Win10 VS2017 failed on unrsolved symbols

Help!, a lots of undefined symbols

here is my build script

cd /D E:\vcmi
set http_proxy=http://127.0.0.1:4780
set https_proxy=http://127.0.0.1:4780
set LANG=en_US
set VCPKG_DISABLE_METRICS=1

git clone https://github.com/microsoft/vcpkg.git vcpkg

call vcpkg\bootstrap-vcpkg.bat

vcpkg\vcpkg.exe install sdl2:x64-windows sdl2-image:x64-windows sdl2-ttf:x64-windows sdl2-mixer:x64-windows boost:x64-windows qt5-base:x64-windows ffmpeg:x64-windows fuzzylite:x64-windows smpeg2:x64-windows minizip:x64-windows


PATH E:\vcmi\cmake-3.19.6-win64-x64\bin;%PATH%

mkdir E:\vcmi\build
cd E:\vcmi\build
cmake E:\vcmi\source -DCMAKE_TOOLCHAIN_FILE=E:/vcmi/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_CXX_FLAGS=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING -DENABLE_TEST=OFF -G "Visual Studio 15 2017 Win64"
cmake --build . --config Release

pause

here is my change

diff --git a/Global.h b/Global.h
index b651e938c..3b6ec38b9 100644
--- a/Global.h
+++ b/Global.h
@@ -204,6 +204,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #include <boost/variant.hpp>
 #include <boost/math/special_functions/round.hpp>
 #include <boost/multi_array.hpp>
+#include <boost/exception/to_string.hpp>^M

 #ifndef M_PI
 #  define M_PI 3.14159265358979323846

here comes link failures


E:\vcmi>call vcpkg\bootstrap-vcpkg.bat
Downloading https://github.com/microsoft/vcpkg-tool/releases/download/2021-02-24-d67989bce1043b98092ac45996a8230a059a2d7e/vcpkg.exe -> E:\vcmi\vcpkg\vcpkg.exe (using proxy: http://127.0.0.1:4780)
Done.

Telemetry
---------
vcpkg collects usage data in order to help us improve your experience.
The data collected by Microsoft is anonymous.
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
passing --disable-metrics to vcpkg on the command line,
or by setting the VCPKG_DISABLE_METRICS environment variable.

Read more about vcpkg telemetry at docs/about/privacy.md
Computing installation plan...
The following packages are already installed:
    boost[core]:x64-windows -> 1.75.0
    ffmpeg[avcodec,avdevice,avfilter,avformat,avresample,core,gpl,postproc,swresample,swscale]:x64-windows -> 4.3.2#7
    fuzzylite[core]:x64-windows -> 6.0#3
    minizip[core]:x64-windows -> 1.2.11#8
    qt5-base[core]:x64-windows -> 5.15.2#7
    sdl2[core]:x64-windows -> 2.0.14#4
    sdl2-image[core]:x64-windows -> 2.0.5#1
    sdl2-mixer[core,nativemidi]:x64-windows -> 2.0.4#11
    sdl2-ttf[core]:x64-windows -> 2.0.15-3
    smpeg2[core]:x64-windows -> 2.0.0-6
Package boost:x64-windows is already installed
Package ffmpeg:x64-windows is already installed
Package fuzzylite:x64-windows is already installed
Package minizip:x64-windows is already installed
Package qt5-base:x64-windows is already installed
Package sdl2:x64-windows is already installed
Package sdl2-image:x64-windows is already installed
Package sdl2-mixer:x64-windows is already installed
Package sdl2-ttf:x64-windows is already installed
Package smpeg2:x64-windows is already installed

Total elapsed time: 12.25 ms

The package minizip:x64-windows provides CMake targets:

    find_package(minizip CONFIG REQUIRED)
    target_link_libraries(main PRIVATE minizip::minizip)

The package qt5-base:x64-windows provides CMake targets:

    find_package(Qt5AccessibilitySupport CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::AccessibilitySupport Qt5::AccessibilitySupport Qt::AccessibilitySupportPrivate Qt5::AccessibilitySupportPrivate)

    find_package(Qt5Concurrent CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::Concurrent Qt5::Concurrent Qt::ConcurrentPrivate Qt5::ConcurrentPrivate)

    find_package(Qt5Core CONFIG REQUIRED)
    # Note: 2 target(s) were omitted.
    target_link_libraries(main PRIVATE Qt::Core Qt5::Core Qt::WinMain Qt5::WinMain)

    find_package(Qt5DBus CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::DBus Qt5::DBus Qt::DBusPrivate Qt5::DBusPrivate)

    find_package(Qt5DeviceDiscoverySupport CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::DeviceDiscoverySupport Qt5::DeviceDiscoverySupport Qt::DeviceDiscoverySupportPrivate Qt5::DeviceDiscoverySupportPrivate)

    find_package(Qt5EdidSupport CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::EdidSupport Qt5::EdidSupport Qt::EdidSupportPrivate Qt5::EdidSupportPrivate)

    find_package(Qt5EventDispatcherSupport CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::EventDispatcherSupport Qt5::EventDispatcherSupport Qt::EventDispatcherSupportPrivate Qt5::EventDispatcherSupportPrivate)

    find_package(Qt5FbSupport CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::FbSupport Qt5::FbSupport Qt::FbSupportPrivate Qt5::FbSupportPrivate)

    find_package(Qt5FontDatabaseSupport CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::FontDatabaseSupport Qt5::FontDatabaseSupport Qt::FontDatabaseSupportPrivate Qt5::FontDatabaseSupportPrivate)

    find_package(Qt5Gui CONFIG REQUIRED)
    # Note: 9 target(s) were omitted.
    target_link_libraries(main PRIVATE Qt::Gui Qt5::Gui Qt::GuiPrivate Qt5::GuiPrivate)

    find_package(Qt5Network CONFIG REQUIRED)
    # Note: 1 target(s) were omitted.
    target_link_libraries(main PRIVATE Qt::Network Qt5::Network Qt::NetworkPrivate Qt5::NetworkPrivate)

    find_package(Qt5OpenGL CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::OpenGL Qt5::OpenGL Qt::OpenGLPrivate Qt5::OpenGLPrivate)

    find_package(Qt5OpenGLExtensions CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::OpenGLExtensions Qt5::OpenGLExtensions Qt::OpenGLExtensionsPrivate Qt5::OpenGLExtensionsPrivate)

    find_package(Qt5PlatformCompositorSupport CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::PlatformCompositorSupport Qt5::PlatformCompositorSupport Qt::PlatformCompositorSupportPrivate Qt5::PlatformCompositorSupportPrivate)

    find_package(Qt5PrintSupport CONFIG REQUIRED)
    # Note: 1 target(s) were omitted.
    target_link_libraries(main PRIVATE Qt::PrintSupport Qt5::PrintSupport Qt::PrintSupportPrivate Qt5::PrintSupportPrivate)

    find_package(Qt5Sql CONFIG REQUIRED)
    # Note: 2 target(s) were omitted.
    target_link_libraries(main PRIVATE Qt::Sql Qt5::Sql Qt::SqlPrivate Qt5::SqlPrivate)

    find_package(Qt5Test CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::Test Qt5::Test Qt::TestPrivate Qt5::TestPrivate)

    find_package(Qt5ThemeSupport CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::ThemeSupport Qt5::ThemeSupport Qt::ThemeSupportPrivate Qt5::ThemeSupportPrivate)

    find_package(Qt5Widgets CONFIG REQUIRED)
    # Note: 1 target(s) were omitted.
    target_link_libraries(main PRIVATE Qt::Widgets Qt5::Widgets Qt::WidgetsPrivate Qt5::WidgetsPrivate)

    find_package(Qt5WindowsUIAutomationSupport CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::WindowsUIAutomationSupport Qt5::WindowsUIAutomationSupport Qt::WindowsUIAutomationSupportPrivate Qt5::WindowsUIAutomationSupportPrivate)

    find_package(Qt5Xml CONFIG REQUIRED)
    target_link_libraries(main PRIVATE Qt::Xml Qt5::Xml Qt::XmlPrivate Qt5::XmlPrivate)

The package sdl2:x64-windows provides CMake targets:

    find_package(SDL2 CONFIG REQUIRED)
    target_link_libraries(main PRIVATE SDL2::SDL2 SDL2::SDL2main)

The package sdl2-image:x64-windows provides CMake targets:

    find_package(sdl2-image CONFIG REQUIRED)
    target_link_libraries(main PRIVATE SDL2::SDL2_image)

The package sdl2-mixer:x64-windows provides CMake targets:

    find_package(sdl2-mixer CONFIG REQUIRED)
    target_link_libraries(main PRIVATE SDL2::SDL2_mixer)

The package sdl2-ttf:x64-windows provides CMake targets:

    find_package(sdl2-ttf CONFIG REQUIRED)
    target_link_libraries(main PRIVATE SDL2::SDL2_ttf)

子目录或文件 E:\vcmi\build 已经存在。
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19042.
-- -- -- Start of VCMI build debug information
-- CMAKE_VERSION: 3.19.6
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- CMAKE_BINARY_DIR: E:/vcmi/build
-- CMAKE_SOURCE_DIR: E:/vcmi/source
-- CMAKE_MODULE_PATH: E:/vcmi/source/cmake_modules
-- CMAKE_COMMAND: E:/vcmi/cmake-3.19.6-win64-x64/bin/cmake.exe
-- CMAKE_ROOT: E:/vcmi/cmake-3.19.6-win64-x64/share/cmake-3.19
-- UNIX:  - WIN32: 1 - APPLE:
-- MINGW:  - CYGWIN:  - MSVC: 1
-- CMAKE_CXX_COMPILER_ID: MSVC
-- CMAKE_CXX_COMPILER_VERSION: 19.16.27045.0
-- CMAKE_C_COMPILER: D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
-- CMAKE_CXX_COMPILER: D:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe
-- CMAKE_SYSTEM: Windows-10.0.19042
-- CMAKE_SYSTEM_NAME: Windows
-- CMAKE_SYSTEM_VERSION: 10.0.19042
-- CMAKE_SYSTEM_PROCESSOR: AMD64
-- -- -- End of VCMI build debug information
-- cotire 1.7.10 loaded.
CMake Warning (dev) at E:/vcmi/cmake-3.19.6-win64-x64/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:426 (message):
  The package name passed to `find_package_handle_standard_args` (MINIZIP)
  does not match the name of the calling package (Minizip).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake_modules/FindMinizip.cmake:70 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  E:/vcmi/vcpkg/scripts/buildsystems/vcpkg.cmake:861 (_find_package)
  CMakeLists.txt:218 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at E:/vcmi/cmake-3.19.6-win64-x64/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:426 (message):
  The package name passed to `find_package_handle_standard_args` (FL) does
  not match the name of the calling package (FuzzyLite).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake_modules/FindFuzzyLite.cmake:54 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  E:/vcmi/vcpkg/scripts/buildsystems/vcpkg.cmake:861 (_find_package)
  AI/CMakeLists.txt:12 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: E:/vcmi/build
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3
版权所有(C) Microsoft Corporation。保留所有权利。

  -- -- -- Start of Git information
  -- GIT_SHA1: b310f2e61ece1ab550614cf1b99b04830820700c
  -- -- -- End of Git information
    正在创建库 E:/vcmi/build/bin/Release/VCMI_lib.lib 和对象 E:/vcmi/build/bin/Release/VCMI_lib.exp
VCMIDirs.obj : error LNK2001: 无法解析的外部符号 "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exc
[email protected]@@[email protected]@@@Z) [E:\vcmi\build\lib\vcmi.vcxproj]
VCMI_Lib.obj : error LNK2001: 无法解析的外部符号 "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_exc
[email protected]@@[email protected]@@@Z) [E:\vcmi\build\lib\vcmi.vcxproj]
JsonDetail.obj : error LNK2001: 无法解析的外部符号 "void __cdecl boost::throw_exception(class std::exception const &)" (?throw_e
........

CZipLoader.obj : error LNK2019: 无法解析的外部符号 __imp_unzOpen2_64,该符号在函数 "public: __cdecl CZipStream::CZipStream(class std::s
hared_ptr<class CIOApi>,class boost::filesystem::path const &,struct unz64_file_pos_s)" ([email protected]@[email protected]?$shared_
[email protected]@@@[email protected]@[email protected]@[email protected]@[email protected]@@Z) 中被引用 [E:\vcmi\build\lib\vcmi.vcxproj]
CZipLoader.obj : error LNK2019: 无法解析的外部符号 __imp_unzClose,该符号在函数 "public: virtual __cdecl CZipStream::~CZipStream(void)"
 ([email protected]@[email protected]) 中被引用 [E:\vcmi\build\lib\vcmi.vcxproj]
CZipLoader.obj : error LNK2019: 无法解析的外部符号 __imp_unzGoToFirstFile,该符号在函数 "private: class std::unordered_map<class Resour
ceID,struct unz64_file_pos_s,struct std::hash<class ResourceID>,struct std::equal_to<class ResourceID>,class std::alloc
ator<struct std::pair<class ResourceID const ,struct unz64_file_pos_s> > > __cdecl CZipLoader::listFiles(class std::bas
ic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::filesystem::path const &
)" ([email protected]@@[email protected]@@[email protected]@[email protected]@@@[email protected]@U?$equal_t
[email protected]@@@[email protected][email protected][email protected][email protected]@[email protected]@@[email protected]@@[email protected]@[email protected]@[email protected]?$char_t
[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@@Z) 中被引用 [E:\vcmi\build\lib\vcmi.vcxproj]
CZipLoader.obj : error LNK2019: 无法解析的外部符号 __imp_unzGoToNextFile,该符号在函数 "private: class std::unordered_map<class Resourc
eID,struct unz64_file_pos_s,struct std::hash<class ResourceID>,struct std::equal_to<class ResourceID>,class std::alloca
tor<struct std::pair<class ResourceID const ,struct unz64_file_pos_s> > > __cdecl CZipLoader::listFiles(class std::basi
c_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::filesystem::path const &)
" ([email protected]@@[email protected]@@[email protected]@[email protected]@@@[email protected]@U?$equal_to
@[email protected]@@[email protected][email protected][email protected][email protected]@[email protected]@@[email protected]@@[email protected]@[email protected]@[email protected]?$char_tr
[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@@Z) 中被引用 [E:\vcmi\build\lib\vcmi.vcxproj]
CZipLoader.obj : error LNK2019: 无法解析的外部符号 __imp_unzLocateFile,该符号在函数 "bool __cdecl ZipArchive::extract(class boost::fil
esystem::path,class boost::filesystem::path,class std::vector<class std::basic_string<char,struct std::char_traits<char
>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class st
d::allocator<char> > > >)" ([email protected]@@[email protected]@[email protected]@[email protected][email protected]?$char_traits
@[email protected]@@[email protected]@[email protected]@[email protected]@[email protected][email protected][email protected]@[email protected]@[email protected]@[email protected]@[email protected]@@[email protected]@[email protected]@@Z)
中被引用 [E:\vcmi\build\lib\vcmi.vcxproj]
.....

I changed to prebuild-vcpkg, but I got LNK1181: unable to open E:\vcmi\vcpkg\installed\x64-windows\debug\lib\minizip.lib

E:\vcmi\build>cmake --build E:\vcmi\build --config Release
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 15.9.21+g9802d43bc3
版权所有(C) Microsoft Corporation。保留所有权利。

  -- -- -- Start of Git information
  -- GIT_SHA1: b310f2e61ece1ab550614cf1b99b04830820700c
  -- -- -- End of Git information
LINK : fatal error LNK1181: 无法打开输入文件“E:\vcmi\vcpkg\installed\x64-windows\debug\lib\minizip.lib” [E:\vcmi\build\lib\vcmi
.vcxproj]

what am I missing?

Try to build release. Or if you build vcpkg yourself do not use minizip. We have our own

Release already enabled.

And, if i keep Global.h not hacked, compile failed on undeclared to_string
error C2039: “to_string”: 不是“boost”的成员, whatever prebuild vcpkg or latest vcpkg used

If you use precompiled vcpkg it should work. It is built the same way in Travis and App Veyor. You can consult CI scripts for details. travis.yml and CI/appveyor.yml. App Veyor build using MSVC.
Just a guess. Cmake might pick some global boost installation automatically. I am not strong C++ developer so might be completely wrong idea.

Hosting provided by DigitalOcean