[Regex]static compilation problems

Dear users,
to start using regular expressions I tried a very simple program only
declaring one regular expression.
#include

On Sunday 15 February 2009 16:47:24 Moritz Beber wrote:
#include
int main(int , char* []) { boost::regex re("\\d+"); return 0; }
Linking and compiling this with the command:
g++ test.cpp -o test -L ~/libs/boost/lib/ -l boost_regex-gcc43-mt
works without problems, but running it then leads to the following:
error while loading shared libraries: libboost_system-gcc43-mt-1_37.so.1.37.0: cannot open shared object file: No such file or directory
But the directory clearly shows its existence:
Indeed, but the dynamic linker (ldd) cannot find it when loading your ELF-file. There are several solutions to this, namely LD_LIBRARY_PATH, ldconfig, rpath and static linking. You can look them all up if you like. In brief, LD_LIBRARY_PATH is by far the easiest for test development, just set LD_LIBRARY_PATH (environment variable) to point to the right directory: EXPORT LD_LIBRARY_PATH=~/libs/boost/lib (bash syntax). rpath is neat if you use Cmake or autotools, which I would recommend as soon as you are past the toy stage --- it makes a pointer to the right library inside the ELF-file, and removes it again when installing. I wouldn't mess with ldconfig unless you are making distribution like work, and static linking usually gives more troubles than it is worth, besides wasting resources. Hope it helps. -- Kærlig hilsen, Esben
participants (2)
-
Esben Mose Hansen
-
Moritz Beber