xmake-io / xmake-repo

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

[Protobuf-Cpp] Can't execute programs using protobuf-cpp with certain setups #3677

Closed SFGrenade closed 4 months ago

SFGrenade commented 5 months ago

Xmake Version

v2.8.9+HEAD.cb1b65054

Operating System Version and Architecture

Windows 10 21H2

Describe Bug

The ZmqPb library needs protobuf and zmq, and for that, since https://github.com/xmake-io/xmake-repo/pull/3576, it also installs abseil.
That just doesn't work and exits(1) while configuring.

Expected Behavior

The required packages install without errors.

Project Configuration

xmake.lua:

set_project( "ZmqPb" )

set_version( "0.5.0", { build = "%Y%m%d", soname = true } )

set_warnings( "allextra" )

add_rules( "mode.debug", "mode.release" )
add_rules( "plugin.compile_commands.autoupdate", { outputdir = ".vscode" } )

if is_plat( "windows" ) then
    set_languages( "cxxlatest" )

    add_cxflags( "/Zc:__cplusplus" )
    add_cxflags( "/Zc:preprocessor" )

    add_cxflags( "/permissive-" )

    --set_runtimes(is_mode("debug") and "MDd" or "MD")
else
    set_languages( "cxx20" )
end

if is_mode( "debug" ) then
    add_defines( "DEBUG" )
end
if is_mode( "release" ) then
    add_defines( "NDEBUG" )
end

add_requireconfs( "*", { configs = { shared = get_config( "kind" ) == "shared" } } )

add_requires( "cppzmq" )
add_requires( "protobuf-cpp" )

target( "ZmqPb" )
    set_kind( "$(kind)" )

    add_packages( "cppzmq", { public = true } )
    add_packages( "protobuf-cpp", { public = true } )

    add_rules( "protobuf.cpp" )

    add_includedirs( "include", { public = true } )
    add_headerfiles( "include/(zmqPb/*.hpp)" )
    add_files( "proto/zmqPb/*.proto", { proto_public = false } )
    add_files( "src/*.cpp" )

xmake conf:

{
    arch = "x64",
    buildir = "build",
    ccache = true,
    host = "windows",
    kind = "shared",
    mode = "release",
    ndk_stdcxx = true,
    network = "public",
    pkg_searchdirs = "",
    plat = "windows",
    proxy_pac = "pac.lua",
    qt = "D:/Qt/5.15.2/msvc2019_64",
    qt_sdkver = "5.15.2",
    theme = "plain",
    vcpkg = "D:/vcpkg",
    vs = "2022"
}

Additional Information and Error Logs

xmake config --import=.vscode/xmakeConfig.release.conf -vD (conf is the one above) results in:

checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\cl.exe
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.33.31630
checking for zig ... ok
checkinfo: cannot runv(nim.exe --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(nim.exe --version), No such file or directory
checking for nim ... no
checkinfo: cannot runv(unzip.exe -v), No such file or directory
checking for unzip ... no
checking for 7z ... D:\xmake\winenv\bin\7z
checking for git ... ok
checkinfo: cannot runv(gzip.exe --version), No such file or directory
checking for gzip ... no
git rev-parse HEAD
checking for cmake ... no
checking for cmake ... no
checking for cmake ... no
checking for cmake ... D:\CMake\bin\cmake
finding zeromq from xmake ..
checking for xmake::zeromq ... zeromq 4.3.5
finding cppzmq from xmake ..
checking for xmake::cppzmq ... cppzmq v4.10.0
finding abseil from xmake ..
checking for xmake::abseil ... abseil 20240116.1
finding protobuf-cpp from xmake ..
checking for xmake::protobuf-cpp ... no
finding protobuf-cpp from vcpkg ..
finding protobuf-cpp from conan ..
finding protobuf-cpp from pkgconfig ..
checkinfo: cannot runv(pkg-config.exe --version), No such file or directory
checking for pkg-config ... no
checkinfo: cannot runv(pkgconf.exe --version), No such file or directory
checking for pkgconf ... no
finding protobuf-cpp from system ..
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\cl.exe
checking for the c compiler (cc) ... cl.exe
> "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX64\\x64\\cl.exe" -c -nologo -FoC:\Users\SFG\AppData\Local\Temp\.xmake\240403\_0FE624747090493085B1A070545C6780.o C:\Users\SFG\AppData\Local\Temp\.xmake\240403\_775FB00633BC4F66BF87D39CCDE5CF30.c
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for link.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\link.exe
checking for the linker (ld) ... link.exe
> "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.33.31629\\bin\\HostX64\\x64\\link.exe" -nologo -dynamicbase -nxcompat -machine:x64 protobuf-cpp.lib -out:C:\Users\SFG\AppData\Local\Temp\.xmake\240403\_0FE624747090493085B1A070545C6780.b C:\Users\SFG\AppData\Local\Temp\.xmake\240403\_0FE624747090493085B1A070545C6780.o
> checking for c links(protobuf-cpp)
> checking for c snippet(find_package/protobuf-cpp)
checkinfo: ...gramdir\core\sandbox\modules\import\core\tool\linker.lua:75: @programdir\modules\core\tools\link.lua:175: LINK : fatal error LNK1181: cannot open input file 'protobuf-cpp.lib'

stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:957]:
    [@programdir\modules\core\tools\link.lua:175]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:123]: in function 'try'
    [@programdir\modules\core\tools\link.lua:150]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:275]:
    [@programdir\core\tool\linker.lua:221]: in function 'link'
    [...gramdir\core\sandbox\modules\import\core\tool\linker.lua:73]: in function 'link'
    [@programdir\modules\lib\detect\check_cxsnippets.lua:249]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:275]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\lib\detect\check_cxsnippets.lua:236]:
    [@programdir\modules\package\manager\system\find_package.lua:68]:
    [@programdir\modules\package\manager\find_package.lua:85]: in function '_find_package_with_builtin_rule'
    [@programdir\modules\package\manager\find_package.lua:131]: in function '_find_package'
    [@programdir\modules\package\manager\find_package.lua:195]:
    [@programdir\modules\lib\detect\find_package.lua:109]:
    [@programdir\core\package\package.lua:1778]: in function '_fetch_library'
    [@programdir\core\package\package.lua:1945]: in function 'fetch'
    [...modules\private\action\require\impl\install_packages.lua:333]: in function 'jobfunc'
    [@programdir\modules\async\runjobs.lua:256]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:275]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [@programdir\modules\async\runjobs.lua:238]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:406]:

checking for protobuf-cpp ... no
note: install or modify (m) these packages (pass -y to skip confirm)?
in xmake-repo:
  -> protobuf-cpp 26.1 [runtimes:"MT", shared:y]
please input: y (y/n/m)
checking for ping ... ok
pinging the host(github.com) ... 20 ms
checking for curl ... D:\xmake\winenv\bin\curl
D:\xmake\winenv\bin\curl -SL -A "Xmake/2.8.9+HEAD.cb1b65054 (Windows;) curl/8.2.1" https://github.com/protocolbuffers/protobuf/releases/download/v26.1/protobuf-cpp-26.1.zip -o protobuf-cpp-26.1.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100     9  100     9    0     0     24      0 --:--:-- --:--:-- --:--:--    25
error: ...modules\private\action\require\impl\actions\download.lua:206: unmatched checksum, current hash(0019dfc4) != original hash(e15c2723)
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:957]:
    [...modules\private\action\require\impl\actions\download.lua:206]: in function '_download'
    [...modules\private\action\require\impl\actions\download.lua:346]:

  => download https://github.com/protocolbuffers/protobuf/releases/download/v26.1/protobuf-cpp-26.1.zip .. failed
D:\xmake\winenv\bin\7z x -y protobuf-26.1.zip -osource.tmp

7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21

Scanning the drive for archives:
1 file, 7613835 bytes (7436 KiB)

Extracting archive: protobuf-26.1.zip
--
Path = protobuf-26.1.zip
Type = zip
Physical Size = 7613835
Comment = 2434ef2adf0c74149b9d547ac5fb545a1ff8b6b5

Everything is Ok

Folders: 320
Files: 2769
Size:       38776581
Compressed: 7613835
checking for cmake ... D:\CMake\bin\cmake
D:\CMake\bin\cmake -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_PROTOC_BINARIES=ON -Dprotobuf_ABSL_PROVIDER=package -DBUILD_SHARED_LIBS=ON -Dprotobuf_MSVC_STATIC_RUNTIME=ON -DCMAKE_INSTALL_PREFIX=C:\Users\SFG\AppData\Local\.xmake\packages\p\protobuf-cpp\26.1\306d197677f34d0c83903475a16853c8 -DCMAKE_INSTALL_LIBDIR:PATH=lib -G "Visual Studio 17 2022" -A x64 -DCMAKE_GENERATOR_TOOLSET=v143 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded "-DCMAKE_CXX_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1" "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG" "-DCMAKE_C_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1" "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG" -DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=pdb -DCMAKE_POSITION_INDEPENDENT_CODE=ON C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source
-- Selecting Windows SDK version 10.0.20348.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.33.31630.0
-- The CXX compiler identification is MSVC 19.33.31630.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- 
-- 26.1.0
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT - Failed
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE  
-- Found ZLIB: D:/libxml/lib/libz.dll.a (found version "1.2.13")  
-- Configuring done (6.1s)
CMake Error at cmake/libprotobuf-lite.cmake:27 (target_link_libraries):
  Target "libprotobuf-lite" links to:
    absl::abseil_dll

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  CMakeLists.txt:300 (include)

CMake Error at cmake/libprotobuf.cmake:30 (target_link_libraries):
  Target "libprotobuf" links to:

    absl::abseil_dll

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  CMakeLists.txt:304 (include)

CMake Error at cmake/libprotoc.cmake:20 (target_link_libraries):
  Target "libprotoc" links to:

    absl::abseil_dll

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  CMakeLists.txt:309 (include)

CMake Error at cmake/protoc.cmake:6 (target_link_libraries):
  Target "protoc" links to:

    absl::abseil_dll

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  CMakeLists.txt:315 (include)

-- Generating done (0.2s)
CMake Generate step failed.  Build files cannot be regenerated correctly.
error: @programdir\core\sandbox\modules\os.lua:378: execv(D:\CMake\bin\cmake -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_PROTOC_BINARIES=ON -Dprotobuf_ABSL_PROVIDER=package -DBUILD_SHARED_LIBS=ON -Dprotobuf_MSVC_STATIC_RUNTIME=ON -DCMAKE_INSTALL_PREFIX=C:\Users\SFG\AppData\Local\.xmake\packages\p\protobuf-cpp\26.1\306d197677f34d0c83903475a16853c8 -DCMAKE_INSTALL_LIBDIR:PATH=lib -G "Visual Studio 17 2022" -A x64 -DCMAKE_GENERATOR_TOOLSET=v143 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded "-DCMAKE_CXX_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1" "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG" "-DCMAKE_C_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1" "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG" -DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=pdb -DCMAKE_POSITION_INDEPENDENT_CODE=ON C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source) failed(1)
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:957]:
    [@programdir\core\sandbox\modules\os.lua:378]:
    [@programdir\core\sandbox\modules\os.lua:291]: in function 'vrunv'
    [@programdir\modules\package\tools\cmake.lua:1056]: in function 'install'
    [...epositories\xmake-repo\packages\p\protobuf-cpp\xmake.lua:59]: in function 'script'
    [...dir\modules\private\action\require\impl\utils\filter.lua:114]: in function 'call'
    [...\modules\private\action\require\impl\actions\install.lua:369]:

  => install protobuf-cpp 26.1 .. failed
error: @programdir\core\main.lua:329: @programdir\modules\async\runjobs.lua:338: ...\modules\private\action\require\impl\actions\install.lua:474: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:957]:
    [...\modules\private\action\require\impl\actions\install.lua:474]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:123]: in function 'try'
    [...\modules\private\action\require\impl\actions\install.lua:333]:
    [...modules\private\action\require\impl\install_packages.lua:487]: in function 'jobfunc'
    [@programdir\modules\async\runjobs.lua:256]:

stack traceback:
    [C]: in function 'error'
    @programdir\core\base\os.lua:957: in function 'base/os.raiselevel'
    (...tail calls...)
    @programdir\core\main.lua:329: in upvalue 'cotask'
    @programdir\core\base\scheduler.lua:406: in function <@programdir\core\base\scheduler.lua:399>
warning: please use package:runtimes() or package:has_runtime() instead of package:config("vs_runtime")
waruqi commented 5 months ago

@c8ef we should provide a abseil config and disable it to ensure minimal dependencies by default.

like zlib. https://github.com/xmake-io/xmake-repo/blob/6f45709808d41ebfd1aa17b7757622d44416021d/packages/p/protobuf-cpp/xmake.lua#L22

waruqi commented 5 months ago

please wait for this pr. https://github.com/xmake-io/xmake-repo/pull/3667

SFGrenade commented 5 months ago

now trying to build it again.

the only errors are:

> checking for c++ snippet(test)
  => install abseil 20240116.1 .. ok
checking for curl ... D:\xmake\winenv\bin\curl
D:\xmake\winenv\bin\curl -SL -A "Xmake/2.8.9+HEAD.cb1b65054 (Windows;) curl/8.2.1" https://github.com/protocolbuffers/protobuf/releases/download/v26.1/protobuf-cpp-26.1.zip -o protobuf-cpp-26.1.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100     9  100     9    0     0     24      0 --:--:-- --:--:-- --:--:--    24
error: ...modules\private\action\require\impl\actions\download.lua:206: unmatched checksum, current hash(0019dfc4) != original hash(e15c2723)
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:957]:
    [...modules\private\action\require\impl\actions\download.lua:206]: in function '_download'
    [...modules\private\action\require\impl\actions\download.lua:346]:
       (ClCompile target) -> 
         D:\curl-7.88.1_2\include\zconf.h(490,14): fatal  error C1083: Cannot open include file: 'unistd.h': No such file or directory (compiling source file C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source\src\google\protobuf\io\gzip_stream.cc) [C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source\build\libprotobuf.vcxproj]

after which protobuf fails to compile.

results in the attached log. 01_configure_release.txt

waruqi commented 5 months ago

the first url https://github.com/protocolbuffers/protobuf/releases/download/v26.1/protobuf-cpp-26.1.zip is invalid url for 22.x

we need to improve url, like this.

https://github.com/xmake-io/xmake-repo/blob/9c9e6660df5bce1699ecc8d3eb98dbb52c612b1c/packages/s/sqlite3/xmake.lua#L6

@c8ef

c8ef commented 5 months ago

the first url https://github.com/protocolbuffers/protobuf/releases/download/v26.1/protobuf-cpp-26.1.zip is invalid url for 22.x

we need to improve url, like this.

https://github.com/xmake-io/xmake-repo/blob/9c9e6660df5bce1699ecc8d3eb98dbb52c612b1c/packages/s/sqlite3/xmake.lua#L6

@c8ef

tracked in #3709

c8ef commented 5 months ago

now trying to build it again.

the only errors are:

> checking for c++ snippet(test)
  => install abseil 20240116.1 .. ok
checking for curl ... D:\xmake\winenv\bin\curl
D:\xmake\winenv\bin\curl -SL -A "Xmake/2.8.9+HEAD.cb1b65054 (Windows;) curl/8.2.1" https://github.com/protocolbuffers/protobuf/releases/download/v26.1/protobuf-cpp-26.1.zip -o protobuf-cpp-26.1.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100     9  100     9    0     0     24      0 --:--:-- --:--:-- --:--:--    24
error: ...modules\private\action\require\impl\actions\download.lua:206: unmatched checksum, current hash(0019dfc4) != original hash(e15c2723)
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:957]:
    [...modules\private\action\require\impl\actions\download.lua:206]: in function '_download'
    [...modules\private\action\require\impl\actions\download.lua:346]:
       (ClCompile target) -> 
         D:\curl-7.88.1_2\include\zconf.h(490,14): fatal  error C1083: Cannot open include file: 'unistd.h': No such file or directory (compiling source file C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source\src\google\protobuf\io\gzip_stream.cc) [C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source\build\libprotobuf.vcxproj]

after which protobuf fails to compile.

results in the attached log. 01_configure_release.txt

pushed as https://github.com/xmake-io/xmake-repo/commit/32fae29e8433456f8f6da746dc0a9eeb98c25bca, please try again. @SFGrenade

SFGrenade commented 5 months ago

after finding out how i can use the xmake-repo (dev branch) as a repo and rebuilding, i do see the unistd error again:

       (ClCompile target) -> 
         D:\curl-7.88.1_2\include\zconf.h(490,14): fatal  error C1083: Cannot open include file: 'unistd.h': No such file or directory (compiling source file C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source\src\google\protobuf\io\gzip_stream.cc) [C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source\build\libprotobuf.vcxproj]

which for some reason it seems to take my locally installed curl? i don't know why, don't find it in any dep/xmake/cmake.

Project config:
.vscode\xmakeConfig.release.conf

{
    arch = "x64",
    buildir = "build",
    ccache = true,
    host = "windows",
    kind = "shared",
    mode = "release",
    ndk_stdcxx = true,
    network = "public",
    pkg_searchdirs = "",
    plat = "windows",
    proxy_pac = "pac.lua",
    qt = "D:/Qt/5.15.2/msvc2019_64",
    qt_sdkver = "5.15.2",
    theme = "plain",
    vcpkg = "D:/vcpkg",
    vs = "2022",
    vs_runtime = "MD"
}

xmake.lua

set_project( "ZmqPb" )

set_version( "0.5.0", { build = "%Y%m%d", soname = true } )

set_warnings( "allextra" )

add_rules( "mode.debug", "mode.release", "mode.releasedbg", "mode.minsizerel" )
add_rules( "plugin.compile_commands.autoupdate", { outputdir = ".vscode" } )

set_languages( "c++11" )

if is_plat( "windows" ) then
    add_cxflags( "/Zc:__cplusplus" )
    add_cxflags( "/Zc:preprocessor" )

    add_cxflags( "/permissive-" )
end

add_requireconfs( "*", { configs = { shared = get_config( "kind" ) == "shared" } } )

add_requires( "cppzmq" )
add_requires( "protobuf-cpp" )

target( "ZmqPb" )
    set_kind( "$(kind)" )

    add_packages( "cppzmq", { public = true } )
    add_packages( "protobuf-cpp", { public = true } )

    add_rules( "protobuf.cpp" )

    add_includedirs( "include", { public = true } )
    add_headerfiles( "include/(zmqPb/*.hpp)" )
    add_files( "proto/zmqPb/*.proto", { proto_public = false } )
    add_files( "src/*.cpp" )

how i build/test this specific project:

  1. delete everything in %localappdata%\.xmake\packages
  2. delete build and .xmake folders in project folder
  3. run rm _build_logs\* (to easier see build logs)
  4. run xmake global --theme=plain >_build_logs\00_set_theme.txt 2>&1
  5. run xmake config --import=.vscode/xmakeConfig.release.conf -vD -y >_build_logs\01_configure_release.txt 2>&1
  6. It fails, with above, but if it wouldn't:
  7. run xmake build -a -vD >_build_logs\02_build.txt 2>&1
  8. run xmake test -vD >_build_logs\05_test.txt 2>&1
  9. run xmake package -vD -ao E:\xmake_packages >_build_logs\10_package.txt 2>&1 or
  10. xmake install -vD -ao E:\System_Simulator >_build_logs\20_install.txt 2>&1

Logs: 00_set_theme.txt 01_configure_release.txt

c8ef commented 5 months ago

Hmm... It's really strange that it somehow includes the curl headers.

waruqi commented 5 months ago

after finding out how i can use the xmake-repo (dev branch) as a repo and rebuilding, i do see the unistd error again:


xrepo update-repo
xrepo remove --all protobuf-cpp abseil curl .... other
xmake f -cvD
xmake
c8ef commented 5 months ago

I've noticed that your build process is finding zlib from sources other than xmake, specifically: Found ZLIB: D:/libxml/lib/libz.dll.a. In my opinion, it's possible that vcpkg is loading a predefined cmake file and providing a different library location, but I can't be certain. Could you please verify if curl is installed in your vcpkg? If it is, does it have the exact version 7.88.1_2? According to the vcpkg source, the 7.88.1 version of curl has exactly two revisions, which somewhat supports my assumption.

waruqi commented 5 months ago
     C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\CL.exe /c /I"D:\curl-7.88.1_2\include" /I"C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source\build" /I"C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source" /I"C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source\src" /IC:\Users\SFG\AppData\Local\.xmake\packages\a\abseil\20240116.1\b8bf244d9f4a47a4aec27d7f4728ed6b\include /nologo /W1 /WX- /diagnostics:column /O2 /Ob2 /D _MBCS /D NDEBUG /D "CMAKE_INTDIR=\"Release\"" /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"utf8_range.dir\Release\\" /Fd"C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source\build\third_party\utf8_range\pdb\Release\\" /external:W1 /Gd /TC /errorReport:queue "C:\Users\SFG\AppData\Local\.xmake\cache\packages\2404\p\protobuf-cpp\26.1\source\third_party\utf8_range\utf8_range.c"

Maybe cmake found curl/zlib on your system instead of xmake-repo. We should tell cmake to find them from xmake-repo instead of system.

SFGrenade commented 5 months ago

I've noticed that your build process is finding zlib from sources other than xmake, specifically: Found ZLIB: D:/libxml/lib/libz.dll.a. In my opinion, it's possible that vcpkg is loading a predefined cmake file and providing a different library location, but I can't be certain. Could you please verify if curl is installed in your vcpkg? If it is, does it have the exact version 7.88.1_2? According to the vcpkg source, the 7.88.1 version of curl has exactly two revisions, which somewhat supports my assumption.

my locally installed vcpkg (which i only installed because i wanted to mess with something only there and not in xmake) does:

C:\Users\SFG>D:\vcpkg\vcpkg.exe list
clap-cleveraudio:x64-windows-static-md            1.2.0               CLAP is an audio plugin ABI which defines a stan...
vcpkg-cmake-config:x64-windows                    2022-02-06#1
vcpkg-cmake:x64-windows                           2023-05-04

so, i don't have curl installed via vcpkg

waruqi commented 5 months ago

D:\curl-7.88.1_2\include, it's not from vcpkg. Maybe you installed curl for windows package?

c8ef commented 5 months ago

The truly perplexing aspect is that the entire protobuf-cpp repository doesn't make any explicit request to find curl. I'm still unable to comprehend why curl headers are present in the include directory. Interestingly, in the CI environment, the protobuf-cpp package doesn't require curl headers for the build process. It successfully generates both shared and static libraries on Windows.

SFGrenade commented 5 months ago

after finding out how i can use the xmake-repo (dev branch) as a repo and rebuilding, i do see the unistd error again:

xrepo update-repo
xrepo remove --all protobuf-cpp abseil curl .... other
xmake f -cvD
xmake

results in: log.update-repo.txt log.remove-all.txt log.xmake-f-cvD.txt log.xmake.txt

SFGrenade commented 5 months ago

D:\curl-7.88.1_2\include, it's not from vcpkg. Maybe you installed curl for windows package?

it is installed manually with curl's windows installer, as the version bundled in windows lacked some features i needed once

SFGrenade commented 5 months ago

The truly perplexing aspect is that the entire protobuf-cpp repository doesn't make any explicit request to find curl. I'm still unable to comprehend why curl headers are present in the include directory. Interestingly, in the CI environment, the protobuf-cpp package doesn't require curl headers for the build process. It successfully generates both shared and static libraries on Windows.

i suppose i can try to remove curl from my path and see what happens

SFGrenade commented 5 months ago

progress: in CI, i managed to have windows build, not mac/linux though lol

though abseil requires c++14 according to preprocessor error, but even then uses c++17 classes, but once i set it to c++17/cxx17, windows manages to build while linux/mac have lua errors:
https://github.com/SFGrenade/ZmqPb/actions/runs/8582299204

build cache stats:
cache directory: build/.build_cache
cache hit rate: 0%
cache hit: 0
cache hit total time: 0.000s
cache miss: 0
cache miss total time: 0.000s
new cached files: 0
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0
compile total time: 0.000s

error: ./.xmake-cache-W14/share/xmake/core/main.lua:329: attempt to compare table with string
stack traceback:
    [C]: in function 'sort'
    [...-W14/share/xmake/rules/plugin/compile_commands/xmake.lua:61]: in function 'buildscript'
    [./.xmake-cache-W14/share/xmake/actions/build/main.lua:97]: in function '_do_project_rules'
    [./.xmake-cache-W14/share/xmake/actions/build/main.lua:162]: in function 'build_targets'
    [./.xmake-cache-W14/share/xmake/actions/build/main.lua:201]:
    [C]: in function 'xpcall'
    [./.xmake-cache-W14/share/xmake/core/base/utils.lua:275]:
    [./.xmake-cache-W14/share/xmake/core/base/task.lua:491]: in function 'run'
    [./.xmake-cache-W14/share/xmake/core/main.lua:327]: in function 'cotask'
    [./.xmake-cache-W14/share/xmake/core/base/scheduler.lua:406]:

stack traceback:
    [C]: in function 'error'
    ./.xmake-cache-W14/share/xmake/core/base/os.lua:957: in function 'base/os.raiselevel'
    (...tail calls...)
    ./.xmake-cache-W14/share/xmake/core/main.lua:329: in upvalue 'cotask'
    ./.xmake-cache-W14/share/xmake/core/base/scheduler.lua:406: in function <./.xmake-cache-W14/share/xmake/core/base/scheduler.lua:399>
Error: Process completed with exit code 255.
SFGrenade commented 5 months ago

i suppose i can try to remove curl from my path and see what happens

once i uninstalled a local cmake and removed a few other things from path (like libxml) it built without problem (on windows)

SFGrenade commented 5 months ago

so the same commit works fine when pushed as a tag apparently? The workflow: https://github.com/SFGrenade/ZmqPb/blob/master/.github/workflows/build.yaml

could possibly mean that each second compile things work fine? idk tbh

no tag: https://github.com/SFGrenade/ZmqPb/actions/runs/8582370862 tag: https://github.com/SFGrenade/ZmqPb/actions/runs/8582432093

edit: nvm, the resulting archives are just empty

SFGrenade commented 5 months ago

so apparently protobuf does not publicize it's dependencies (required for using it, only when linking): https://github.com/xmake-io/xmake-repo/actions/runs/8583100316/job/23521931254?pr=3712#step:6:405

SFGrenade commented 5 months ago

which seems to be related to: https://github.com/protocolbuffers/protobuf/issues/12271 https://github.com/protocolbuffers/protobuf/issues/12637 https://github.com/protocolbuffers/protobuf/issues/12746

SFGrenade commented 4 months ago

considering https://github.com/xmake-io/xmake/issues/4980 was completed, i'll close this

SFGrenade commented 4 months ago

nvm, https://github.com/NetworkingHelpers/ZmqPb-Cpp/actions/runs/8765233490/job/24056030112 can't require protobuf, because it depends on abseil, which apparently doesn't like debug static linking

SFGrenade commented 4 months ago

yea, even in debug it wants to either have MD or MT runtimes, not the -d variants: https://github.com/SFGrenade/ZmqPb-Cpp/actions/runs/8780193422

SFGrenade commented 4 months ago

Runs to show the -d variant phenomenon: https://github.com/SFGrenade/MinXmakeProtobufExample/actions/runs/8786162232 https://github.com/SFGrenade/MinXmakeProtobufExample/actions/runs/8786162232/job/24108368436 specifically also shows a lot of error LNK2001: unresolved external symbol

SFGrenade commented 4 months ago

so after testing i can say that right now:

SFGrenade commented 4 months ago

And with an actual library utilizing protobuf, tests conclude that:

waruqi commented 4 months ago

Due to limited ci resources and maintenance time, packages from the xmake-repo repository cannot be guaranteed to be reliable for debug mode packages. You can either pr to improve these packages so that they support debug mode better. Or you can be patient and wait for the maintainers to improve it. This may take some time.

It is cross-compiled on windows arm ci, so its protoc binary is not executable. This means that the protobuf-cpp package does not currently support the cross-compilation toolchain. Although it can generate library files, its binary executable is not available.

waruqi commented 4 months ago

It works for me.

ruki-2:MinXmakeProtobufExample ruki$ xmake run -vD MinExample
addenvs {
  LD_LIBRARY_PATH = {
    "/Users/ruki/.xmake/packages/p/protobuf-cpp/26.1/ae262a70afeb498eb98116e7f418249c/lib",
    "/Users/ruki/.xmake/packages/c/cmake/3.29.2/3e5df9e9859c40e58c694a1385a22115/lib",
    "/Users/ruki/.xmake/packages/a/abseil/20240116.2/686c031234b7431d9d0437b8a28cb574/lib",
    "/Users/ruki/.xmake/packages/u/utf8_range/2022.11.15/704726b2eca043f18fa655f3b94938e9/lib",
    "/Users/ruki/.xmake/packages/c/cmake/3.29.2/3e5df9e9859c40e58c694a1385a22115/lib",
    "/Users/ruki/.xmake/packages/a/abseil/20240116.2/686c031234b7431d9d0437b8a28cb574/lib"
  },
  DYLD_LIBRARY_PATH = {
    "/Users/ruki/.xmake/packages/p/protobuf-cpp/26.1/ae262a70afeb498eb98116e7f418249c/lib",
    "/Users/ruki/.xmake/packages/c/cmake/3.29.2/3e5df9e9859c40e58c694a1385a22115/lib",
    "/Users/ruki/.xmake/packages/a/abseil/20240116.2/686c031234b7431d9d0437b8a28cb574/lib",
    "/Users/ruki/.xmake/packages/u/utf8_range/2022.11.15/704726b2eca043f18fa655f3b94938e9/lib",
    "/Users/ruki/.xmake/packages/c/cmake/3.29.2/3e5df9e9859c40e58c694a1385a22115/lib",
    "/Users/ruki/.xmake/packages/a/abseil/20240116.2/686c031234b7431d9d0437b8a28cb574/lib"
  },
  PATH = {
    "/Users/ruki/.xmake/packages/p/protobuf-cpp/26.1/ae262a70afeb498eb98116e7f418249c/bin",
    "/Users/ruki/.xmake/packages/c/cmake/3.29.2/3e5df9e9859c40e58c694a1385a22115/bin",
    "/Users/ruki/.xmake/packages/c/cmake/3.29.2/3e5df9e9859c40e58c694a1385a22115/bin"
  }
}

setenvs { }

env:
=> 'SHELL=/bin/bash'
=> 'XPC_FLAGS=0x0'
=> 'TERM_PROGRAM_VERSION=450'
=> 'rvm_prefix=/Users/ruki'
=> 'JAVA_HOME=/Library//Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home/'
=> '__CFBundleIdentifier=com.apple.Terminal'
=> 'SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.15JT8oSLZf/Listeners'
=> 'TERM_SESSION_ID=F2B54146-035F-4CCD-9656-A610A109FF54'
=> 'XMAKE_PROGRAM_FILE=/Users/ruki/.local/bin/xmake'
=> 'MY_RUBY_HOME=/Users/ruki/.rvm/rubies/ruby-2.6.3'
=> 'NVIM_LOG_FILE=/Users/ruki/.cache/nvim/log'
=> 'RUBY_VERSION=ruby-2.6.3'
=> 'NVIM_LISTEN_ADDRESS=/var/folders/32/w9cz0y_14hs19lkbs6v6_fm80000gn/T/nvim12LZFf/0'
=> 'PWD=/tmp/MinXmakeProtobufExample'
=> 'LOGNAME=ruki'
=> 'rvm_version=1.29.9 (latest)'
=> 'XMAKE_PROGRAM_DIR=/Users/ruki/.local/share/xmake'
=> 'LaunchInstanceID=9F3D9850-E1B0-49BE-A91F-99AEC93C89D1'
=> 'PUB_HOSTED_URL=https://pub.flutter-io.cn'
=> 'HOME=/Users/ruki'
=> 'LANG=zh_CN.UTF-8'
=> 'SECURITYSESSIONID=186a1'
=> 'VIMRUNTIME=/Users/ruki/files/nvim-osx64/share/nvim/runtime'
=> 'TMPDIR=/var/folders/32/w9cz0y_14hs19lkbs6v6_fm80000gn/T/'
=> 'FENCVIEW_TELLENC=tellenc'
=> 'rvm_bin_path=/Users/ruki/.rvm/bin'
=> 'VIM=/Users/ruki/files/nvim-osx64/share/nvim'
=> 'GEM_PATH=/Users/ruki/.rvm/gems/ruby-2.6.3:/Users/ruki/.rvm/gems/ruby-2.6.3@global'
=> 'GEM_HOME=/Users/ruki/.rvm/gems/ruby-2.6.3'
=> 'TERM=xterm-256color'
=> 'USER=ruki'
=> 'XMAKE_ROOTDIR=/Users/ruki/.local/bin'
=> 'SHLVL=3'
=> 'XPC_SERVICE_NAME=0'
=> 'MYVIMRC=/Users/ruki/.vim/init.vim'
=> 'XMAKE_SHELL=bash'
=> 'FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn'
=> 'PATH=/Users/ruki/.xmake/packages/p/protobuf-cpp/26.1/ae262a70afeb498eb98116e7f418249c/bin:/Users/ruki/.xmake/packages/c/cmake/3.29.2/3e5df9e9859c40e58c694a1385a22115/bin:/Users/ruki/.local/bin:/Us
ers/ruki/.rvm/gems/ruby-2.6.3/bin:/Users/ruki/.rvm/gems/ruby-2.6.3@global/bin:/Users/ruki/.rvm/rubies/ruby-2.6.3/bin:/Library//Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home//bin:/usr/local/o
pt/make/libexec/gnubin:/Users/ruki/projects/working/flutter/flutter_v1.9.1+hotfix.6-stable/flutter/bin:/Users/ruki/projects/working/flutter/flutter_v1.9.1+hotfix.6-stable/flutter/bin/cache/dart-sdk/bi
n:/Users/ruki/projects/working/flutter/depot_tools:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/ruki/.cargo/bin:/Use
rs/ruki/.rvm/bin'
=> 'CLASS_PATH=/Library//Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home//lib'
=> 'IRBRC=/Users/ruki/.rvm/rubies/ruby-2.6.3/.irbrc'
=> 'rvm_path=/Users/ruki/.rvm'
=> '__CF_USER_TEXT_ENCODING=0x1F5:0x19:0x34'
=> 'TERM_PROGRAM=Apple_Terminal'
=> '_=/Users/ruki/.local/bin/xmake'
=> 'DYLD_LIBRARY_PATH=/Users/ruki/.xmake/packages/p/protobuf-cpp/26.1/ae262a70afeb498eb98116e7f418249c/lib:/Users/ruki/.xmake/packages/c/cmake/3.29.2/3e5df9e9859c40e58c694a1385a22115/lib:/Users/ruki/.
xmake/packages/a/abseil/20240116.2/686c031234b7431d9d0437b8a28cb574/lib:/Users/ruki/.xmake/packages/u/utf8_range/2022.11.15/704726b2eca043f18fa655f3b94938e9/lib'
=> 'LD_LIBRARY_PATH=/Users/ruki/.xmake/packages/p/protobuf-cpp/26.1/ae262a70afeb498eb98116e7f418249c/lib:/Users/ruki/.xmake/packages/c/cmake/3.29.2/3e5df9e9859c40e58c694a1385a22115/lib:/Users/ruki/.xm
ake/packages/a/abseil/20240116.2/686c031234b7431d9d0437b8a28cb574/lib:/Users/ruki/.xmake/packages/u/utf8_range/2022.11.15/704726b2eca043f18fa655f3b94938e9/lib'
Your PATH is: /Users/ruki/.xmake/packages/p/protobuf-cpp/26.1/ae262a70afeb498eb98116e7f418249c/bin:/Users/ruki/.xmake/packages/c/cmake/3.29.2/3e5df9e9859c40e58c694a1385a22115/bin:/Users/ruki/.local/bi
n:/Users/ruki/.rvm/gems/ruby-2.6.3/bin:/Users/ruki/.rvm/gems/ruby-2.6.3@global/bin:/Users/ruki/.rvm/rubies/ruby-2.6.3/bin:/Library//Java/JavaVirtualMachines/jdk1.8.0_291.jdk/Contents/Home//bin:/usr/lo
cal/opt/make/libexec/gnubin:/Users/ruki/projects/working/flutter/flutter_v1.9.1+hotfix.6-stable/flutter/bin:/Users/ruki/projects/working/flutter/flutter_v1.9.1+hotfix.6-stable/flutter/bin/cache/dart-s
dk/bin:/Users/ruki/projects/working/flutter/depot_tools:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local
/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/Users/ruki/.cargo/bin
:/Users/ruki/.rvm/bin
Message at 0x600002ee8000
- Name: myMessage->set_name
- String: myMessage->set_string
- 
waruqi commented 4 months ago

It also works for me.

ruki-2:ZmqPb-Cpp ruki$ xmake run -vD --group=TESTS
[==========] Running 6 tests from 1 test suite.
[----------] Global test environment set-up.
[----------] 6 tests from ZmqPb
[ RUN      ] ZmqPb.ConstructorTest01
[       OK ] ZmqPb.ConstructorTest01 (0 ms)
[ RUN      ] ZmqPb.ConstructorTest02
[       OK ] ZmqPb.ConstructorTest02 (5 ms)
[ RUN      ] ZmqPb.ConstructorTest03
[       OK ] ZmqPb.ConstructorTest03 (0 ms)
[ RUN      ] ZmqPb.ConstructorTest04
[       OK ] ZmqPb.ConstructorTest04 (0 ms)
[ RUN      ] ZmqPb.ConstructorTest05
[       OK ] ZmqPb.ConstructorTest05 (0 ms)
[ RUN      ] ZmqPb.ConstructorTest06
[       OK ] ZmqPb.ConstructorTest06 (0 ms)
[----------] 6 tests from ZmqPb (6 ms total)

[----------] Global test environment tear-down
[==========] 6 tests from 1 test suite ran. (6 ms total)
[  PASSED  ] 6 tests.
SFGrenade commented 4 months ago

It works for me.

Odd that github CI doesn't like it then, but if it does work

SFGrenade commented 4 months ago

It also works for me.

same for here