I built a C library (compiled from source) below my home folder and now I have to build a new package that depends on that library. When running the configure script I get the error
configure: error: The required <package> library was not found.
Is there an environment variable I can edit to make my script search the library's path?
I already tried LD_LIBRARY_PATH
you should set C_INCLUDE_PATH or CPLUS_INCLUDE_PATH, for C or C++ respectively.
More information is available gcc documentation
Related
On my system (Fedora 26), I installed XercesC using yum (aka dnf). The XercesC header files are located in
/usr/include/xercesc-2.7.0/xercesc
and the library is
/usr/lib64/libxerces-c.so.27.
I have tried the official FindXercesC.cmake as well as a number of posted versions of this package finder. I also attempted many edits to the posted *.cmake files. None of them can locate XercesC and I have to resort to manually entering the locations for the headers and library.
Is there a CMake package finder for XercesC that will automatically locate XercesC on my system?
Normally, CMake search things only in default directories. E.g., /usr/include directory is automatically searched for the header files.
But directory /usr/include/xercesc-2.7.0 isn't a default for CMake (it is not default for compiler too), so CMake cannot find things there without an explicit hint. For hint CMake about include directory to search, set CMAKE_INCLUDE_PATH variable. E.g., via command line:
cmake -DCMAKE_INCLUDE_PATH=/usr/include/xercesc-2.7.0 <other_params>
Similar is true for searching library files: CMake automatically searches libraries under /usr/lib64/, but not under /usr/lib64/xercesc-2.7.0. Also, CMake can find only library without so-version, so it cannot find file /usr/lib64/libxerces-c.so.27. For finding a file /usr/lib64/xercesc-2.7.0/libxerces-c.so you need to hint CMake with CMAKE_LIBRARY_PATH variable.
According to the xercesc sources, it supports searching the package via pkg-config and via CONFIG mode of find_package. Probably, these variants won't require additional hints.
Searching via pkg-config can be performed with pkg_check_modules, for use find_package in CONFIG mode either add this option to the call find_package(XercesC), or simply remove FindXercesC.cmake script.
I am working on centos. I installed boost version 1.45.0 on my system. The programs are compiled correctly but whenever I type command to see output it gives following error:
./a.out: error while loading shared libraries:
libboost_thread.so.1.45.0: cannot open shared object file: No such
file or directory
In addition to the other answers, you can also set the DT_RPATH elf tag when linking your executable
-Wl,-rpath,/path/to/boost/libraries -L /path/to/boost/libraries -lboost_whatever
This way you don't have to remember to set your LD_LIBRARY_PATH if the libraries are installed in a non-standard location.
How did you install the boost libraries?
The problem you're likely having is that the linker can not find the libraries, and when you built your program, you had to manually specify additional library paths to search for libraries.
A quick fix you can do is to set LD_LIBRARY_PATH to include the directory where the boost thread library is:
export LD_LIBRARY_PATH=/path/to/boost/libs:$LD_LIBRARY_PATH
./runExecutable
You need to set the LD_LIBRARY_PATH environment variable to include the path to the Boost libraries (they're possibly in /usr/local/lib, etc).
In bash, this is simply
export LD_LIBRARY_PATH=/path/to/boost:$LD_LIBRARY_PATH
If you use the command target_link_libraries in cmake, when linking the linker will search for libraries which name match some criteria. For instace:
Using following command:
target_link_libraries(some_target some_lib)
In Linux the linker will search for: libsome_lib.so while in Windows the linker will search for some_lib.lib (in Windows I'm compiling a VS project generated from the cmake project).
Due to deployment requirements of my application the libraries have no extension and have to be called the same in both OS (e.g some_lib).
How can I tell cmake that search for such library?
I suppose that entering the full path will do the trick, but, there is another any way to do this?
Edit: Specifying the full path to the library does not work.
I didn't ever test that, but the CMake Wiki Docs refer these variables to specify library extensions:
CMAKE_FIND_LIBRARY_SUFFIXES
CMAKE_IMPORT_LIBRARY_SUFFIX
Windows-specific. Appears to be read-only. Use SET_TARGET_PROPERTIES.
CMAKE_LINK_LIBRARY_SUFFIX
Windows-specific.
CMAKE_SHARED_LIBRARY_SUFFIX
Appears to be read-only. Use SET_TARGET_PROPERTIES.
CMAKE_STATIC_LIBRARY_SUFFIX
Appears to be read-only. Use SET_TARGET_PROPERTIES.
I am trying to build a c++ implementation of hidden markov models - downloaded from
http://www.cs.au.dk/~asand/?page_id=152
I am compiling this on an ubuntu 12.04 with a g++ 4.6 compiler.
Following the instructions mentioned on the webpage, on typing
cmake .
I get the following errors,
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
CMake Error at CMakeLists.txt:101 (message):
The Boost C++ libraries was not found. Get Boost from
http://www.boost.org/ or set the environment variable BOOST_ROOT to point
to the root of boost directory.
Could someone help me resolve these issues out.
My boost folder is situated at
/usr/local/boost_1_52_0
It's telling you to set BOOST_ROOT environment variable. So just do it:
BOOST_ROOT=/usr/local/boost_1_52_0 cmake
(prefixing a command with setting of an environment variable in posix shell sets it for just that command; cmake will remember the value in CMakeCache.txt afterwards)
I suppose the fact it didn't find doxygen does not matter. You will should still be able to build the library, you just won't be able to generate nice documentation for it, but that probably exists on the web somewhere or you can read it in the headers directly anyway.
I am working on centos. I installed boost version 1.45.0 on my system. The programs are compiled correctly but whenever I type command to see output it gives following error:
./a.out: error while loading shared libraries:
libboost_thread.so.1.45.0: cannot open shared object file: No such
file or directory
In addition to the other answers, you can also set the DT_RPATH elf tag when linking your executable
-Wl,-rpath,/path/to/boost/libraries -L /path/to/boost/libraries -lboost_whatever
This way you don't have to remember to set your LD_LIBRARY_PATH if the libraries are installed in a non-standard location.
How did you install the boost libraries?
The problem you're likely having is that the linker can not find the libraries, and when you built your program, you had to manually specify additional library paths to search for libraries.
A quick fix you can do is to set LD_LIBRARY_PATH to include the directory where the boost thread library is:
export LD_LIBRARY_PATH=/path/to/boost/libs:$LD_LIBRARY_PATH
./runExecutable
You need to set the LD_LIBRARY_PATH environment variable to include the path to the Boost libraries (they're possibly in /usr/local/lib, etc).
In bash, this is simply
export LD_LIBRARY_PATH=/path/to/boost:$LD_LIBRARY_PATH