在cmake中设置curl库路径

 W蓝尾蝶SUH_435 发布于 2022-12-13 18:13

我下载了"curl library"以用于第三方应用程序.当我运行包含的cmake文件时,我收到以下错误.请帮我.我很感激:

> The C compiler identification is MSVC 18.0.30501.0
    >     The CXX compiler identification is MSVC 18.0.30501.0
    >     Check for working C compiler using: Visual Studio 12 2013
    >     Check for working C compiler using: Visual Studio 12 2013 -- works
    >     Detecting C compiler ABI info
    >     Detecting C compiler ABI info - done
    >     Check for working CXX compiler using: Visual Studio 12 2013
    >     Check for working CXX compiler using: Visual Studio 12 2013 -- works
    >     Detecting CXX compiler ABI info
    >     Detecting CXX compiler ABI info - done
    >     Could NOT find CURL (missing:  CURL_LIBRARY) (found version "7.38.0")
    >     CMake Error at CMakeLists.txt:49 (MESSAGE):
    >       Could not find the CURL library and development files.  
    >     
    >     Configuring incomplete, errors occurred!
    >     See also "C:/BUILD/CMakeFiles/CMakeOutput.log".

我在Windows中为"CURL_LIBRARY"设置环境变量以指向curl的库文件安装位置,但是即使cxke指示在我的系统上检测到版本7.38.0,它仍然无法找到它.

谢谢您的帮助..

编辑:cMakeLists.txt文件

  ...
# Look for required libraries
SET(requiredlibs)

FIND_PACKAGE(CURL)
IF(CURL_FOUND)
  INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR})
  SET(requiredlibs ${requiredlibs} ${CURL_LIBRARIES} )
ELSE(CURL_FOUND)
  MESSAGE(FATAL_ERROR "Could not find the CURL library and development files.")
ENDIF(CURL_FOUND)
   ...

我在Windows环境变量中设置了include和lib目录,但没有变化.

编辑:这是完整的项目文件:cmake项目.

1 个回答
  • 我遇到了同样的问题,这个问题在我的搜索过程中是最重要的问题之一.所以我给出了我找到的解决方案.以下cmake让我在我的代码中使用libcurl include.希望它对某人有用.

    set(CURL_LIBRARY "-lcurl") 
    find_package(CURL REQUIRED) 
    add_executable (curl-demo convert.cpp)
    include_directories(${CURL_INCLUDE_DIR})
    target_link_libraries(curl-demo ${CURL_LIBRARIES})
    

    2022-12-13 18:15 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有