[gui-builder] Build failure
JackBoosY opened this issue · comments
Hi guys,
I'm vcpkg maintainer.
I'm trying to update tgui on vcpkg(microsoft/vcpkg#17093), but met some problems when building tgui:
[123/124] cmd.exe /C "cd . && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E vs_link_exe --intdir=gui-builder\CMakeFiles\gui-builder.dir --rc="C:\PROGRA~2\Windows Kits\10\bin\10.0.19041.0\x64\rc.exe" --mt="C:\PROGRA~2\Windows Kits\10\bin\10.0.19041.0\x64\mt.exe" --manifests -- "C:\PROGRA~2\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x86\link.exe" gui-builder\CMakeFiles\gui-builder.dir\src\main.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\Form.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\GuiBuilder.cpp.obj /out:gui-builder\gui-builder.exe /implib:gui-builder\gui-builder.lib /pdb:gui-builder\gui-builder.pdb /version:0.0 /machine:X86 /nologo /debug /INCREMENTAL /subsystem:windows lib\tgui-d.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2_ttf.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2d.lib user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib version.lib uuid.lib advapi32.lib setupapi.lib shell32.lib dinput8.lib F:\vcpkg\installed\x86-windows\debug\lib\freetyped.lib F:\vcpkg\installed\x86-windows\debug\lib\manual-link\SDL2maind.lib opengl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D F:\vcpkg\buildtrees\tgui\x86-windows-dbg\gui-builder && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E copy F:/vcpkg/buildtrees/tgui/x86-windows-dbg/gui-builder/gui-builder.exe F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-6591265fa7/gui-builder/ && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E copy_directory F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-6591265fa7/themes F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-6591265fa7/gui-builder/themes""
FAILED: gui-builder/gui-builder.exe
cmd.exe /C "cd . && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E vs_link_exe --intdir=gui-builder\CMakeFiles\gui-builder.dir --rc="C:\PROGRA~2\Windows Kits\10\bin\10.0.19041.0\x64\rc.exe" --mt="C:\PROGRA~2\Windows Kits\10\bin\10.0.19041.0\x64\mt.exe" --manifests -- "C:\PROGRA~2\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x86\link.exe" gui-builder\CMakeFiles\gui-builder.dir\src\main.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\Form.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\GuiBuilder.cpp.obj /out:gui-builder\gui-builder.exe /implib:gui-builder\gui-builder.lib /pdb:gui-builder\gui-builder.pdb /version:0.0 /machine:X86 /nologo /debug /INCREMENTAL /subsystem:windows lib\tgui-d.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2_ttf.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2d.lib user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib version.lib uuid.lib advapi32.lib setupapi.lib shell32.lib dinput8.lib F:\vcpkg\installed\x86-windows\debug\lib\freetyped.lib F:\vcpkg\installed\x86-windows\debug\lib\manual-link\SDL2maind.lib opengl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D F:\vcpkg\buildtrees\tgui\x86-windows-dbg\gui-builder && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E copy F:/vcpkg/buildtrees/tgui/x86-windows-dbg/gui-builder/gui-builder.exe F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-6591265fa7/gui-builder/ && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E copy_directory F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-6591265fa7/themes F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-6591265fa7/gui-builder/themes""
LINK Pass 1: command "C:\PROGRA~2\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x86\link.exe gui-builder\CMakeFiles\gui-builder.dir\src\main.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\Form.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\GuiBuilder.cpp.obj /out:gui-builder\gui-builder.exe /implib:gui-builder\gui-builder.lib /pdb:gui-builder\gui-builder.pdb /version:0.0 /machine:X86 /nologo /debug /INCREMENTAL /subsystem:windows lib\tgui-d.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2_ttf.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2d.lib user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib version.lib uuid.lib advapi32.lib setupapi.lib shell32.lib dinput8.lib F:\vcpkg\installed\x86-windows\debug\lib\freetyped.lib F:\vcpkg\installed\x86-windows\debug\lib\manual-link\SDL2maind.lib opengl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:gui-builder\CMakeFiles\gui-builder.dir/intermediate.manifest gui-builder\CMakeFiles\gui-builder.dir/manifest.res" failed (exit code 1120) with the following output:
SDL2maind.lib(SDL_windows_main.c.obj) : error LNK2005: _main already defined in main.cpp.obj
SDL2maind.lib(SDL_windows_main.c.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _main_getcmdline
gui-builder\gui-builder.exe : fatal error LNK1120: 1 unresolved externals
ninja: build stopped: subcommand failed.
After consulting the cmake file, I found that gui-builder
depends on tgui-default-backend-interface
, and tgui-default-backend-interface
depends on tgui-sdl-interface
, and tgui-sdl-interface
depends on SDL2::Main
.
The symbol main
exists in SDL2::Main
, which causes this problem.
Is this a bug or something else?
Thanks.
Thanks for reporting this (and for maintaining the vcpkg package).
I am a bit confused about one thing: the cmake command doesn't specify the SDL backend. Did you clear the build folder before running the command? Unless you change the TGUI_BACKEND variable, the SDL branch should not be executed in cmake and this error shouldn't be possible (the SFML backend is the default one).
The SDL backend hasn't actually been tested on Windows yet. I'll probably have a look at that somewhere this week.
@texus So, we shouldn't pass in TGUI_BACKEND
right?
Correct. You either don't set the variable or you explicitly set it to "SFML". Both will have the same effect.
I didn't realize you were providing options for both backends. My previous answer was assuming you only wanted the SFML backend.
If you want to select the backend then you seem to be doing the correct thing:
- Set TGUI_BACKEND="Custom"
- Set TGUI_HAS_BACKEND_SFML and TGUI_HAS_BACKEND_SFML to TRUE or FALSE depending on which backend(s) you want to build
At least one backend always has to be selected.
I haven't had the chance to test on Windows yet, but I have made a potential fix for the duplicate main function.
Not working after apply a6ae17a changes:
[123/124] cmd.exe /C "cd . && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E vs_link_exe --intdir=gui-builder\CMakeFiles\gui-builder.dir --rc="C:\PROGRA~2\Windows Kits\10\bin\10.0.19041.0\x64\rc.exe" --mt="C:\PROGRA~2\Windows Kits\10\bin\10.0.19041.0\x64\mt.exe" --manifests -- "C:\PROGRA~2\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x86\link.exe" gui-builder\CMakeFiles\gui-builder.dir\src\main.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\Form.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\GuiBuilder.cpp.obj /out:gui-builder\gui-builder.exe /implib:gui-builder\gui-builder.lib /pdb:gui-builder\gui-builder.pdb /version:0.0 /machine:X86 /nologo /debug /INCREMENTAL /subsystem:windows lib\tgui-d.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2_ttf.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2d.lib user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib version.lib uuid.lib advapi32.lib setupapi.lib shell32.lib dinput8.lib F:\vcpkg\installed\x86-windows\debug\lib\freetyped.lib F:\vcpkg\installed\x86-windows\debug\lib\manual-link\SDL2maind.lib opengl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D F:\vcpkg\buildtrees\tgui\x86-windows-dbg\gui-builder && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E copy F:/vcpkg/buildtrees/tgui/x86-windows-dbg/gui-builder/gui-builder.exe F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-cde739737e/gui-builder/ && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E copy_directory F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-cde739737e/themes F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-cde739737e/gui-builder/themes""
FAILED: gui-builder/gui-builder.exe
cmd.exe /C "cd . && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E vs_link_exe --intdir=gui-builder\CMakeFiles\gui-builder.dir --rc="C:\PROGRA~2\Windows Kits\10\bin\10.0.19041.0\x64\rc.exe" --mt="C:\PROGRA~2\Windows Kits\10\bin\10.0.19041.0\x64\mt.exe" --manifests -- "C:\PROGRA~2\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x86\link.exe" gui-builder\CMakeFiles\gui-builder.dir\src\main.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\Form.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\GuiBuilder.cpp.obj /out:gui-builder\gui-builder.exe /implib:gui-builder\gui-builder.lib /pdb:gui-builder\gui-builder.pdb /version:0.0 /machine:X86 /nologo /debug /INCREMENTAL /subsystem:windows lib\tgui-d.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2_ttf.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2d.lib user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib version.lib uuid.lib advapi32.lib setupapi.lib shell32.lib dinput8.lib F:\vcpkg\installed\x86-windows\debug\lib\freetyped.lib F:\vcpkg\installed\x86-windows\debug\lib\manual-link\SDL2maind.lib opengl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D F:\vcpkg\buildtrees\tgui\x86-windows-dbg\gui-builder && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E copy F:/vcpkg/buildtrees/tgui/x86-windows-dbg/gui-builder/gui-builder.exe F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-cde739737e/gui-builder/ && F:\vcpkg\downloads\tools\cmake-3.19.2-windows\cmake-3.19.2-win32-x86\bin\cmake.exe -E copy_directory F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-cde739737e/themes F:/vcpkg/buildtrees/tgui/src/0aa7c449e1-cde739737e/gui-builder/themes""
LINK Pass 1: command "C:\PROGRA~2\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x86\link.exe gui-builder\CMakeFiles\gui-builder.dir\src\main.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\Form.cpp.obj gui-builder\CMakeFiles\gui-builder.dir\src\GuiBuilder.cpp.obj /out:gui-builder\gui-builder.exe /implib:gui-builder\gui-builder.lib /pdb:gui-builder\gui-builder.pdb /version:0.0 /machine:X86 /nologo /debug /INCREMENTAL /subsystem:windows lib\tgui-d.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2_ttf.lib F:\vcpkg\installed\x86-windows\debug\lib\SDL2d.lib user32.lib gdi32.lib winmm.lib imm32.lib ole32.lib oleaut32.lib version.lib uuid.lib advapi32.lib setupapi.lib shell32.lib dinput8.lib F:\vcpkg\installed\x86-windows\debug\lib\freetyped.lib F:\vcpkg\installed\x86-windows\debug\lib\manual-link\SDL2maind.lib opengl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:gui-builder\CMakeFiles\gui-builder.dir/intermediate.manifest gui-builder\CMakeFiles\gui-builder.dir/manifest.res" failed (exit code 1120) with the following output:
SDL2maind.lib(SDL_windows_main.c.obj) : error LNK2005: _main already defined in main.cpp.obj
SDL2maind.lib(SDL_windows_main.c.obj) : error LNK2019: unresolved external symbol _SDL_main referenced in function _main_getcmdline
gui-builder\gui-builder.exe : fatal error LNK1120: 1 unresolved externals
ninja: build stopped: subcommand failed.
My fix was indeed slightly wrong. I've updated the code in 7b1a592 and tested it myself. It should work now.
I confirm it works, thanks!