我使用CMake构建了一个与libcurl链接的静态库。
find_package(CURL REQUIRED)
if(CURL_FOUND)
message(STATUS "curl found")
include_directories(${CURL_INCLUDE_DIR})
set(requiredlibs ${requiredlibs} ${CURL_LIBRARY})
else()
message(FATAL_ERROR "CURL NOT FOUND")
endif(CURL_FOUND)
target_link_libraries(${LIB_NAME} ${CURL_LIBRARY})
现在我想在我的其他Qt项目中使用这个库。我在WindowsClient.pro文件中执行了以下操作:
DEPENDPATH += "$$PWD/../../LIB_NAME/include"
INCLUDEPATH += "$$PWD/../../LIB_NAME/include"
Debug:LIBS += -L"$$PWD/../../LIB_NAME/build/Debug/" -lmyLib-d
Debug:PRE_TARGETDEPS += "$$PWD/../../LIB_NAME/build/Debug/myLib-d.lib"
Release:LIBS += -L"$$PWD/../../LIB_NAME/build/Release/" -lmyLib
Release:PRE_TARGETDEPS += "$$PWD/../../LIB_NAME/build/Release/myLib.lib"
问题是当我尝试构建我的Qt项目时,它总是给我链接错误:
myLib.lib(lib.obj):-1: error: LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall lib::fetchCompanyName(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?@@QAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V34@@Z)
我永远坚持这个问题......提前谢谢!!!