Boost logo

Boost Users :

From: KSpam (keesling_spam_at_[hidden])
Date: 2007-05-30 02:28:13


Scott,

> I was hoping that all I had to do for g++ was do the same for the
> LIBRARY_PATH environment variable (per
> http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html), but I get
> unresolved symbol errors during linking even after doing that. I played
> around with the -l option (per
> http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options), but
> nothing I tried worked.

The -l (lowercase) option tells the linker what library to link in, and the -L
(uppercase) option tells the linker where to find the library.

Another potential hangup is in naming the library on the command line.
Windows users are used to specifying the full name of the library, but the
Unix way is to not include the "lib" prefix. The gcc compiler works the Unix
way. In other words, you want "-lboost_regex" instead of "-llibboost_regex".

> Can somebody explain or point me to an explanation of what I need to do to
> get a program using Boost binaries to link? I'm hoping there's something
> as simple as with VC8 where I can just specify a directory to look in and
> have the linker magically figure everything out from there. I'd like to
> avoid explicitly having to add a new library to link against each time I
> start using a new compiled Boost library in a project.

Unfortunately, the option you are looking for does not exist on the gcc
compiler (to my knowledge). You want "auto_link". If you look in
boost/config/auto_link.hpp, you will see a line similar to the following:

#pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")

This pragma statement is a directive that VC8 uses to automatically link in a
library when a certain header is included in a compilation unit. With gcc,
you have to do this task manually by adding the library name to the link line
with the -l (lowercase) option.

Respectfully,
Justin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net