简体   繁体   中英

Include external Library cmake

I want to use the SQLAPI library, i have copied all files in the include directory to usr/local/include/SQLAPI and all files from the lib directory to usr/local/lib. The lib files are named libsqlapi.a /libsqlapi.so and libsqlapiu.a /libsqlapiu.so .

My cmakeLists.txt looks like this:

project(gsl_test)
cmake_minimum_required(VERSION 2.8)

SET(CMAKE_CXX_FLAGS "-std=c++0x")

aux_source_directory(. SRC_LIST)
include_directories(usr/local/include)
link_directories(usr/local/lib)

add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME} libsqlapi)

I get the build/linker error: cannot find -llibsqlapi.

I did also try target_link_libraries(${PROJECT_NAME} sqlapi), but it gives me additional "skipping incompatible //usr/local/lib/libsqlapi.so" (and the same for .a) with cannot find -lsqlapi

Ok, i'll change my edit to an answer:

The reason linker complained was the fact that you specified the library in the wrong manner. lib is just prefix - if you use target_link_libraries you use the rest of library name. Changing to

target_link_libraries(${PROJECT_NAME} sqlapi)

solved that issue. The error you receive now

skipping incompatible //usr/local/lib/libsqlapi.so

Is most probably caused by the fact that you have copied all the files from some pre-build package and it's not compatible with your system. You need to recompile the library on your own.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM