otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.59k stars 1.06k forks source link

[MSVC] Forgottenserver build failed due to fatal error LNK1181: cannot open input file 'cryptopp-static.lib' #4268

Closed Zhaojun-Liu closed 5 months ago

Zhaojun-Liu commented 1 year ago

Before creating an issue, please ensure:

Hi, recently, the MSVC team updated the commit of Forgottenserver and vcpkg for RWC testing, and it build failed due to the error about can't opening the cryptopp lib, could you please look this issue? Thanks.

Steps to reproduce (include any configuration/script required to reproduce)

  1. git clone https://github.com/otland/forgottenserver F:\gitP\otland\forgottenserver
  2. git clone https://github.com/Microsoft/vcpkg F:\gitP\Microsoft\vcpkg
  3. cd F:\gitP\Microsoft\vcpkg
  4. bootstrap-vcpkg.bat
  5. vcpkg.exe install --recurse boost-iostreams boost-asio boost-system boost-filesystem boost-variant boost-lockfree luajit libmariadb pugixml cryptopp fmt --triplet x64-windows --clean-after-build
  6. mkdir F:\gitP\otland\forgottenserver\build_amd64 & cd F:\gitP\otland\forgottenserver\build_amd64
  7. cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DCMAKE_BUILD_TYPE=Release -DMARIADB_LIBRARIES=F:/gitP/microsoft/vcpkg/installed/x64-windows/lib/libmariadb.lib -DCMAKE_TOOLCHAIN_FILE=F:\gitP\Microsoft\vcpkg\scripts\buildsystems\vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows ..
  8. msbuild /m /p:Platform=x64 /p:Configuration=Release /p:PlatformToolset=v142 tfs.sln /t:Rebuild

Expected behaviour

Build successfully。

Actual behaviour

LINK : fatal error LNK1181: cannot open input file 'cryptopp-static.lib' [F:\gitP\otland\forgottenserver\build_amd64\tfs.vcxproj]

Environment

Windows Server 2022

Reproduction environment

VS2019 (16.11.20)

More info

I tried to update the line 27 in CMakeLists.txt to be find_package(cryptopp QUIET), it will build successfully.

Zbizu commented 1 year ago

Any errors during vcpkg command? If yes, it may require updating portfile for cryptopp manually

Zhaojun-Liu commented 1 year ago

Any errors during vcpkg command? If yes, it may require updating portfile for cryptopp manually

There is no error during vcpkg command. You can check the logs configure.log

The msbuild log, you can check: build.log

Kezuino commented 1 year ago

I have observed this behavior whenever multiple compilers were installed on the same machine. Basically it could occur vcpkg preferred compiler X and the server tries to compile with compiler Y which ultimately causes the linkage error, even though it is observed to occur as well if both are forced to compile using the same compiler.

Possible solution: Remove either one of the compilers.

Zhaojun-Liu commented 1 year ago

@Kezuino According to what you said, I only kept one compiler and tried several times, and the problem reproduced steadily. My vcpkg commit is e46521d and I also tried the latest vcpkg commit, the same result. I observed that if my vcpkg commit is e46521d or later, after I executed vcpkg.exe install --recurse cryptopp --triplet x64-windows --clean-after-build, in the vcpkg\installed\x64-windows\lib folder, there will be a file named cryptopp.lib generated, but when I use a previous commit of vcpkg, like 927006b, the lib file would be cryptopp-static.lib

Codinablack commented 7 months ago

We can close this as the issue isn't with TFS, or CMake (its actually all CMake's fault), its due to Cryptopp removing support for CMake as, and I quote here: "18 percent of reported bugs were from cmake". You can find this change on their github with this commit

https://github.com/weidai11/cryptopp/commit/913a9e60d375e4581d4eca7078f0786327afa258

The community now has to work on support for cmake, they do so here : https://github.com/abdes/cryptopp-cmake

I am unsure of the exact steps to take to resolve this for those who run into this, but I would start with the above link and follow their instructions, which should hopefully resolve this for anyone who has this problem.

There is also the possibility of switching to Conan for the package manager, that would also resolve this if installed and configured correctly (cmake changes).

There is one other option to resolve this, downgrade the cryptopp version. You can do this by uninstalling through vcpkg the version you have now, and the installing the specific version, or you can force the version type using the vcpkg.json.