Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imgui:开启任意 SDL 相关配置时无法通过测试,应包含 SDL.h 头文件。 #3008

Closed
63enjoy opened this issue Dec 29, 2023 · 1 comment
Labels

Comments

@63enjoy
Copy link
Contributor

63enjoy commented Dec 29, 2023

Xmake 版本

2.8.6

操作系统版本和架构

Windows 11 23H2 22631.2861

描述问题

使用 xrepo 安装 imgui,开启任意 SDL 相关配置后,无法通过测试。
根据错误信息,找到测试生成的代码如下:

#include <imgui.h>


            void test() {
                IMGUI_CHECKVERSION();
                ImGui::CreateContext();
                ImGuiIO& io = ImGui::GetIO();
                ImGui::NewFrame();
                ImGui::Text("Hello, world!");
                ImGui::ShowDemoWindow(NULL);
                ImGui::Render();
                ImGui::DestroyContext();
            }
        
int main(int argc, char** argv)
{

    return 0;
}

根据代码判断,应该是因为修复 #2997 后,没有包含 SDL.h 头文件导致没有 main 宏,从而导致链接错误。

on_test(function (package)
local user_config = package:config("user_config")
assert(user_config ~= nil or package:check_cxxsnippets({test = [[
void test() {
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
ImGui::NewFrame();
ImGui::Text("Hello, world!");
ImGui::ShowDemoWindow(NULL);
ImGui::Render();
ImGui::DestroyContext();
}
]]}, {configs = {languages = "c++11"}, includes = {"imgui.h"}}))
end)

期待的结果

在开启任意 SDL 相关配置测试时包含 SDL.h 头文件,正常通过测试。

工程配置

xrepo install -vD -f "sdl2=true" imgui

附加信息和错误日志

测试错误:

checking for xmake::imgui ... imgui v1.90
{
  license = "MIT",
  sysincludedirs = {
    "C:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\include",
    "C:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\include\imgui",
    "C:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\include\backends",
    "C:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\include\misc\cpp"
  },
  libfiles = {
    "C:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\lib\imgui.lib"
  },
  linkdirs = {
    "C:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\lib"
  },
  syslinks = "imm32",
  version = "v1.90",
  links = {
    "imgui"
  },
  static = true
}

patching C:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\lib\pkgconfig\imgui.pc ..
checking for the linker (ld) ... link.exe
checking for cl.exe ... C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\cl.exe
checking for the c++ compiler (cxx) ... cl.exe
checking for C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX64\x64\cl.exe ... ok
checking for flags (/MT) ... ok
> cl.exe "/MT" "-nologo"
checking for flags (cl_external_includedir) ... ok
> cl.exe "-external:W0" "-external:IC:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\include" "-nologo"
> "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX64\\x64\\cl.exe" -c -nologo /MT -std:c++11 /EHsc -external:W0 -external:IC:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\include -external:W0 -external:IC:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\include\imgui -external:W0 -external:IC:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\include\backends -external:W0 -external:IC:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\include\misc\cpp -external:W0 -external:IC:\Users\sbl\AppData\Local\.xmake\packages\l\libsdl\2.28.5\d8952366ead841df8ae47979da7077b7\include -external:W0 -external:IC:\Users\sbl\AppData\Local\.xmake\packages\l\libsdl\2.28.5\d8952366ead841df8ae47979da7077b7\include\SDL2 -FoC:\Users\sbl\AppData\Local\Temp\.xmake\231229\_48DA043308CA4E10893CC1A47C0F7840.o C:\Users\sbl\AppData\Local\Temp\.xmake\231229\_484D0CD762AC4497B1EA5B556545ADB4.cpp
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
> "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX64\\x64\\link.exe" -nologo -dynamicbase -nxcompat -machine:x64 -subsystem:windows -nodefaultlib:msvcrt.lib -libpath:C:\Users\sbl\AppData\Local\.xmake\packages\i\imgui\v1.90\9e6fb0d68227496d9b321f236dd6016d\lib -libpath:C:\Users\sbl\AppData\Local\.xmake\packages\l\libsdl\2.28.5\d8952366ead841df8ae47979da7077b7\lib imgui.lib SDL2main.lib SDL2-static.lib user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib version.lib uuid.lib advapi32.lib setupapi.lib shell32.lib -out:C:\Users\sbl\AppData\Local\Temp\.xmake\231229\_48DA043308CA4E10893CC1A47C0F7840.b C:\Users\sbl\AppData\Local\Temp\.xmake\231229\_48DA043308CA4E10893CC1A47C0F7840.o
> checking for c++ includes(imgui.h)
> checking for c++ links(imgui, SDL2main, SDL2-static, user32, gdi32, winmm, imm32, ole32, oleaut32, version, uuid, advapi32, setupapi, shell32)
> checking for c++ snippet(test)
checkinfo: ...gramdir\core\sandbox\modules\import\core\tool\linker.lua:75: @programdir\modules\core\tools\link.lua:175: SDL2main.lib(SDL_windows_main.obj) : error LNK2005: main 已经在 _48DA043308CA4E10893CC1A47C0F7840.o 中定义
SDL2main.lib(SDL_windows_main.obj) : error LNK2019: 无法解析的外部符号 SDL_main,函数 main_getcmdline 中引用了该符号
C:\Users\sbl\AppData\Local\Temp\.xmake\231229\_48DA043308CA4E10893CC1A47C0F7840.b : fatal error LNK1120: 1 个无法解析的外部命令

stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:949]:
    [@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:280]:
    [@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:247]:
    [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\lib\detect\check_cxsnippets.lua:236]:
    [...xmake\repositories\xmake-repo\packages\i\imgui\xmake.lua:148]: in function 'script'
    [...dir\modules\private\action\require\impl\utils\filter.lua:114]: in function 'call'
    [...dir\modules\private\action\require\impl\actions\test.lua:41]:
    [...\modules\private\action\require\impl\actions\install.lua:412]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:280]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:117]: in function 'try'
    [...\modules\private\action\require\impl\actions\install.lua:333]:
    [...modules\private\action\require\impl\install_packages.lua:479]: 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]:

error: ...xmake\repositories\xmake-repo\packages\i\imgui\xmake.lua:148: assertion failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:949]: in function 'raiselevel'
    [@programdir\core\sandbox\modules\utils.lua:151]: in function 'assert'
    [...xmake\repositories\xmake-repo\packages\i\imgui\xmake.lua:148]: in function 'script'
    [...dir\modules\private\action\require\impl\utils\filter.lua:114]: in function 'call'
    [...dir\modules\private\action\require\impl\actions\test.lua:41]:
    [...\modules\private\action\require\impl\actions\install.lua:412]:

  => install imgui v1.90 .. failed
error: @programdir\core\main.lua:314: @programdir\modules\async\runjobs.lua:320: ...\modules\private\action\require\impl\actions\install.lua:474: install failed!
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:949]:
    [...\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:479]: in function 'jobfunc'
    [@programdir\modules\async\runjobs.lua:237]:

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>
error: @programdir\core\main.lua:314: @programdir\core\sandbox\modules\os.lua:378: execv(xmake require -v -D -j 22 --extra={system=false,configs={sdl2=true}} imgui) failed(-1)
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:949]:
    [@programdir\core\sandbox\modules\os.lua:378]:
    [@programdir\modules\private\xrepo\action\install.lua:300]: in function '_install_packages'
    [@programdir\modules\private\xrepo\action\install.lua:307]:
    [@programdir\modules\private\xrepo\main.lua:196]:
    [@programdir\plugins\lua\main.lua:124]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:280]:
    [@programdir\core\base\task.lua:501]: in function 'run'
    [@programdir\core\main.lua:312]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:404]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:949: in function '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>
@63enjoy 63enjoy added the bug label Dec 29, 2023
@Issues-translate-bot
Copy link

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


Title: imgui: The test cannot be passed when any SDL related configuration is turned on. The SDL.h header file should be included.

63enjoy added a commit to 63enjoy/xmake-repo that referenced this issue Jan 2, 2024
waruqi pushed a commit that referenced this issue Jan 2, 2024
@63enjoy 63enjoy closed this as completed Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants