This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Does the order of command line arguments matter?


The -l options are used to specify libraries.  They are passed to the
linker.  The way linking (with libraries) works, is that the .o's are
processed, and then the -l's are used, in order, to resolve the
undefineds up until that point.

If a library uses something that isn't defined yet, the library that
defines the symbol MUST be added after the one where it is used.
Because of this, you link .o's first (since they are used in their
entirety), followed by the -l's (which are selectively used based upon
which modules in the libraries contain the symbols you need to resolve).

	Dave

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of sxm@everymail.net
Sent: Tuesday, December 21, 2004 3:28 PM
To: gcc-help@gcc.gnu.org
Subject: Does the order of command line arguments matter?

Hi,
I try to compile a file (scroll_ex.c from the 'Curses
Development Kit'). The following command line does the job:

gcc -g scroll_ex.c -o scroll_ex  -lcdk -lncurses

But when I first tried this:

gcc -g -lcdk -lncurses scroll_ex.c -o scroll_ex

the compiler complained:

...undefined reference to `CDKparseParams'...
...

('CDKparseParams' is a function of libcdk.a) 

I would like to understand that behaviour. The info- pages
say that I can 'mix options and other arguments' and that
their order does (almost) not matter. I have gcc v. 3.3.1.

I would be grateful if someone could point me in the right
direction.

sxm




------------------------ Werbung -----------------------
>>  NEU: Ab sofort: AT-Domains superguenstig um EUR 7,00
http://www.emerion.com


---------------------------------------------------------
*** sent through http://www.everymail.net     FREE e-mail 
             


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]