Bug 6665

Summary: Import library order does matter
Product: gcc Reporter: chorns
Component: cAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, rth
Priority: P3    
Version: unknown   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: libtest.tar.gz

Description chorns 2002-05-15 11:36:00 UTC
This has troubled me a couble of times before so I decided to make an example that illustrates the problem. If gcc builds an executable from a static library (or just a regular object file) that imports functions from a dynamic library, then gcc cannot resolve the imports from the import library if the import library is specified before the static library on the command line. E.g.

gcc -o myprogram.exe myprogram.o mydlibrary.a myslibrary.o

will not work, but 

gcc -o myprogram.exe myprogram.o myslibrary.o mydlibrary.a

will work.

Release:
Current CVS

Environment:
Cross compile i386-mingw32msv from linux

How-To-Repeat:
Run the attached example.
Comment 1 chorns 2002-05-15 11:36:00 UTC
Fix:
Put the import library last on the command line to gcc.
Comment 2 Richard Henderson 2002-05-16 19:08:29 UTC
State-Changed-From-To: open->closed
State-Changed-Why: (1) The linker is in the binutils package, not gcc.
    (2) The linker is working as designed.