I was looking for a watch on how to solve this, and everything I tried does not work. I am trying to link statically with some libraries (libPoco, libmysqlcpp, libmysqlclient, libssl).
I use cmake, and although I define a static library, cmake is just looking for a dynamic one. I know that I have all the necessary libraries in a static archive in my file system, and I know where they are.
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64 /usr/lib/x86_64-linux-gnu) find_library(POCO_NET NAMES libPocoNet.a PATHS CMAKE_LIBRARY_PATH STATIC IMPORTED) find_library(POCO_UTIL NAMES libPocoUtil.a PATHS CMAKE_LIBRARY_PATH STATIC IMPORTED) find_library(POCO_XML NAMES libPocoXML.a PATHS CMAKE_LIBRARY_PATH STATIC IMPORTED) find_library (MYSQL_CLIENT NAMES libmysqlclient.a PATHS CMAKE_LIBRARY_PATH STATIC IMPORTED) find_library (MYSQL_CPP NAMES libmysqlpp.a PATHS CMAKE_LIBRARY_PATH STATIC IMPORTED) find_library (LIBSSL NAMES libssl.a PATHS CMAKE_LIBRARY_PATH STATIC IMPORTED) if (POCO_NET AND POCO_UTIL AND POCO_XML AND MYSQL_CLIENT AND MYSQL_CPP AND LIBSSL) message(STATUS ${POCO_NET}) message(STATUS ${POCO_UTIL}) message(STATUS ${POCO_XML}) message(STATUS ${MYSQL_CLIENT}) message(STATUS ${MYSQL_CPP}) message(STATUS ${LIBSSL}) target_link_libraries(icarus PocoNet PocoUtil PocoXML mysqlpp mysqlclient ssl) else () message(FATAL_ERROR "FATAL ERROR: missing library") endif (POCO_NET AND POCO_UTIL AND POCO_XML AND MYSQL_CLIENT AND MYSQL_CPP AND LIBSSL)
But when I started cmake .. , I get:
-- /usr/local/lib/libPocoNet.so -- /usr/local/lib/libPocoUtil.so -- /usr/local/lib/libPocoXML.so -- /usr/lib/x86_64-linux-gnu/libmysqlclient.so -- /usr/lib/libmysqlpp.so -- /usr/lib/libssl.so
And when I try to compile, I get undefined links, since I use the -static flag. What am I missing here? Is there a way to get cmake to look for static libraries instead of dynamic ones? Am I really wrong? Thanks.
Γlex source share