I am trying to use cmake to build my project. I want to link against libpng which is present in my system. This is my code:
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
My problem is that I want to link statically rather than dynamically. Furthermore, and although the variable set as PNG_LIBRARY is correctly set to /usr/local/lib/libpng.so, I get an error message when running my executable:
error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
Any suggestions on how to resolve this?