problem with order of -lmylibrary flags.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've found kind of a weird issue where if I indicate I want to link a
library with the -l flag too early on the command line, I get linker
errors.

Here's an example:
g++ -lml -lcvaux -lhighgui -lcv -lcxcore   -std=c++0x -Werror -Wall -g
-MMD -MP -Iinclude  -o objrec main.cpp

Here I'm linking a bunch of libraries, into a binary called objerec.
The source file is at the end. This command line produces linker
errors as if the libraries had not been linked properly.

However in this example everything is fine:
g++  -std=c++0x -Werror -Wall -g -MMD -MP -Iinclude  -o objrec
main.cpp -lml -lcvaux -lhighgui -lcv -lcxcore

The only difference is that I place the -l flags after the source file
(main.cpp) that I'm building.

Why does the second example compile while the first gets linker errors?

A more general question: in a make file is it better to list libraries
you want to link in the LDFLAGS variable, or in the LDLIBS variable?

Thanks,
Brendan Miller


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux