Poco C++ 与柯南依赖管理器的链接问题,我该如何解决?

Poco C++ Linking issues with conan dependency manager, how would I fix it?

我一直在尝试在我的编程项目中使用 Poco 库,但出现链接错误。我的 C++ 文件在 main 函数中只有一行代码,应该可以正常编译。

我的 C++ 文件:

/**
 * Created by kkprince on 27/06/16.
 */

#include <Poco/AutoPtr.h>
#include <Poco/Util/IniFileConfiguration.h>

using Poco::AutoPtr;
using Poco::Util::IniFileConfiguration;

int main(int argc, char* argv[]){
    AutoPtr<IniFileConfiguration> pConf(new IniFileConfiguration("invalid"));
}

我的 CMakeLists:

cmake_minimum_required(VERSION 3.5)
project(village.io-server CXX)

include(conanbuildinfo.cmake)
conan_basic_setup()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "/home/kkprince/ClionProjects/village.io/build")
set(CMAKE_BINARY_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})

find_package(Boost
        COMPONENTS program_options system REQUIRED)

set(SOURCE_FILES main.cpp) # src/Runner.cpp src/Runner.h src/workQueue/workQueue.h src/server/Server.cpp src/server/Server.h)
add_executable(village.io-server ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(village.io-server ${Boost_LIBRARIES} ${CONAN_LIBS})

还有我的conanfile.txt:

[requires]
Poco/1.7.3@lasote/stable
easyloggingpp/9.80@memsharded/testing

[options]
Poco:shared=False

[generators]
cmake

我生成的 conaninfo.txt:

[settings]
    arch=x86_64
    build_type=Release
    compiler=gcc
    compiler.libcxx=libstdc++
    compiler.version=5.3
    os=Linux

[requires]
    Poco/1.Y.Z
    easyloggingpp/9.Y.Z

[options]


[full_settings]
    arch=x86_64
    build_type=Release
    compiler=gcc
    compiler.libcxx=libstdc++
    compiler.version=5.3
    os=Linux

[full_requires]
    OpenSSL/1.0.2g@lasote/stable:c9485444fc54028aa59ea9eb50adf168f08452e3
    Poco/1.7.3@lasote/stable:cfe3c3d40d613222d431d274eb053831f72a9116
    easyloggingpp/9.80@memsharded/testing:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    electric-fence/2.2.0@lasote/stable:52bcde7d26fabb9754f2f3b850001579b1098686
    zlib/1.2.8@lasote/stable:52bcde7d26fabb9754f2f3b850001579b1098686

[full_options]
    OpenSSL:386=False
    OpenSSL:no_asm=False
    OpenSSL:no_bf=False
    OpenSSL:no_cast=False
    OpenSSL:no_des=False
    OpenSSL:no_dh=False
    OpenSSL:no_dsa=False
    OpenSSL:no_electric_fence=False
    OpenSSL:no_hmac=False
    OpenSSL:no_md2=False
    OpenSSL:no_md5=False
    OpenSSL:no_mdc2=False
    OpenSSL:no_rc2=False
    OpenSSL:no_rc4=False
    OpenSSL:no_rc5=False
    OpenSSL:no_rsa=False
    OpenSSL:no_sha=False
    OpenSSL:no_sse2=False
    OpenSSL:no_threads=False
    OpenSSL:no_zlib=False
    OpenSSL:shared=False
    OpenSSL:zlib_dynamic=False
    Poco:enable_apacheconnector=False
    Poco:enable_cppparser=False
    Poco:enable_crypto=True
    Poco:enable_data=True
    Poco:enable_data_mysql=False
    Poco:enable_data_odbc=False
    Poco:enable_data_sqlite=True
    Poco:enable_json=True
    Poco:enable_mongodb=True
    Poco:enable_net=True
    Poco:enable_netssl=True
    Poco:enable_netssl_win=True
    Poco:enable_pagecompiler=False
    Poco:enable_pagecompiler_file2page=False
    Poco:enable_pdf=False
    Poco:enable_pocodoc=False
    Poco:enable_sevenzip=False
    Poco:enable_tests=False
    Poco:enable_util=True
    Poco:enable_xml=True
    Poco:enable_zip=True
    Poco:force_openssl=True
    Poco:poco_unbundled=False
    Poco:shared=False
    electric-fence:shared=False
    zlib:shared=False

现在,我用 rm -Rfv build conan{b,i}* && conan install . && mkdir build && cd build && cmake .. && cmake --build . -- VERBOSE=1; cd ..:

构建它
removed 'build/Makefile'
removed 'build/CMakeCache.txt'
removed 'build/cmake_install.cmake'
removed 'build/CMakeFiles/Makefile2'
removed directory 'build/CMakeFiles/CMakeTmp'
removed 'build/CMakeFiles/TargetDirectories.txt'
removed 'build/CMakeFiles/CMakeOutput.log'
removed 'build/CMakeFiles/progress.marks'
removed 'build/CMakeFiles/Makefile.cmake'
removed 'build/CMakeFiles/Progress/1'
removed 'build/CMakeFiles/Progress/count.txt'
removed 'build/CMakeFiles/Progress/2'
removed directory 'build/CMakeFiles/Progress'
removed 'build/CMakeFiles/feature_tests.bin'
removed 'build/CMakeFiles/CMakeDirectoryInformation.cmake'
removed 'build/CMakeFiles/cmake.check_cache'
removed 'build/CMakeFiles/feature_tests.cxx'
removed 'build/CMakeFiles/3.5.1/CMakeSystem.cmake'
removed 'build/CMakeFiles/3.5.1/CMakeCXXCompiler.cmake'
removed 'build/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin'
removed 'build/CMakeFiles/3.5.1/CompilerIdCXX/a.out'
removed 'build/CMakeFiles/3.5.1/CompilerIdCXX/CMakeCXXCompilerId.cpp'
removed directory 'build/CMakeFiles/3.5.1/CompilerIdCXX'
removed directory 'build/CMakeFiles/3.5.1'
removed 'build/CMakeFiles/village.io-server.dir/depend.internal'
removed 'build/CMakeFiles/village.io-server.dir/cmake_clean.cmake'
removed 'build/CMakeFiles/village.io-server.dir/CXX.includecache'
removed 'build/CMakeFiles/village.io-server.dir/progress.make'
removed 'build/CMakeFiles/village.io-server.dir/depend.make'
removed 'build/CMakeFiles/village.io-server.dir/link.txt'
removed 'build/CMakeFiles/village.io-server.dir/flags.make'
removed 'build/CMakeFiles/village.io-server.dir/main.cpp.o'
removed 'build/CMakeFiles/village.io-server.dir/build.make'
removed 'build/CMakeFiles/village.io-server.dir/DependInfo.cmake'
removed directory 'build/CMakeFiles/village.io-server.dir'
removed directory 'build/CMakeFiles'
removed directory 'build'
removed 'conanbuildinfo.cmake'
removed 'conaninfo.txt'
Requirements
    OpenSSL/1.0.2g@lasote/stable from conan.io
    Poco/1.7.3@lasote/stable from conan.io
    easyloggingpp/9.80@memsharded/testing from conan.io
    electric-fence/2.2.0@lasote/stable from conan.io
    zlib/1.2.8@lasote/stable from conan.io
Packages
    OpenSSL/1.0.2g@lasote/stable:c9485444fc54028aa59ea9eb50adf168f08452e3
    Poco/1.7.3@lasote/stable:cfe3c3d40d613222d431d274eb053831f72a9116
    easyloggingpp/9.80@memsharded/testing:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    electric-fence/2.2.0@lasote/stable:52bcde7d26fabb9754f2f3b850001579b1098686
    zlib/1.2.8@lasote/stable:52bcde7d26fabb9754f2f3b850001579b1098686

easyloggingpp/9.80@memsharded/testing: Already installed!
electric-fence/2.2.0@lasote/stable: Already installed!
zlib/1.2.8@lasote/stable: Already installed!
OpenSSL/1.0.2g@lasote/stable: Already installed!
Poco/1.7.3@lasote/stable: Already installed!
PROJECT: Generated conaninfo.txt
PROJECT: Generated cmake created conanbuildinfo.cmake
-- The CXX compiler identification is GNU 5.3.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Current conanbuildinfo.cmake directory: /home/kkprince/ClionProjects/village.io/server
-- Configuring done
-- Generating done
-- Build files have been written to: /home/kkprince/ClionProjects/village.io/server/build
/usr/bin/cmake -H/home/kkprince/ClionProjects/village.io/server -B/home/kkprince/ClionProjects/village.io/server/build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/kkprince/ClionProjects/village.io/server/build/CMakeFiles /home/kkprince/ClionProjects/village.io/server/build/CMakeFiles/progress.marks
/usr/bin/make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/kkprince/ClionProjects/village.io/server/build'
/usr/bin/make -f CMakeFiles/village.io-server.dir/build.make CMakeFiles/village.io-server.dir/depend
make[2]: Entering directory '/home/kkprince/ClionProjects/village.io/server/build'
cd /home/kkprince/ClionProjects/village.io/server/build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/kkprince/ClionProjects/village.io/server /home/kkprince/ClionProjects/village.io/server /home/kkprince/ClionProjects/village.io/server/build /home/kkprince/ClionProjects/village.io/server/build /home/kkprince/ClionProjects/village.io/server/build/CMakeFiles/village.io-server.dir/DependInfo.cmake --color=
Dependee "/home/kkprince/ClionProjects/village.io/server/build/CMakeFiles/village.io-server.dir/DependInfo.cmake" is newer than depender "/home/kkprince/ClionProjects/village.io/server/build/CMakeFiles/village.io-server.dir/depend.internal".
Dependee "/home/kkprince/ClionProjects/village.io/server/build/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/kkprince/ClionProjects/village.io/server/build/CMakeFiles/village.io-server.dir/depend.internal".
Scanning dependencies of target village.io-server
make[2]: Leaving directory '/home/kkprince/ClionProjects/village.io/server/build'
/usr/bin/make -f CMakeFiles/village.io-server.dir/build.make CMakeFiles/village.io-server.dir/build
make[2]: Entering directory '/home/kkprince/ClionProjects/village.io/server/build'
[ 50%] Building CXX object CMakeFiles/village.io-server.dir/main.cpp.o
/usr/bin/c++   -DPOCO_NO_AUTOMATIC_LIBS -DPOCO_STATIC=ON -isystem /home/kkprince/.conan/data/Poco/1.7.3/lasote/stable/package/cfe3c3d40d613222d431d274eb053831f72a9116/include -isystem /home/kkprince/.conan/data/easyloggingpp/9.80/memsharded/testing/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/include -isystem /home/kkprince/.conan/data/OpenSSL/1.0.2g/lasote/stable/package/c9485444fc54028aa59ea9eb50adf168f08452e3/include -isystem /home/kkprince/.conan/data/electric-fence/2.2.0/lasote/stable/package/52bcde7d26fabb9754f2f3b850001579b1098686/include -isystem /home/kkprince/.conan/data/zlib/1.2.8/lasote/stable/package/52bcde7d26fabb9754f2f3b850001579b1098686/include   -o CMakeFiles/village.io-server.dir/main.cpp.o -c /home/kkprince/ClionProjects/village.io/server/main.cpp
[100%] Linking CXX executable /home/kkprince/ClionProjects/village.io/build/village.io-server
/usr/bin/cmake -E cmake_link_script CMakeFiles/village.io-server.dir/link.txt --verbose=1
/usr/bin/c++          CMakeFiles/village.io-server.dir/main.cpp.o  -o /home/kkprince/ClionProjects/village.io/build/village.io-server  -L/home/kkprince/.conan/data/Poco/1.7.3/lasote/stable/package/cfe3c3d40d613222d431d274eb053831f72a9116/lib  -L/home/kkprince/.conan/data/easyloggingpp/9.80/memsharded/testing/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/lib  -L/home/kkprince/.conan/data/OpenSSL/1.0.2g/lasote/stable/package/c9485444fc54028aa59ea9eb50adf168f08452e3/lib  -L/home/kkprince/.conan/data/electric-fence/2.2.0/lasote/stable/package/52bcde7d26fabb9754f2f3b850001579b1098686/lib  -L/home/kkprince/.conan/data/zlib/1.2.8/lasote/stable/package/52bcde7d26fabb9754f2f3b850001579b1098686/lib -lPocoUtil -lPocoMongoDB -lPocoNet -lPocoNetSSL -lPocoCrypto -lPocoData -lPocoDataSQLite -lPocoUtil -lPocoZip -lPocoXML -lPocoJSON -lPocoFoundation -lrt -lssl -lcrypto -ldl -lefence -lpthread -lz -lPocoMongoDB -lPocoNet -lPocoNetSSL -lPocoCrypto -lPocoData -lPocoDataSQLite -lPocoZip -lPocoXML -lPocoJSON -lPocoFoundation -lrt -lssl -lcrypto -ldl -lefence -lpthread -lz -Wl,-rpath,/home/kkprince/.conan/data/Poco/1.7.3/lasote/stable/package/cfe3c3d40d613222d431d274eb053831f72a9116/lib:/home/kkprince/.conan/data/easyloggingpp/9.80/memsharded/testing/package/5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9/lib:/home/kkprince/.conan/data/OpenSSL/1.0.2g/lasote/stable/package/c9485444fc54028aa59ea9eb50adf168f08452e3/lib:/home/kkprince/.conan/data/electric-fence/2.2.0/lasote/stable/package/52bcde7d26fabb9754f2f3b850001579b1098686/lib:/home/kkprince/.conan/data/zlib/1.2.8/lasote/stable/package/52bcde7d26fabb9754f2f3b850001579b1098686/lib 
CMakeFiles/village.io-server.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x5a): undefined reference to `Poco::Util::IniFileConfiguration::IniFileConfiguration(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
CMakeFiles/village.io-server.dir/build.make:94: recipe for target '/home/kkprince/ClionProjects/village.io/build/village.io-server' failed
make[2]: *** [/home/kkprince/ClionProjects/village.io/build/village.io-server] Error 1
make[2]: Leaving directory '/home/kkprince/ClionProjects/village.io/server/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/village.io-server.dir/all' failed
make[1]: *** [CMakeFiles/village.io-server.dir/all] Error 2
make[1]: Leaving directory '/home/kkprince/ClionProjects/village.io/server/build'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

我是不是编译错了,或者我该如何让它工作?

POCO 包和安装的 libstdc++ 编译器之间似乎存在 libstdc++ ABI 不兼容问题

1) 如果您使用的是默认为 libstdc++ 的 linux 发行版(例如 Ubuntu 14.04),那么您需要使用该版本的软件包。安装包为:

$ conan install -s compiler=gcc -s compiler.version=5.3 -s compiler.libcxx=libstdc++ --build=missing

2) 如果您使用的是默认为 libstdc++11 的 linux 发行版(例如 Ubuntu 16.04),那么您需要使用该版本的软件包。安装包为:

$ conan install -s compiler=gcc -s compiler.version=5.3 -s compiler.libcxx=libstdc++11 --build=missing

这将从与匹配的 libstdc++ 链接的源(可能需要一段时间)构建包,前提是二进制包不存在 --build=missing

所要求的

提示:您可以在 ~/.conan/conan.conf 文件中更改 compiler.libcxx 的默认值。

您可能还想使用柯南的 Boost 包。为您的 conanfile.txt

增光添彩
[requires]
Boost/1.60.0@lasote/stable
Poco/1.7.3@lasote/stable
easyloggingpp/9.80@memsharded/testing

find_package 应该继续工作,找到 Boost 包而不是你安装的包。