我已经从源代码构建了Curl,它安装在 /usr/local/lib/libcurl.so
/usr/local/lib/libcurl.so
我现在正试图指示CMake将此版本与我的应用程序静态链接(如果动态更容易,那也没关系)。
从其他Stackoverflow问题中,我尝试了以下方法:
option(CURL_STATICLIB "Set to ON to build libcurl with static linking." ON) option(LIBCURL_ENABLE "Enable or disable the requirement of libcurl" ON) set(CURL_LIBRARY "-lcurl") set(CURL_PATH "/usr/local/lib") find_library(LIB_CURL NAMES libcurl PATHS ${CURL_PATH}) include_directories(${CURL_INCLUDE_DIR}) message(STATUS "LIB_CURL: " ${LIB_CURL}) add_definitions(-DCURL_STATICLIB) target_link_libraries(my_project PRIVATE ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES})
但它找不到 libcurl.so :
libcurl.so
LIB_CURL: LIB_CURL-NOTFOUND
(我的CMake知识是基本的,欢迎您提供任何其他改进技巧)
option(CURL_STATICLIB "Set to ON to build libcurl with static linking." ON) option(LIBCURL_ENABLE "Enable or disable the requirement of libcurl" ON)
option 使用错误。curl没有在CMakeLists中配置,因此 选项 应移除。
option
选项
尝试
find_library(LIB_CURL NAMES curl PATHS ${CURL_PATH})
这是不清楚的,你定义 -DCURL_STATICLIB 但是寻找 libcurl.so
-DCURL_STATICLIB