dlltool not creating a proper import library

Andrew Begel abegel@eecs.berkeley.edu
Mon Jun 4 16:01:00 GMT 2001


I'm try to use the Mingw32 dlltool to produce an import library from a
.def file I've got. But, the generated import library seems to be
missing a symbol that ld wants to see when it links the import library
with my code. 

When gcc -shared creates a DLL and associated import library (using the
-Wl,--outimp=libfoo.dll.a flag), for each exported symbol, in the
libfoo.dll.a file there are three symbols. One is the original symbol
_bar, the second is
__imp__bar, and the third is __nm__bar.=20

However, when I use dlltool to make an import library from a .def file,
I only get two  symbols for each exported symbol: _bar and __imp_bar.
When I try to link a DLL from a static library that contains my
generated import library (from the .def file), ld complains that
I'm missing the __nm__bar symbol:

i.e. nmth000000.o(.idata$4+0x0): undefined reference to `_nm__bar'

Before this error, I get a warning about the symbol:

Warning: resolving _bar by linking to __imp__bar (auto-import)

In my .def, I have

bar DATA

listed on its own line,

bar is decorated with

extern __declspec(dllimport) int bar;

in its .h file, and my C++ code that includes this .h, references bar.

Is this something where dlltool didn't get changed in sync with gcc
-shared, or is there a flag I can pass to make this work?

Thanks,

Andrew



More information about the Binutils mailing list