cmake ignores static library link request -


i've searched hours on how solve , tried did not work. i'm trying link statically libraries, (libpoco, libmysqlcpp, libmysqlclient, libssl).

i'm using cmake, , although defining static library, cmake looks dynamic one. know have required libraries in static archive in filesystem, , know 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 , poco_util , poco_xml , mysql_client , mysql_cpp , 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 , poco_util , poco_xml , mysql_client , mysql_cpp , libssl) 

but when run cmake .. is:

-- /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 try compile, undefined references since using -static flag. missing here? there way force cmake lookup static libraries instead of dynamic ones? going wrong way this? thank you.

it looks you're getting wee bit confused between add_library , find_library commands. find_library doesn't take arguments of static or imported.

also, you've not wrapped cmake_library_path in ${} inside find_library call, you're passing 3 paths of "cmake_library_path", "static" , "imported" cmake's search routine, not intended 6 paths of ${cmake_library_path}.

finally, since ${cmake_library_path} first port of call in cmake search routine, there's no need add explicitly find_library commands.

so can like:

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) find_library(poco_util names libpocoutil.a) find_library(poco_xml names libpocoxml.a) find_library(mysql_client names libmysqlclient.a) find_library(mysql_cpp names libmysqlpp.a) find_library(libssl names libssl.a paths)  if(poco_net , poco_util , poco_xml , mysql_client , mysql_cpp , 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              ${poco_net}             ${poco_util}             ${poco_xml}             ${mysql_client}             ${mysql_cpp}             ${libssl}) else()   message(fatal_error "fatal error: missing library") endif() 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -