Bug 6665 - Import library order does matter
Summary: Import library order does matter
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-15 11:36 UTC by chorns
Modified: 2003-07-25 17:33 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
libtest.tar.gz (699 bytes, application/x-gzip )
2003-05-21 15:16 UTC, chorns
Details

Note You need to log in before you can comment on or make changes to this bug.
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.