问题描述
我有一个简单的问题,链接库与CMake(我不知道CMake很好)。
我的配置如下:
project / src / CMakeLists.txt(所有.cpp和.h文件)
project / support / linux / gmp / include / gmp.h
project / support / linux / gmp / include / gmpxx.h
project / support / linux / gmp / include / libgmp .a
project / support / linux / gmp / include / libgmpxx.a
包括库gmp在编译过程中? (我失去了FIND_PACKAGE,INCLUDE_DIRECTORIES,TARGET_LINK_LIBRARIES,ADD_LIBRARY ...命令)
非常感谢。
第一步
$ b
使用找到库。
find_package(GMP REQUIRED)
第二步
使用以包含库头文件。
include_directories($ {GOBJECT_INCLUDE_DIR})
第三步
使用将您的二进制文件链接到库。
add_executable(ExecutableName Main.cpp)
target_link_libraries(ExecutableName $ {GOBJECT_LIBRARIES})
I have a simple problem with the linking of libraries with CMake (I don't know CMake very well).My configuration is the following :
project/src/CMakeLists.txt (with all .cpp and .h files)
project/support/linux/gmp/include/gmp.h
project/support/linux/gmp/include/gmpxx.h
project/support/linux/gmp/include/libgmp.a
project/support/linux/gmp/include/libgmpxx.a
How to include the library gmp in the process of compilation ? (I am lost between FIND_PACKAGE, INCLUDE_DIRECTORIES, TARGET_LINK_LIBRARIES, ADD_LIBRARY ... commands)
Thank you very much.
CMake is not so hard to understand.
First Step
Use find_package to locate the libary.
find_package(GMP REQUIRED)
Second step
Use include_directories to include the libary header files.
include_directories(${GOBJECT_INCLUDE_DIR})
Third Step
Use target_link_libraries to link your binary against the libary.
add_executable(ExecutableName Main.cpp)
target_link_libraries(ExecutableName ${GOBJECT_LIBRARIES})
这篇关于Cmake基本库链接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!