I use CMake to built a static library with libcurl linked with it.
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})
Now I want to use this library in my other Qt Project. I did the following in the WindowsClient.pro file:
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"
The problem is when I'm trying to build my Qt Project, it always gives me linkage error:
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)
I've stuck on this problem forever...Thanks in advance!!!