1

I have been struggling for the last 8 hours to find information on how to reference a library in a C project on Windows built with CMake, specifically cURL.

I have downloaded version 7.67 cURL source from the website, and then went used the visual studio developer command prompt to compile the CMake project into a build folder using the standard method of:

cd winbuild
nmake /f Makefile.vc mode=dll

Which outputs three curl folders, one of them called "libcurl-vc-x86-release-dll-ipv6-sspi-winssl". In that folder contains a lib, a bin, and an include folder.

I built my C project with CLion and this is the CMake file that is generated.

cmake_minimum_required(VERSION 3.15)
project(hello_world C)

set(CMAKE_C_STANDARD 99)

add_executable(hello_world main.c)

How do I use my compiled CURL in my C project with CMake properly?

Youseflapod
  • 132
  • 1
  • 10

1 Answers1

1

I finally solved this issue by creating a cmake folder at the C: directory, and copying in the built curl CMake project folder.

The issue was that there weren't any specific tutorials that I found on how to reference projects on Windows for CMake, specifically the curl project.

Fortunately, I found this post which specified an issue I had in referencing the include folder and .lib directory separately. How to link shared library *dll with CMake in Windows

cmake_minimum_required(VERSION 3.15)
project(hello_world C)

set(CMAKE_C_STANDARD 99)

include_directories("C:/cmake/libcurl-vc-x86-release-dll-ipv6-sspi-winssl/include")
link_directories("C:/cmake/libcurl-vc-x86-release-dll-ipv6-sspi-winssl/lib")

add_executable(hello_world main.c)

set( LIBS libcurl )
target_link_libraries(hello_world ${LIBS} )

Now the code compiles and runs succesfully. I don't believe this is the proper method of doing this though, any help would be appreciated.

Youseflapod
  • 132
  • 1
  • 10