Я пытаюсь использовать boost :: asio через cmake и vcpkg в моем проекте, и каждый раз, когда я касаюсь чего-то, связанного с date_time (даже неявно), я получаю некоторые ошибки связывания с григорианским календарем. Кто-то знает, почему это не ссылки? Я новичок в CMake & vcpkg.
Хост-окружение
- ОС: Windows 10
- Компилятор: MSVC ++ 14.23
Воспроизвести
./vcpkg install Boost
cd $MyProjectDir
mkdir build
cd build
cmake -G "Visual Studio 16 2019" -A x64 ..
cmake --build .
проблематично c C ++ код
#include <boost/asio.hpp>
int main() {
boost::asio::io_service service;
//boost::asio::deadline_timer timer(service); // this one causes error
}
Мой CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
set(CMAKE_TOOLCHAIN_FILE "C:/Repos/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
project(Backend)
find_package(Boost REQUIRED)
add_executable(Backend
"source/main.cpp"
)
target_link_libraries(Backend PRIVATE ${Boost_LIBRARIES})
target_include_directories(Backend PRIVATE ${Boost_INCLUDE_DIRS})
Журналы сбоев
2>------ Build started: Project: Backend, Configuration: Debug x64 ------
2>Building Custom Rule C:/Repos/fridge/backend/CMakeLists.txt
2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl boost::gregorian::greg_month::greg_month(unsigned short)" (__imp_??0greg_month@gregorian@boost@@QEAA@G@Z) referenced in function "public: __cdecl boost::gregorian::date::date(enum boost::date_time::special_values)" (??0date@gregorian@boost@@QEAA@W4special_values@date_time@2@@Z)
2>main.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl boost::gregorian::greg_month::operator unsigned short(void)const " (__imp_??Bgreg_month@gregorian@boost@@QEBAGXZ) referenced in function "public: static unsigned int __cdecl boost::date_time::gregorian_calendar_base<struct boost::date_time::year_month_day_base<class boost::gregorian::greg_year,class boost::gregorian::greg_month,class boost::gregorian::greg_day>,unsigned int>::day_number(struct boost::date_time::year_month_day_base<class boost::gregorian::greg_year,class boost::gregorian::greg_month,class boost::gregorian::greg_day> const &)" (?day_number@?$gregorian_calendar_base@U?$year_month_day_base@Vgreg_year@gregorian@boost@@Vgreg_month@23@Vgreg_day@23@@date_time@boost@@I@date_time@boost@@SAIAEBU?$year_month_day_base@Vgreg_year@gregorian@boost@@Vgreg_month@23@Vgreg_day@23@@23@@Z)
2>C:\Repos\fridge\backend\build\Debug\Backend.exe : fatal error LNK1120: 2 unresolved externals
2>Done building project "Backend.vcxproj" -- FAILED.