Я впервые использую vcpkg с amqp cpp. Я тестирую его с помощью cmake, чтобы получить настройки проекта с использованием библиотеки. vcpkg устанавливает пакет правильно, и cmake без проблем находит цель amqpcpp
. Существует некоторая проблема с компоновщиком, которую я не могу решить. Ниже мой CMakeLists.txt.
cmake_minimum_required(VERSION 3.15)
set(VCPKG_TARGET_TRIPLET x86-windows )
set(CMAKE_TOOLCHAIN_FILE "C:/Users/reine/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
project(amqp_test)
set(CMAKE_CXX_STANDARD 11)
find_package(amqpcpp CONFIG REQUIRED)
include_directories(${amqpcpp_INCLUDE_DIR})
add_executable(amqp_test main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE amqpcpp)
И ниже - ошибка компоновщика, с которой я столкнулся. ConnectionImpl
действительно существует. Почему имена файлов такие сумасшедшие? Я полагаю, что это сделано для предотвращения двойной ссылки на объект. Я думаю, что это где моя проблема.
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: CMakeFiles\amqp_test.dir/objects.a(main.cpp.obj): in function `ZN4AMQP10ConnectionD1Ev':
C:/Users/reine/vcpkg/installed/x86-windows/include/amqpcpp/connection.h:70: undefined reference to `AMQP::ConnectionImpl::~ConnectionImpl()'
Я провел тщательную проверку этого типа ошибок компоновщика и полностью застрял.
Подробный вывод данных
Clean finished
====================[ Build | all | Debug ]=====================================
"C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" --build C:\Users\reine\CLionProjects\amqp-test\cmake-build-debug --target all -- -j 4
"C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" -SC:\Users\reine\CLionProjects\amqp-test -BC:\Users\reine\CLionProjects\amqp-test\cmake-build-debug --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" -E cmake_progress_start C:\Users\reine\CLionProjects\amqp-test\cmake-build-debug\CMakeFiles C:\Users\reine\CLionProjects\amqp-test\cmake-build-debug\CMakeFiles\progress.marks
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\Makefile2 all
mingw32-make.exe[1]: Entering directory 'C:/Users/reine/CLionProjects/amqp-test/cmake-build-debug'
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\amqp_test.dir\build.make CMakeFiles/amqp_test.dir/depend
mingw32-make.exe[2]: Entering directory 'C:/Users/reine/CLionProjects/amqp-test/cmake-build-debug'
"C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\reine\CLionProjects\amqp-test C:\Users\reine\CLionProjects\amqp-test C:\Users\reine\CLionProjects\amqp-test\cmake-build-debug C:\Users\reine\CLionProjects\amqp-test\cmake-build-debug C:\Users\reine\CLionProjects\amqp-test\cmake-build-debug\CMakeFiles\amqp_test.dir\DependInfo.cmake --color=
mingw32-make.exe[2]: Leaving directory 'C:/Users/reine/CLionProjects/amqp-test/cmake-build-debug'
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\amqp_test.dir\build.make CMakeFiles/amqp_test.dir/build
mingw32-make.exe[2]: Entering directory 'C:/Users/reine/CLionProjects/amqp-test/cmake-build-debug'
[ 50%] Building CXX object CMakeFiles/amqp_test.dir/main.cpp.obj
C:\MinGW\bin\g++.exe @CMakeFiles/amqp_test.dir/includes_CXX.rsp -g -std=gnu++11 -o CMakeFiles\amqp_test.dir\main.cpp.obj -c C:\Users\reine\CLionProjects\amqp-test\main.cpp
[100%] Linking CXX executable amqp_test.exe
"C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" -E cmake_link_script CMakeFiles\amqp_test.dir\link.txt --verbose=1
"C:\Program Files\JetBrains\CLion 2019.2.5\bin\cmake\win\bin\cmake.exe" -E remove -f CMakeFiles\amqp_test.dir/objects.a
C:\MinGW\bin\ar.exe cr CMakeFiles\amqp_test.dir/objects.a @CMakeFiles\amqp_test.dir\objects1.rsp
C:\MinGW\bin\g++.exe -g -Wl,--whole-archive CMakeFiles\amqp_test.dir/objects.a -Wl,--no-whole-archive -o amqp_test.exe -Wl,--out-implib,libamqp_test.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFiles\amqp_test.dir\linklibs.rsp
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: CMakeFiles\amqp_test.dir/objects.a(main.cpp.obj): in function `ZN4AMQP10ConnectionC1EPNS_17ConnectionHandlerERKNS_5LoginERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE':
C:/Users/reine/vcpkg/installed/x86-windows/include/amqpcpp/connection.h:40: undefined reference to `AMQP::ConnectionImpl::ConnectionImpl(AMQP::Connection*, AMQP::ConnectionHandler*, AMQP::Login const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
c:/mingw/bin/../lib/gcc/mingw32/8.2.0/../../../../mingw32/bin/ld.exe: CMakeFiles\amqp_test.dir/objects.a(main.cpp.obj): in function `ZN4AMQP10ConnectionD1Ev':
C:/Users/reine/vcpkg/installed/x86-windows/include/amqpcpp/connection.h:70: undefined reference to `AMQP::ConnectionImpl::~ConnectionImpl()'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\amqp_test.dir\build.make:89: recipe for target 'amqp_test.exe' failed
mingw32-make.exe[2]: Leaving directory 'C:/Users/reine/CLionProjects/amqp-test/cmake-build-debug'
mingw32-make.exe[2]: *** [amqp_test.exe] Error 1
mingw32-make.exe[1]: *** [CMakeFiles/amqp_test.dir/all] Error 2
CMakeFiles\Makefile2:77: recipe for target 'CMakeFiles/amqp_test.dir/all' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/reine/CLionProjects/amqp-test/cmake-build-debug'
Makefile:85: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2