Rayen Marino
Rayen Marino

Reputation: 11

TGUI Using raylib backend with cmake

I'm currently using raylib 5.5 and TGUI 1.6.1 and using msys2 to manage package. Both TGUI (with SFML backend) and raylib worked fine independently. I turn TGUI_HAS_BACKEND_RAYLIB to TRUE and trying to use raylib as backend. And when I try to build the offical code, I got these errors:

[main] Building folder: f:/Code Workplace/Chatter/raylibexample/build 
[build] Starting build
[proc] Executing command: "C:\Program Files\Environment\CMake\bin\cmake.EXE" --build "f:/Code Workplace/Chatter/raylibexample/build" --config Debug --target all -j 30 --
[build] [ 50%] Linking CXX executable MyRaylibApp.exe
[build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\MyRaylibApp.dir/objects.a(main.cpp.obj): in function `run_application()':
[build] F:/Code Workplace/Chatter/raylibexample/main.cpp:6:(.text+0x1b): undefined reference to `__imp__ZN4tgui6RAYLIB3GuiC1Ev'
[build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: F:/Code Workplace/Chatter/raylibexample/main.cpp:7:(.text+0x6a): undefined reference to `__imp__ZN4tgui16BackendGuiRaylib8mainLoopENS_5ColorE'
[build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\MyRaylibApp.dir/objects.a(main.cpp.obj): in function `tgui::RAYLIB::Gui::~Gui()':
[build] D:/msys64/mingw64/include/TGUI/Backend/raylib.hpp:51:(.text$_ZN4tgui6RAYLIB3GuiD1Ev[_ZN4tgui6RAYLIB3GuiD1Ev]+0xf): undefined reference to `__imp__ZTVN4tgui6RAYLIB3GuiE'
[build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: D:/msys64/mingw64/include/TGUI/Backend/raylib.hpp:51:(.text$_ZN4tgui6RAYLIB3GuiD1Ev[_ZN4tgui6RAYLIB3GuiD1Ev]+0x28): undefined reference to `__imp__ZN4tgui16BackendGuiRaylibD2Ev'
[build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\MyRaylibApp.dir/objects.a(main.cpp.obj):main.cpp:(.rdata$_ZTVN4tgui6RAYLIB3GuiE[_ZTVN4tgui6RAYLIB3GuiE]+0x28): undefined reference to `tgui::BackendGuiRaylib::mainLoop(tgui::Color)'
[build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\MyRaylibApp.dir/objects.a(main.cpp.obj):main.cpp:(.rdata$_ZTVN4tgui6RAYLIB3GuiE[_ZTVN4tgui6RAYLIB3GuiE]+0x40): undefined reference to `tgui::BackendGuiRaylib::updateTextCursorPosition(tgui::Rect<float>, tgui::Vector2<float>)'
[build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\MyRaylibApp.dir/objects.a(main.cpp.obj):main.cpp:(.rdata$_ZTVN4tgui6RAYLIB3GuiE[_ZTVN4tgui6RAYLIB3GuiE]+0x48): undefined reference to `tgui::BackendGuiRaylib::isKeyboardModifierPressed(tgui::Event::KeyModifier) const'
[build] D:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\MyRaylibApp.dir/objects.a(main.cpp.obj):main.cpp:(.rdata$_ZTVN4tgui6RAYLIB3GuiE[_ZTVN4tgui6RAYLIB3GuiE]+0x50): undefined reference to `tgui::BackendGuiRaylib::updateContainerSize()'
[build] collect2.exe: error: ld returned 1 exit status
[build] mingw32-make[2]: *** [CMakeFiles\MyRaylibApp.dir\build.make:103: MyRaylibApp.exe] Error 1
[build] mingw32-make[1]: *** [CMakeFiles\Makefile2:82: CMakeFiles/MyRaylibApp.dir/all] Error 2
[build] mingw32-make: *** [Makefile:90: all] Error 2
[proc] The command: "C:\Program Files\Environment\CMake\bin\cmake.EXE" --build "f:/Code Workplace/Chatter/raylibexample/build" --config Debug --target all -j 30 -- exited with code: 2
[driver] Build completed: 00:00:00.604
[build] Build finished with exit code 2

The cmakelists.txt I used:

cmake_minimum_required(VERSION 3.10)
project(MyRaylibApp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++ -static")
set(CMAKE_PREFIX_PATH "D:/msys64/mingw64")
find_package(raylib REQUIRED)
find_package(TGUI 1.6.1 REQUIRED)
set(TGUI_BACKEND RAYLIB)
set(TGUI_USE_RAYLIB TRUE)
set(TGUI_USE_SFML FALSE) 

add_executable(MyRaylibApp main.cpp)
set(raylib_ROOT "D:/msys64/mingw64")

target_link_libraries(MyRaylibApp PRIVATE raylib TGUI::TGUI)

set_target_properties(MyRaylibApp PROPERTIES CXX_STANDARD 11)

Also I turn #define TGUI_HAS_BACKEND_RAYLIB to 1 in TGUI/Config.hpp

Upvotes: 1

Views: 16

Answers (0)

Related Questions