I'm noob at C and cmake and experience difficulties with a lib linkage. I have the following cmake:
cmake_minimum_required(VERSION 3.10)
project(EC C)
set(CMAKE_C_STANDARD 11)
add_executable(EC main.c)
set(CURL_INCLUDE_DIR C:/curl-8.14.1_1-win64-mingw/include)
set(CURL_LIBRARY C:/curl-8.14.1_1-win64-mingw/lib/libcurl.a)
find_package(CURL REQUIRED)
if(CURL_FOUND)
message(STATUS "libcurl found")
include_directories(${CURL_INCLUDE_DIRS})
target_link_libraries(EC CURL::libcurl)
else()
message(FATAL_ERROR "libcurl not found")
endif()
While building I receive like this:
C:/Users/DELL/CLionProjects/EC/main.c:22:(.text+0x118): undefined reference to `__imp_curl_easy_init'
As I understood I have a problem with static lib linkage, but can't find workable solution for me. How can I define what a lib is not linked and how to link it?
P.S. I've add add_compile_definitions(CURL_STATICLIB) to the end of cmake as n. m. could be an AI suggests, but get then new warnings like:
undefined reference to `__imp_closesocket`
CURL_STATICLIBpreprocessor macro defined. You can add it by addingadd_compile_definitions(CURL_STATICLIB)to CMakeLists.txt.C:/curl-8.14.1_1-win64-mingw/lib/libcurl.a(unity_0_c.c.obj):unity_0_c.c:(.text$async_thrdd_destroy[async_thrdd_destroy]+0x13e): undefined reference to__imp_closesocket'`