Home Ask Login Register

Developers Planet

Your answer is one click away!

Khang Truong 2 weeks ago

Link to static library by cmake

I have a project C++ using libnuma library. Because I don't have permission to install libnuma in the root system, so I have to install it in folder of user: /home/khangtg/opt. This folder contains 2 main folders:

  • Folder include contains: numacompat1.h, numa.h, numaif.h
  • Folder lib contains: libnuma.a, libnuma.la, libnuma.so, libnuma.so.1, libnuma.so.1.0.0

Now, I have a file .cpp include libnuma library:

#include <numa.h>

and I build the project by file CMakeLists.txt with content:

add_library (common Bigraph.cpp AdjList.cpp Vocab.cpp NumaArray.cpp clock.cpp)
set (LINK_LIBS ${LINK_LIBS} common gflags numa )

add_executable (warplda main.cpp lda.cpp warplda.cpp)
add_executable (format format.cpp)

target_link_libraries (warplda ${LINK_LIBS})
target_link_libraries (format ${LINK_LIBS})

After run cmake command, I get some error that is "can not include numa.h".

So, how can I fix this error and build the project by cmake. Many thanks!


Marcus Karpoff 2 weeks ago

you want to set the link_directories to include the director of the libraries. More can be found in the cmake docs. This tells the linker where to look for the libraries.

Post Status

Asked in 2 weeks ago
Viewed 2,312 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life