且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Windows上链接动态生成的cmake文件?

更新时间:2023-10-22 23:21:58

我终于解决了这个问题,方法是在C:目录中创建一个cmake文件夹,然后将其复制到内置的curl CMake项目文件夹中.

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

问题是我没有找到有关如何在Windows上为CMake引用项目的特定教程,特别是curl项目.

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.

幸运的是,我发现这篇文章指出了我在分别引用include文件夹和.lib目录时遇到的问题. 如何在Windows中将共享库* dll与CMake链接

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.