This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to compile with gcc/cygwin for "multithreaded DLL" access?


I have a simple program that compiles and runs fine when built using Visual Studio. It accesses the SICL instrument control DLL (sicl32.dll). The program needs to be compiled with the "Use run-time library: Multithreaded DLL" option on the VS's Project Settings dialog. This executable runs fine and uses the following DLLs:

cygcheck Debug/testSicl.exe
Debug/testSicl.exe
  .\SICL32.dll
    C:\WINDOWS\system32\KERNEL32.dll
      C:\WINDOWS\system32\ntdll.dll
    C:\WINDOWS\system32\ADVAPI32.dll
      C:\WINDOWS\system32\RPCRT4.dll
    C:\WINDOWS\system32\VERSION.dll
    C:\WINDOWS\system32\MSVCR70.dll
  C:\WINDOWS\system32\MSVCRT.dll

I can compile and link this same program with gcc (cygwin) but don't know how to specify to gcc that it will use a "Multithreaded DLL". The compile/link looks like:

gcc -g -o testSicl -I /cygdrive/c/progra~1/agilent/iolibr~1/c testSicl.c -L . -lsicl32

cygcheck testSicl.exe
Found: .\testSicl.exe
testSicl.exe
  C:\cygwin\bin\cygwin1.dll
    C:\WINDOWS\system32\ADVAPI32.DLL
      C:\WINDOWS\system32\ntdll.dll
      C:\WINDOWS\system32\KERNEL32.dll
      C:\WINDOWS\system32\RPCRT4.dll
  .\SICL32.dll
    C:\WINDOWS\system32\VERSION.dll
    C:\WINDOWS\system32\MSVCR70.dll

Note that I needed to make a local copy of SICL32.dll so that I didn't need to have /cygdrive/c/windows/system32 on my command line. 

testSicl: cygcheck Debug/testSicl.exe
When I run it, I successfully invoke the iopen( ) function in the SICL DLL. When I call the iprintf( ) function, it core dumps. Here's the gdb backtrace:

./testSicl gpib0,15
successful open of "gpib0,15" inst=0x00000001
Segmentation fault (core dumped)

gdb testSicl
GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-cygwin"...
(gdb) r gpib0,15
Starting program: /cygdrive/c/dmcp/ieee1588/omniber/testSicl/testSicl.exe gpib0,
15
successful open of "gpib0,15" inst=0x00000001

Program received signal SIGSEGV, Segmentation fault.
0x610ed429 in wmemset () from /usr/bin/cygwin1.dll
(gdb) bt
#0  0x610ed429 in wmemset () from /usr/bin/cygwin1.dll
#1  0x610ebd6c in wmemset () from /usr/bin/cygwin1.dll
#2  0x610ebc08 in wmemset () from /usr/bin/cygwin1.dll
#3  0x610e7647 in wmemset () from /usr/bin/cygwin1.dll
#4  0x610938ef in cygwin1!aclcheck () from /usr/bin/cygwin1.dll
#5  0x610064a3 in getprogname () from /usr/bin/cygwin1.dll
#6  0x610066b0 in dll_crt0@0 () from /usr/bin/cygwin1.dll
#7  0x00000000 in ?? () from
(gdb) k
Kill the program being debugged? (y or n) y
(gdb) q

Thanks in advance,

-	J
-	
Jeff Burch

Agilent Laboratories                       
Communications Solutions Department
System and Solutions Lab
3500 Deer Creek Rd, M/S 24M-A               
Palo Alto, CA 94304-1392
                    
e-mail: jeff_burch@agilent.com 
Phone:  650-485-6364 
Fax: 650-485-8092


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]