I am trying to build a c++ program using Unix.
I got the error
Linking CXX executable ../../bin/ME
/usr/bin/ld: cannot find -lboost_regex-mt
I heard that I just need to set the location of libboost* in my LD_LIBRARY_PATH env variable and then invoke make as I originally did, by typing
-L /usr/lib64 -l boost_regex-mt
or
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64
But where is LD_LIBRARY_PATH? how do I set the LD_LIBRARY_PATH env variable?
Best Answer
You already set it when you did this:
But that will not solve your problem.
$LD_LIBRARY_PATH
is consulted at time of execution, to provide a list of additional directories in which to search for dynamically linkable libraries. It is not consulted at link time (except maybe for locating libraries required by the built tools themselves!).In order to tell the linker where to find libraries at build time, you need to use the
-L
linker option. You already did that too:If you are still getting the error, then you need to make sure that the library is actually there. Do you have a file
libboost_regex-mt.so
orlibboost_regex-mt.a
in that (or any) directory? Note that a file likelibboost_regex-mt.so.othersuffix
doesn't count for this purpose. If you don't have that, then you probably need to install your distribution's development package for this library.