I am trying to install Poco
with the help of Conan
and Cmake
. According to Conan
it seems to be able to download Poco
, but the setup of the libraries seems to be missing. The final steps gives me either the error that PocoFoundation.lib
cannot be found/open, or the error that it cannot find or include 'Poco/....
. I have tried searching for the library in my entire system, but it does not seem to exist. I have been following the official Conan guide: Build a simple CMake project using Conan. I am using Windows OS (windows 11) and Visual Studio 2022.
Versions
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
Files
Conan profile:
[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();
}
Commands to reproduce error
Generating Build folder.
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
Building the App.
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
Final step and error
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]
In a different build, i got a seperat error:
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]
I have seen some posts which indicates that i need to add PocoFoundation.lib
in Configuration properties -> Linker -> Input -> Ignore Specific Default Libraries (when using visual studio). I have tried this with no success.
Any help would be appreciated.
It seems you could be mixing commands from Linux/single-config systems with Windows/multi-config systems.
The right commands for Windows-Visual Studio would be:
# Not even need to change folder, if the recipe defined ``cmake_layout``
cmake --preset conan-default
cmake --build --preset conan-release
In short: