GNOME Evolution contains several interdependent libraries, so on Cygwin/MinGW the build creates artificial import libraries with dlltool from .def files. While trying to build 2.28 I came across a possible incompatibility between the implib generated by dlltool and auto-import linkage:

$ gcc -shared -Wl,--out-implib,libtest.dll.a -o cygtest.dll libtest.c
Creating library file: libtest.dll.a

$ nm libtest.dll.a | grep -v ' [bdit] '

d000003.o:
00000000 I _cygtest_dll_iname

d000000.o:
00000000 I __head_cygtest_dll
         U _cygtest_dll_iname

d000002.o:
         U __head_cygtest_dll
00000000 I __imp__test_func
00000000 T _test_func

d000001.o:
         U __head_cygtest_dll
00000000 I __imp__test_data
00000000 I __nm__test_data

$ gcc -o test.exe test.c libtest.dll.a

# now let's try with dlltool
$ dlltool --dllname cygtest.dll --input-def libtest.def --output-lib libtest.dll.a

$ nm libtest.dll.a | grep -v ' [bdit] '

deobt.o:
00000000 I __libtest_dll_a_iname

deobh.o:
00000000 I __head_libtest_dll_a
         U __libtest_dll_a_iname

deobs00001.o:
         U __head_libtest_dll_a
00000000 I __imp__test_func
00000000 T _test_func

deobs00000.o:
         U __head_libtest_dll_a
00000000 I __imp__test_data
# Note no __nm__test_data auto-import here

$ gcc -o test.exe test.c libtest.dll.a
fu000001.o:(.idata$2+0xc): undefined reference to `_libtest_dll_a_iname'
nmth000000.o:(.idata$4+0x0): undefined reference to `__nm__test_data'
collect2: ld returned 1 exit status


Yaakov
__declspec(dllexport) int test_data = 42;
__declspec(dllexport) int test_func(void) { return test_data; }
EXPORTS
test_func
test_data DATA
extern int test_data;
extern int test_func(void);

int
main(void) {
        int foo = test_data;
        test_func();
        return 0;
}

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

Reply via email to