ld does not alias with .lib files. Of course, you can use .a files instead, if you are able to generate them. Below is a makefile that generates an error. The makefile requires components of VC Express to generate a .lib, namely lib.exe, link.exe and mspdb80.dll. The makefile generates two variants of a small application: one by using a .lib file and one by using a .a file. The first variant does not work, because it does not alias. But the "real-life application" by which I signaled the problem does only not work when a .dll is generated with the .lib file (say, foo_test_lib.dll). I have not been able yet to isolate the reason for that. all: foo_test_a.exe foo_test_lib.exe clean: del foo*.* foo.cpp: echo extern "C" __declspec(dllexport) int foo() > 1.tmp echo { return 3840; } > 2.tmp copy /b 1.tmp+2.tmp foo.cpp del ?.tmp foo.def: echo LIBRARY foo > 1.tmp echo EXPORTS > 2.tmp echo foo > 3.tmp echo bar = foo > 4.tmp copy /b 1.tmp+2.tmp+3.tmp+4.tmp foo.def del ?.tmp foo.dll: foo.cpp g++ -shared foo.cpp -o foo.dll foo.lib: foo.def lib /def:foo.def del foo.exp foo.a: foo.def dlltool -d foo.def -l foo.a foo_test.cpp: echo #include "stdio.h" > 1.tmp echo extern "C" __declspec(dllimport) int bar(); > 2.tmp echo main() { printf("%%x\n", bar()); } > 3.tmp copy /b 1.tmp+2.tmp+3.tmp foo_test.cpp del ?.tmp foo_test.o: foo_test.cpp g++ -c foo_test.cpp -o foo_test.o foo_test_a.exe: foo_test.o foo.a foo.dll g++ foo_test.o -o foo_test_a.exe -Wl,foo.a foo_test_lib.exe: foo_test.cpp foo.lib foo.dll g++ foo_test.o -o foo_test_lib.exe -Wl,foo.lib
I believe the problem is that in the old version of ld you are using the *.lib name was not recognized as a dynamic lib so ld used direct linking to foo.dll in preference to linking against the "static" foo.lib This is fixed in recent binutils (2.18). Can you try that? As a work-around you could try renaming the LIB.EXE generated foo.lib to libfoo.a Danny
As per comment #1, probably fixed a long time ago.