Problems using boost-regex after being compiled as non root.
Javier-Elias Vasquez-Vivas wrote:
Hi all,
I'm new at using boost. I was able to compile it and install it with "--prefix". The reason to use "--prefix" is not having root access... I used the following bjam command to compile:
bjam --prefix=$PATH1 install
Then I got under $PATH1 the following stuff:
$PATH1/lib/
$PATH1/include/boost-1_32/boost/ (including regex.hpp and its sub-directory) So I copied credit_card_example.cpp in $PATH2 and tried to compile it as follows:
g++ -I$PATH1/include/boost-1_32 -L$PATH1/lib credit_card_example.cpp
Is any one aware of what I might be doing wrong, so that can indicate how to do things right?
You at least need to tell GCC that you want to link to the regex library. By using the -l option. -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com - 102708583/icq
Then someone in the list indicated I at least needed to indicate I want to link regex library, and "-l" was indicated for that purpose:
c++ -I$PATH1/include/boost-1_32 -L$PATH1/lib -llibboost_regex-gcc credit_card_example.o -o memo
I'm surprised that this works, you normally need to to place the list of libraries *after* the object files that use them: that's probably why the -static option failed.
When I read the documentation for "-l" I found "The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker then uses this file as if it had been specified precisely by name.", so I'm confused why the dynamic library is being used... Any ways, I used -static, and it didn't work when it should ("On systems that support dynamic linking, this prevents linking with the shared libraries").
The linker always links to a shared library in preference to a static one when there's a choice.
Besides this static/dynamic problem, I'm wondering why I need to specify the boost libraries to use (that's not required for std libraries at all). If one requires several boost libraries, then are all them to be specified as well?
Yes, gcc will only link to those libraries that are always required (the C and C++ runtimes), optional system libraries (-lpthread, -lm, -lrt etc) and all third party libraries need to be explicitly listed, John.
participants (3)
-
Javier-Elias Vasquez-Vivas
-
John Maddock
-
Rene Rivera