[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Building a DLL with libltdl support

From: Bill Jones
Subject: Re: Building a DLL with libltdl support
Date: Fri, 02 Jul 2004 09:29:25 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1

Under Windows, if any object module has used "__declspec(dllexport)" then this suppresses the default behavior of ld to export all symbols and it only exports those with the above attribute. This is the case with libltdl. The libltdl/ltdl.h header defines "LT_SCOPE" and uses it throughout libltdl. Therefore, you must use the LT_SCOPE macro for any symbols in file.c that need also to be exported. An alternative is to simply pass "--export-all-symbols" to GNU ld assuming that all symbols need export.


Bill Jones wrote:
I am trying to build a DLL which uses libltdl for dynamic loading of other libtool modules. As a result I am first building libltdl as a "convenience library" using


in my  My DLL is then built with

  libname_la_SOURCES = ...
  libname_la_LDFLAGS = -no-undefined -avoid-version
  libname_la_LIBADD = @LIBLTDL@

All builds without error, however, on Windows under MinGW 3.1.0 and Msys 1.0.9 using

  automake 1.82.
  autoconf 2.59
  libtool 1.5.2

the resulting export library "libname.dll.a" does not contain any exported symbols other than those provided by libltdl (ex: lt_dlsym...lt_dladderror). The libtool link and resulting gcc commands presented by the `make` are paraphased below:

/bin/sh libtool --mode=link gcc -g -O2 -o -rpath ... -no-undefined -avoid-version file.lo libltdl/ gcc -shared .libs/file.o -Wl,--whole-archive libltdl/.libs/libltdlc.a -Wl,--no-whole-archive -o .libs/libname.dll -Wl,--image-base=0x10000000 -Wl,--out-implib,.libs/libname.dll.a

Again, the library is created, there just aren't any exported symbols from file.o. However, if I instead manually link without the "--whole-archive" of the convenience library and simply use the ltdl object file

gcc -shared .libs/file.o libltdl/ltdl.o -o .libs/libname.dll -Wl,--image-base=0x10000000 -Wl,--out-implib,.libs/libname.dll.a

The import library libname.dll.a contains the symbols for libltdl as well as those of file.o as expected.

Any help as to what I am doing wrong is greatly appreciated.



    Bill Jones                                   address@hidden
    Mail Stop 125                       Data Analysis and Imaging Branch
    15 Langley Boulevard                  Systems Engineering Competency
    NASA Langley Research Center                Building 1268, Room 1038
    Hampton, VA  23681-2199                        Phone +1 757 864-5318
                                                     Fax +1 757 864-7635

reply via email to

[Prev in Thread] Current Thread [Next in Thread]