我正在尝试使用cmake来构建我的项目。我想链接到我的系统中存在的libpng。这是我的代码:
cmake_minimum_required(VERSION 2.8.11)
project(main)
file(GLOB SOURCES *.c)
add_executable(sphstego ${SOURCES})
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS})
target_link_libraries(main ${PNG_LIBRARY})
message(STATUS "PNG_LIBRARY: " ${PNG_LIBRARY}) # correct path to so file
我的问题是我想静态链接而不是动态链接。此外,虽然设置为PNG_LIBRARY的变量已正确设置为 /usr/local/lib/libpng.so ,但在运行可执行文件时出现错误消息:
error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
有关如何解决此问题的任何建议?