xmake-io / xmake-repo

📦 An official xmake package repository
https://xrepo.xmake.io
Apache License 2.0
685 stars 396 forks source link

gamenetworkingsockets fails to build (likely related to #3667 ) #3710

Open RobbeBryssinck opened 6 months ago

RobbeBryssinck commented 6 months ago

Xmake Version

2.8.9

Operating System Version and Architecture

Windows 11, Ubuntu 22.04

Describe Bug

Linking to protobuf-cpp fails.

I am guessing it is related to the C++ version not being set correctly (protobuf or abseil using C++11 causing strings compilation to fail). Seems there are other packages like grpc that are running into similar issues ( #3705 ).

Sometimes, compilation seems to continue, only for it to later fail as the protobuf files are not present, resulting in errors such as the following:

error: @programdir\core\main.lua:329: @programdir\actions\build\main.lua:148: @programdir\modules\async\runjobs.lua:338: @programdir\modules\private\action\build\object.lua:91: @programdir\modules\core\tools\cl.lua:716: steamnetworkingsockets_stun.cpp
C:\Users\pc\AppData\Local\Temp\.xmake\240406.dir\src\steamnetworkingsockets\clientlib\../steamnetworkingsockets_internal.h(27): fatal error C1083: Cannot open include file: 'steamnetworkingsockets_messages_certs.pb.h': No such file or directory

Expected Behavior

protobuf and/or its dependencies should use the correct C++ version to compile.

Project Configuration

The latest version of gamenetworkingsockets is used (v1.4.1).

Additional Information and Error Logs

error: libprotobuf.lib(generated_message_tctable_lite.obj) : error LNK2019: unresolved external symbol "bool __cdecl utf8_range::IsStructurallyValid(class absl::lts_20240116::string_view)" (?IsStructurallyValid@utf8_range@@YA_NVstring_view@lts_20240116@absl@@@Z) referenced in function "public: static char const * __cdecl google::protobuf::internal::TcParser::FastUR1(class google::protobuf::MessageLite *,char const *,class google::protobuf::internal::ParseContext *,struct google::protobuf::internal::TcFieldData,struct google::protobuf::internal::TcParseTableBase const *,unsigned __int64)" (?FastUR1@TcParser@internal@protobuf@google@@SAPEBDPEAVMessageLite@34@PEBDPEAVParseContext@234@UTcFieldData@234@PEBUTcParseTableBase@234@_K@Z)
libprotobuf.lib(wire_format_lite.obj) : error LNK2001: unresolved external symbol "bool __cdecl utf8_range::IsStructurallyValid(class absl::lts_20240116::string_view)" (?IsStructurallyValid@utf8_range@@YA_NVstring_view@lts_20240116@absl@@@Z)
libprotobuf.lib(parse_context.obj) : error LNK2001: unresolved external symbol "bool __cdecl utf8_range::IsStructurallyValid(class absl::lts_20240116::string_view)" (?IsStructurallyValid@utf8_range@@YA_NVstring_view@lts_20240116@absl@@@Z)
libprotobuf.lib(text_format.obj) : error LNK2019: unresolved external symbol "unsigned __int64 __cdecl utf8_range::SpanStructurallyValid(class absl::lts_20240116::string_view)" (?SpanStructurallyValid@utf8_range@@YA_KVstring_view@lts_20240116@absl@@@Z) referenced in function "private: static void __cdecl google::protobuf::TextFormat::Printer::HardenedPrintString(class absl::lts_20240116::string_view,class google::protobuf::TextFormat::BaseTextGenerator *)" (?HardenedPrintString@Printer@TextFormat@protobuf@google@@CAXVstring_view@lts_20240116@absl@@PEAVBaseTextGenerator@234@@Z)
waruqi commented 6 months ago

try this patch. https://github.com/xmake-io/xmake-repo/pull/3706

RobbeBryssinck commented 6 months ago

try this patch. #3706

Isn't this already in the "main repo"? As in, if I were to clean my repository cache, run xrepo update-repo, and then build again, shouldn't it build already with that patch? Because I tried that already.

c8ef commented 6 months ago

Could you please provide a minimal reproduction that will help us pinpoint the root cause? This will assist in narrowing down the issue more effectively.

RobbeBryssinck commented 6 months ago

The issue can be reproduced by adding the gamenetworkingsockets to a sample project (like, say, this one: https://github.com/xmake-io/xmake/tree/master/tests/projects/c%2B%2B/console). I modified the xmake.lua file of this project to look like this:

add_rules("mode.debug", "mode.release")
add_requires("gamenetworkingsockets")
target("test")
    set_kind("binary")
    add_files("src/*.cpp")
    add_deps("gamenetworkingsockets")
waruqi commented 6 months ago

try

xrepo update-repo
xrepo remove --all abseil
xmake f -cvD
RobbeBryssinck commented 6 months ago

This produces a long list of compilation errors that boils down to string_view not being able to compile:

...

[ 15%]: compiling.proto.release build_7c0aa346\.gens\gns\windows\x64\release\rules\protobuf\src\common\steamnetworkingsockets_messages_certs.pb.cc
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\bin\HostX64\x64\cl.exe -c -nologo -O2 -fp:fast -MT -Iinclude -Isrc -Isrc\common -Isrc\tier0 -Isrc\tier1 -Isrc\vstdlib -Isrc\steamnetworkingsockets -Isrc\steamnetworkingsockets\clientlib -Isrc\public -DWIN32 -D_WINDOWS -DSTEAMNETWORKINGSOCKETS_STATIC_LINK -DOPENSSL_USE_STATIC_LIBS -DSTEAMNETWORKINGSOCKETS_CRYPTO_25519_OPENSSL -DSTEAMNETWORKINGSOCKETS_CRYPTO_VALVEOPENSSL -DOPENSSL_HAS_25519_RAW -DVALVE_CRYPTO_ENABLE_25519 -DGOOGLE_PROTOBUF_NO_RTTI -DVALVE_CRYPTO_25519_OPENSSL -DCRYPTO_DISABLE_ENCRYPT_WITH_PASSWORD -DENABLE_OPENSSLCONNECTION /EHsc -external:W0 -external:IC:\Users\pc\AppData\Local\.xmake\packages\p\protobuf-cpp\26.1\6ffa349d1b5f4047a086e95e2d5e70ed\include -external:W0 -external:IC:\Users\pc\AppData\Local\.xmake\packages\a\abseil\20240116.1\f1d1419501d24c1cbe78f072955b1d15\include -external:W0 -external:IC:\Users\pc\AppData\Local\.xmake\packages\o\openssl\1.1.1-w\61d86fc2f8cc4e60a5bef5bc478c3a92\include -DNDEBUG -Ibuild_7c0aa346\.gens\gns\windows\x64\release\rules\protobuf\src\common -Fobuild_7c0aa346\.objs\gns\windows\x64\release\gens\rules\protobuf\src\common\steamnetworkingsockets_messages_certs.pb.cc.obj build_7c0aa346\.gens\gns\windows\x64\release\rules\protobuf\src\common\steamnetworkingsockets_messages_certs.pb.cc
steamnetworkingsockets_messages_certs.pb.cc
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\string_view(12): warning STL4038: The contents of <string_view> are available only with C++17 or later.
C:\Users\pc\AppData\Local\.xmake\packages\a\abseil\20240116.1\f1d1419501d24c1cbe78f072955b1d15\include\absl/strings/string_view.h(53): error C2039: 'string_view': is not a member of 'std'
...
waruqi commented 6 months ago

please add set_languages("c++17") ,

https://github.com/xmake-io/xmake-repo/issues/3705#issuecomment-2041039294

waruqi commented 6 months ago

or add_requireconfs("**.abseil", {configs = {cxx_standard = "14"}})

RobbeBryssinck commented 6 months ago

I'm assuming these configuration options would be added in my project's configuration, and not the gamenetworkingsockets package configuration? These options don't work, even if cxx_standard is set to "17". I get the same compilation errors.

waruqi commented 6 months ago

add to your gamenetworkingsockets package's project xmake.lua