链接共享库时出现上面问题,编写CMakeLists.txt时,
cmake_minimum_required(VERSION 3.0)
INCLUDE_DIRECTORIES(/usr/local/include/hello)
ADD_EXECUTABLE(main main.c)
TARGET_LINK_LIBRARIES(main libhello.so)
查找问题,
In addition to the accepted answer: An important detail is to place target_link_libraries
afterthe add_executable
and find_package
lines, so all linked components are known.
原来编写时,先写add_executable() ,然后再是target_link_libraries(),最后写find_packed().