在我的C项目中,我在VSCode中将LIBCURL与CMakeLists正确链接时遇到了困难。尽管使用vcpkg成功安装了curl,但它仍然不起作用。
有人能提供在VSCode中设置CMakeLists文件以链接LIBCURL的指导吗?
任何帮助,代码片段,或例子将不胜感激。谢谢你,谢谢
以下是我的CMakeLists到目前为止的样子:
VCPKG的路径:C:/vcpkg
set(CMAKE_PREFIX_PATH "C:/vcpkg/installed/x64-windows/share")
find_package(CURL CONFIG REQUIRED)
include_directories("C:\\vcpkg\\installed\\x64-windows\\include\\")
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl)
字符串
错误:
CMake Error at C:/vcpkg/scripts/buildsystems/vcpkg.cmake:853 (_find_package):Could not find a configuration file for package "CURL" that is compatible
with requested version "".
The following configuration files were considered but not accepted:
C:/vcpkg/installed/x64-windows/share/curl/CURLConfig.cmake, version: 8.1.2-DEV (64bit)
型
1条答案
按热度按时间bnlyeluc1#
正如评论中所说:你可能是混合x86和x64。虽然你的vcpkg安装了x64库,但你的cmake项目却被设置为x86。如果使用例如,可能会发生这种情况。VS 2019或更低版本生成器或您明确请求x86。
其次请阅读vcpkg手册如何正确使用vcpkg。手动设置
CMAKE_PREFIX_PATH
或向include_directories
添加硬编码的vcpkg路径不是正确的方法。