通过Conan/Cmake安装Poco的问题

问题描述 投票:0回答:1

我正在尝试在

Poco
Conan
的帮助下安装
Cmake
。根据
Conan
,它似乎可以下载
Poco
,但库的设置似乎丢失了。最后的步骤给我要么是无法找到/打开
PocoFoundation.lib
的错误,要么是无法找到或包含
'Poco/....
的错误。我尝试在整个系统中搜索该库,但它似乎不存在。我一直在遵循官方 Conan 指南:使用 Conan 构建一个简单的 CMake 项目。我使用的是 Windows 操作系统 (Windows 11) 和 Visual Studio 2022。

版本

PS C:\Users\madde\source\repos\Webcrawler> conan --version
Conan version 2.0.13

PS C:\Users\madde\source\repos\Webcrawler> cmake --version
cmake version 3.26.4-msvc4

文件

柯南简介:

    [settings]
    arch=x86_64
    build_type=Release
    compiler=msvc
    compiler.cppstd=17
    compiler.runtime=dynamic
    compiler.version=193
    os=Windows

CMakeLists.txt

cmake_minimum_required(VERSION 3.15)

project(Webcrawler)
find_package(Poco REQUIRED)

add_executable(${PROJECT_NAME} Webcrawler/Webcrawler.cpp)

target_link_libraries(${PROJECT_NAME} Poco::Poco)

conanfile.txt

[requires]
poco/1.12.4

[generators]
CMakeDeps
CMakeToolchain

Webcrawler\Webcrawler.cpp

#include "Poco/Net/HTTPClientSession.h"
#include "Poco/Net/HTTPRequest.h"
#include "Poco/Net/HTTPResponse.h"
#include "Poco/StreamCopier.h"
#include <iostream>
#include "WebPage.h"
int main()
{
    WebPage webpage("192.168.1.1/Index");
    webpage.download();
}

重现错误的命令

正在生成 Build 文件夹。

PS C:\Users\madde\source\repos\Webcrawler> conan install . --output-folder=build --build=missing 

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=17
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows
....
....
======== Installing packages ========
bzip2/1.0.8: Already installed! (1 of 11)
expat/2.5.0: Already installed! (2 of 11)
lz4/1.9.4: Already installed! (3 of 11)
sqlite3/3.42.0: Already installed! (4 of 11)
zlib/1.3: Already installed! (5 of 11)
zstd/1.5.5: Already installed! (6 of 11)
libpq/14.9: Already installed! (7 of 11)
pcre2/10.42: Already installed! (8 of 11)
pcre2/10.42: Appending PATH environment variable: C:\Users\madde\.conan2\p\pcre2d85e041fe43c5\p\bin
openssl/3.1.4: Already installed! (9 of 11)
libmysqlclient/8.0.31: Already installed! (10 of 11)
poco/1.12.4: Already installed! (11 of 11)
...¨
...
conanfile.txt: CMakeToolchain generated: CMakePresets.json
conanfile.txt: CMakeToolchain generated: ..\CMakeUserPresets.json
conanfile.txt: Generator 'CMakeDeps' calling 'generate()'
conanfile.txt: Generating aggregated env files
conanfile.txt: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
Install finished successfully

构建应用程序。

PS C:\Users\madde\source\repos\Webcrawler> cd .\build\
PS C:\Users\madde\source\repos\Webcrawler\build> cmake .. --preset conan-default -DCMAKE_BUILD_TYPE=Release

Preset CMake variables:

  CMAKE_POLICY_DEFAULT_CMP0091="NEW"
  CMAKE_TOOLCHAIN_FILE:FILEPATH="C:\Users\madde\source\repos\Webcrawler\build\conan_toolchain.cmake"

-- Using Conan toolchain: C:/Users/madde/source/repos/Webcrawler/build/conan_toolchain.cmake
-- Conan toolchain: C++ Standard 17 with extensions OFF
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22621.
-- The C compiler identification is MSVC 19.37.32822.0
-- The CXX compiler identification is MSVC 19.37.32822.0
....
....
-- Conan: Component target declared 'Poco::DataMySQL'
-- Conan: Component target declared 'Poco::DataPostgreSQL'
-- Conan: Component target declared 'Poco::DataSQLite'
-- Conan: Component target declared 'Poco::Encodings'
-- Conan: Component target declared 'Poco::JWT'
-- Conan: Component target declared 'Poco::MongoDB'
-- Conan: Component target declared 'Poco::Util'
-- Conan: Component target declared 'Poco::Zip'
-- Conan: Component target declared 'Poco::ActiveRecord'
-- Conan: Component target declared 'Poco::NetSSL'
-- Conan: Target declared 'Poco::Poco'
....
....
-- Conan: Component target declared 'zstd::libzstd_static'
-- Conan: Target declared 'LZ4::lz4_static'
-- Configuring done (5.5s)
-- Generating done (0.1s)
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_POLICY_DEFAULT_CMP0091


-- Build files have been written to: C:/Users/madde/source/repos/Webcrawler/build

最后一步和错误

PS C:\Users\madde\source\repos\Webcrawler\build> cmake --build .

MSBuild version 17.7.2+d6990bcfa for .NET Framework

  Checking Build System
  Building Custom Rule C:/Users/madde/source/repos/Webcrawler/CMakeLists.txt
  PWYPWebcrawler.cpp
LINK : fatal error LNK1104: cannot open file 'PocoFoundation.lib' [C:\Users\madde\source\repos\Webcrawler\build\Webcrawler.vcxproj]

在不同的版本中,我遇到了单独的错误:

PS C:\Users\madde\source\repos\Webcrawler\build>  cmake --build .
MSBuild version 17.7.2+d6990bcfa for .NET Framework

  Checking Build System
  Building Custom Rule C:/Users/madde/source/repos/Webcrawler/CMakeLists.txt
  Webcrawler.cpp
C:\Users\madde\source\repos\Webcrawler\Webcrawler\Webcrawler.cpp(6,10): fatal  error C1083: Cannot open include file: 'Poco/Net/HTTPClien
tSession.h': No such file or directory [C:\Users\madde\source\repos\Webcrawler\build\Webcrawler.vcxproj]

我看到一些帖子表明我需要在配置属性 -> 链接器 -> 输入 -> 忽略特定默认库(使用 Visual Studio 时)中添加

PocoFoundation.lib
。我已经尝试过但没有成功。

如有任何帮助,我们将不胜感激。

c++ cmake poco-libraries conan
1个回答
0
投票

看来您可以将来自 Linux/单配置系统的命令与 Windows/多配置系统混合。

Windows-Visual Studio 的正确命令是:

# Not even need to change folder, if the recipe defined ``cmake_layout``
cmake --preset conan-default 
cmake --build --preset conan-release

简而言之:

  • 对于 Visual Studio 等多配置系统,您不需要传递 -DCMAKE_BUILD_TYPE=xxxx。
  • 您最好也使用预设来构建,而不是在没有预设的情况下调用构建
© www.soinside.com 2019 - 2024. All rights reserved.