Mail Archives: cygwin/2002/05/06/20:09:39
Summary:
I am trying to figure out how to build a dll with the cygwin tools.
I consulted the list archives and proceeded to download dllhelpers-0.4.0. I
assumed that a working example would reveal everything that I needed to
know.
The examples don't work for me as described: global variables are not
successfully exported, only functions are exported. (details below)
Does this happen to anybody else?
Any idea what I'm doing wrong? My impression from searching the list
archives is that this issue was fixed some time ago. Am I mistaken in this
understanding?
Rob Kroeger
rjkroege AT liqui DOT org
----
Messy details:
I get the same results for cygwin installs on two different cygwin installs
(though from the same mirror), (cygcheck -c output at bottom)
Here's what happens (all in the 'c' example -- to keep things as simple as
possible):
$ make
gcc -c -I. -g -Wall -o cdll.o cdll.c
gcc -shared -Wl,--out-implib=libcdll.dll.a \
-o cygcdll.dll cdll.o -Wl,--export-all-symbols
Creating library file: libcdll.dll.a
gcc -c -I. -g -Wall -o usedll.o usedll.c
gcc -o usedll.exe -g -Wall usedll.o -L./ -lcdll
usedll.o: In function `main':
/home/rjkroege/docs/dllhelpers-0.4.0/c/usedll.c:9: undefined reference to
`dll_global_int_var'
/home/rjkroege/docs/dllhelpers-0.4.0/c/usedll.c:12: undefined reference to
`dll_global_int_var'
/home/rjkroege/docs/dllhelpers-0.4.0/c/usedll.c:14: undefined reference to
`dll_global_int_var'
/home/rjkroege/docs/dllhelpers-0.4.0/c/usedll.c:19: undefined reference to
`dll_global_int_var'
collect2: ld returned 1 exit status
make: *** [usedll.exe] Error 1
Obviously, dll_global_int_var is not exported in libcdll.dll.a.
If I remove references to dll_global_int_var from usedll.c, everything links
and runs fine -- so the example works fine for function symbols but not for
data symbols.
If I change the defn of dll_global_int_var to
extern __declspec(dllimport) int dll_global_int_var;
in the importer and
int __declspec(dllexport ) dll_global_int_var = 99; in the exporter,
then once again everything works fine.
Further confounding me, nm generates identical results for libcdll.dll.a and
cygdll.dll both WITH and WITHOUT the presence of __declspec.
abbreviated cygcheck -c:
Cygwin Package Information Package Version
ash 20011018-1
bash 2.05a-3
binutils 20011001-1
cygutils 1.0.0-1
cygwin 1.3.10-1
cygwin-doc 1.0-1
dllhelpers 0.4.0
gcc 2.95.3-5
libtool 20010531a-1
libtool-devel 20020202-1
libtool-stable 1.4.2-2
make 3.79.1-6
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -