Note that there are some explanatory texts on larger screens.

plurals
  1. POLinker not taking local (user) boost installation with g++
    primarykey
    data
    text
    <p>I want to have local installation (in my home-folder (Linux), say $HOME/boost) of the boost C++ libraries in addition to a system-wide installed default of the boost libs. I built them from sorce and that worked fine.</p> <p>After that, I set the environment variables CPLUS_INCLUDE_PATH and LD_LIBRARY_PATH to match the destination of the local installation, so both pointing to $HOME/boost/include and $HOME/boost/lib/, respectively.</p> <p>In order to test that, I used the following code for testing the correct usage of CPLUS_INCLUDE_PATH for the headers:</p> <pre><code>#include &lt;boost/version.hpp&gt; #include &lt;iostream&gt; #include &lt;iomanip&gt; int main() { std::cout &lt;&lt; "Boost version: " &lt;&lt; BOOST_LIB_VERSION &lt;&lt; std::endl; return 0; } </code></pre> <p>Compiling it with <code>g++ -o Test_boost_version test_boost_version.cpp</code> works as expected, reporting the expected (local) version. Having CPLUS_INCLUDE_PATH empty gives me the boost-version of the default, system-wide installation. So far so good.</p> <p>In order to test the linking, I used the following code (taken from the boost homepage:</p> <pre><code>#include &lt;boost/regex.hpp&gt; #include &lt;iostream&gt; #include &lt;string&gt; int main() { std::string line; boost::regex pat( "^Subject: (Re: |Aw: )*(.*)" ); while (std::cin) { std::getline(std::cin, line); boost::smatch matches; if (boost::regex_match(line, matches, pat)) std::cout &lt;&lt; matches[2] &lt;&lt; std::endl; } } </code></pre> <p>and built it with <code>g++ -o Test_boost_linking test_boost_linking.cpp -lboost_regex</code>.</p> <p>Calling <code>ldd Test_boost_linking</code> however does NOT make use of the local installation (provided via LD_LIBRARY_PATH) but gives me: <code>libboost_regex.so.1.42.0 =&gt; /usr/lib/libboost_regex.so.1.42.0 (0x00007f9264612000)</code></p> <p>When I use <code>g++ -o Test_boost_linking test_boost_linking.cpp -lboost_regex -L$HOME/boost/lib</code>, ldd is reporting the correct library (<code>libboost_regex.so.1.50.0 =&gt; $HOME/boost/lib/libboost_regex.so.1.50.0 (0x00007f6947d2a000)</code>).</p> <p>This is actually a problem for me since I want to set up my local environment such that a compilation will ignore the system-default boost installation and only use the local installation and I thought this is exactly what is achieved when setting the CPLUS_INCLUDE_PATH and LD_LIBRARY_PATH, but for the latter, this seems not to hold true.</p> <p>So how can I make sure that using <code>g++ -o Test_boost_linking test_boost_linking.cpp -lboost_regex</code> (without -L) uses the local libraries?</p> <p>[EDIT] Thinking of it further, I am wondering IF it is actually <em>absolutely</em> mandatory to use "-L$HOME/boost/lib" in the command-line (using LDFLAGS as environment variable seems to have no effect, probably just in combination with a Makefile) when using libraries in a non-standard directory?? Is this the case?</p> <p>(BTW I think this will hold true also for other libraries, not only boost...)</p> <p>(I used: g++ (Debian 4.4.5-8) 4.4.5)</p> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload