xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.02k stars 781 forks source link

wsl2的ubuntu系统下使用mingw-w64编译时无法找到windows.h #4612

Closed Arama0517 closed 9 months ago

Arama0517 commented 9 months ago

Xmake 版本

2.8.6+20240115

操作系统版本和架构

Linux localhost 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

描述问题

xmake找不到mingw-w64的windows.h但usr/x86_64-w64-mingw32/include下是存在的

期待的结果

正常使用

工程配置

`add_rules("mode.debug", "mode.releasedbg", "mode.release")

add_languages("cxx17", "c17")

add_requires( "libcurl", "openssl3", "nlohmann_json" )

add_packages("nlohmann_json")

target("lib") if is_mode("debug", "releasedbg") then set_kind("shared") if is_plat("windows") then add_rules("utils.symbols.export_all", {export_classes = true}) end else set_kind("static") set_policy("build.merge_archive", true) end add_headerfiles("lib/*.hpp") add_files("lib/**.cpp") add_packages("libcurl") add_packages("openssl3") target_end()

if is_mode("debug", "releasedbg") then target("test") set_kind("binary") add_files("test.cpp") add_deps("lib") target_end() add_defines("DEBUG") end

target("main") set_kind("binary") add_files("main.cpp") add_deps("lib") target_end()`

附加信息和错误日志

`checking for mingw directory ... /usr checkinfo: cannot runv(unzip -v), No such file or directory checking for unzip ... no checking for 7z ... /usr/bin/7z checking for git ... /usr/bin/git checking for gzip ... /usr/bin/gzip checking for tar ... /usr/bin/tar /usr/bin/git rev-parse HEAD checking for cmake ... no finding libcurl from xmake .. checking for xmake::libcurl ... libcurl 8.5.0 finding openssl3 from xmake .. checking for xmake::openssl3 ... openssl3 3.0.7 finding nlohmann_json from xmake .. checking for xmake::nlohmann_json ... nlohmann_json v3.11.3 checking for x86_64-w64-mingw32-g++ ... /usr/bin/x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ checking for the c++ compiler (cxx) ... x86_64-w64-mingw32-g++ checking for /usr/bin/x86_64-w64-mingw32-g++ ... ok checking for flags (-fvisibility-inlines-hidden) ... ok

x86_64-w64-mingw32-g++ "-fvisibility-inlines-hidden" "-m64" checking for flags (-O0) ... ok x86_64-w64-mingw32-g++ "-O0" "-m64" [ 15%]: cache compiling.debug test.cpp /usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -o build/.objs/test/mingw/x86_64/debug/test.cpp.obj test.cpp [ 15%]: cache compiling.debug lib/pages/removePage.cpp /usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0.7/c1728da28e14488599c1f1d5fc92d7b5/include -o build/.objs/lib/mingw/x86_64/debug/lib/pages/removePage.cpp.obj lib/pages/removePage.cpp [ 15%]: cache compiling.debug lib/pages/startPage.cpp /usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0.7/c1728da28e14488599c1f1d5fc92d7b5/include -o build/.objs/lib/mingw/x86_64/debug/lib/pages/startPage.cpp.obj lib/pages/startPage.cpp [ 15%]: cache compiling.debug lib/pages/initPage.cpp /usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0.7/c1728da28e14488599c1f1d5fc92d7b5/include -o build/.objs/lib/mingw/x86_64/debug/lib/pages/initPage.cpp.obj lib/pages/initPage.cpp [ 15%]: cache compiling.debug lib/pages/createPage.cpp /usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0.7/c1728da28e14488599c1f1d5fc92d7b5/include -o build/.objs/lib/mingw/x86_64/debug/lib/pages/createPage.cpp.obj lib/pages/createPage.cpp [ 15%]: cache compiling.debug lib/controllers/javaDetector.cpp /usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0.7/c1728da28e14488599c1f1d5fc92d7b5/include -o build/.objs/lib/mingw/x86_64/debug/lib/controllers/javaDetector.cpp.obj lib/controllers/javaDetector.cpp [ 15%]: cache compiling.debug lib/controllers/FastMirrorAPI.cpp /usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0.7/c1728da28e14488599c1f1d5fc92d7b5/include -o build/.objs/lib/mingw/x86_64/debug/lib/controllers/FastMirrorAPI.cpp.obj lib/controllers/FastMirrorAPI.cpp [ 15%]: cache compiling.debug lib/controllers/downloadController.cpp /usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0.7/c1728da28e14488599c1f1d5fc92d7b5/include -o build/.objs/lib/mingw/x86_64/debug/lib/controllers/downloadController.cpp.obj lib/controllers/downloadController.cpp [ 15%]: cache compiling.debug lib/pages/configPage.cpp /usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0.7/c1728da28e14488599c1f1d5fc92d7b5/include -o build/.objs/lib/mingw/x86_64/debug/lib/pages/configPage.cpp.obj lib/pages/configPage.cpp [ 15%]: cache compiling.debug lib/controllers/serverController.cpp /usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0.7/c1728da28e14488599c1f1d5fc92d7b5/include -o build/.objs/lib/mingw/x86_64/debug/lib/controllers/serverController.cpp.obj lib/controllers/serverController.cpp checking for flags (-MMD -MF) ... ok x86_64-w64-mingw32-g++ "-MMD" "-MF" "/dev/null" "-m64" checking for flags (-fdiagnostics-color=always) ... ok x86_64-w64-mingw32-g++ "-fdiagnostics-color=always" "-m64" error: @programdir/core/main.lua:314: @programdir/actions/build/main.lua:148: @programdir/modules/async/runjobs.lua:320: @programdir/modules/private/action/build/object.lua:91: @programdir/modules/core/tools/gcc.lua:841: lib/controllers/javaDetector.cpp:1:10: fatal error: Windows.h: No such file or directory 1 | #include | ^~~ compilation terminated. stack traceback: [C]: in function 'error' [@programdir/core/base/os.lua:949]: [@programdir/modules/core/tools/gcc.lua:841]: in function 'catch' [@programdir/core/sandbox/modules/try.lua:123]: in function 'try' [@programdir/modules/core/tools/gcc.lua:782]: [C]: in function 'xpcall' [@programdir/core/base/utils.lua:280]: [@programdir/core/tool/compiler.lua:278]: in function 'compile' [@programdir/modules/private/action/build/object.lua:91]: in function 'script' [@programdir/modules/private/action/build/object.lua:122]: in function 'build_object' [@programdir/modules/private/action/build/object.lua:147]: in function 'jobfunc' [@programdir/modules/async/runjobs.lua:237]: [C]: in function 'xpcall' [@programdir/core/base/utils.lua:280]: in function 'trycall' [@programdir/core/sandbox/modules/try.lua:117]: in function 'try' [@programdir/modules/async/runjobs.lua:220]: in function 'cotask' [@programdir/core/base/scheduler.lua:404]:

stack traceback: [C]: in function 'error' @programdir/core/base/os.lua:949: in function 'base/os.raiselevel' (...tail calls...) @programdir/core/main.lua:314: in upvalue 'cotask' @programdir/core/base/scheduler.lua:404: in function <@programdir/core/base/scheduler.lua:397>

Issues-translate-bot commented 9 months ago

Bot detected the issue body's language is not English, translate it automatically.


Title: windows.h cannot be found when compiling with mingw-w64 under the ubuntu system of wsl2

waruqi commented 9 months ago

/usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3.11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0.7/c1728da28e14488599c1f1d5fc92d7b5/include -o build/.objs/lib/mingw/x86_64/debug/lib/controllers/serverController.cpp.obj lib/controllers/serverController.cpp

自己对下 flags ,如果没啥问题,那就是你的 mingw 环境问题,或者是 Windows.h 大小写问题。。

反正这个跟 xmake 关系应该不大,你可以自己直接调原始编译命令

Issues-translate-bot commented 9 months ago

Bot detected the issue body's language is not English, translate it automatically.


/usr/bin/x86_64-w64-mingw32-g++ -c -m64 -g -O0 -std=c++17 -DDEBUG -DCURL_STATICLIB -isystem /home/arama/.xmake/packages/n/nlohmann_json/v3. 11.3/1db32ac108d247869096721ae8de2af8/include -isystem /home/arama/.xmake/packages/l/libcurl/8.5.0/163eaa5f8b154ae5ba76527c2a1cc01a/include -isystem /home/arama/.xmake/packages/o/openssl3/3.0. 7/c1728da28e14488599c1f1d5fc92d7b5/ include -o build/.objs/lib/mingw/x86_64/debug/lib/controllers/serverController.cpp.obj lib/controllers/serverController.cpp

Check flags yourself. If there is no problem, then it is a problem with your mingw environment, or a case problem with Windows.h. .

Anyway, this has nothing to do with xmake. You can directly adjust the original compilation command yourself.