QuoteI now have an issue with the example for the SFML backend, encountering an undefined reference to the bool runExample(tgui::BackendGui& gui) function.
bool runExample(tgui::BackendGui& gui)
{
return true;
}
Quote from: texus on 27 March 2024, 19:28:51The library name passed to "target_link_libraries" should be either "TGUI::TGUI" (recommended)
#include <TGUI/TGUI.hpp>
#include <TGUI/Backend/SFML-Graphics.hpp>
int main()
{
}
[main] Building folder: AutoBackupScript2
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/build --config Debug --target all -j 6 --
[build] [ 77%] Built target tgui
[build] [ 81%] Building CXX object CMakeFiles/AutoBackupScript.dir/src/main.cpp.obj
[build] [ 96%] Built target gui-builder
[build] [100%] Linking CXX executable AutoBackupScript.exe
[build] C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\AutoBackupScript.dir/objects.a(main.cpp.obj): in function `main':
[build] C:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/src/main.cpp:41: undefined reference to `runExample(tgui::BackendGui&)'
[build] collect2.exe: error: ld returned 1 exit status
[build] mingw32-make[2]: *** [CMakeFiles\AutoBackupScript.dir\build.make:108: AutoBackupScript.exe] Error 1
[build] mingw32-make[1]: *** [CMakeFiles\Makefile2:132: CMakeFiles/AutoBackupScript.dir/all] Error 2
[build] mingw32-make: *** [Makefile:135: all] Error 2
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/build --config Debug --target all -j 6 -- exited with code: 2
[driver] Build completed: 00:00:05.274
[build] Build finished with exit code 2
Quote from: texus on 27 March 2024, 19:28:51The cmake command that is being executed has "-j 6" in it. Is this something you can change yourself? The log output would have been more clear if you ran it with "-j 1" (which you should only do when investigating an issue, as usually you do want to build with more threads). Now it builds your project and the gui builder at the same time so it prints both outputs interleaved and it isn't clear that the error is about your project and not the gui builder.
[main] Building folder: AutoBackupScript2
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/build --config Debug --target all -j 6 --
[build] [ 3%] Linking CXX executable AutoBackupScript.exe
[build] [ 81%] Built target tgui
[build] C:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lTGUI: No such file or directory
[build] collect2.exe: error: ld returned 1 exit status
[build] mingw32-make[2]: *** [CMakeFiles\AutoBackupScript.dir\build.make:104: AutoBackupScript.exe] Error 1
[build] mingw32-make[1]: *** [CMakeFiles\Makefile2:132: CMakeFiles/AutoBackupScript.dir/all] Error 2
[build] mingw32-make[1]: *** Waiting for unfinished jobs....
[build] [ 96%] Built target gui-builder
[build] mingw32-make: *** [Makefile:135: all] Error 2
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/build --config Debug --target all -j 6 -- exited with code: 2
[driver] Build completed: 00:00:00.913
[build] Build finished with exit code 2
tgui::Font font;
font = tgui::Font("font.ttf");
tgui::Font font;
font.getBackendFont()->loadFromFile("font.ttf");
but this leads to a segmentation fault. Are there any ways to do what I intend to do?QuoteThe source directory is being set to the "TGUI" subdirectory, but the build directory is the one from your project? That would mean that it is trying to build TGUI and your own cmake script isn't even being executed.
cmake_minimum_required(VERSION 3.17)
project(AutoBackupScript VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
include_directories(headers)
add_subdirectory(TGUI)
# Füge die Quelldateien hinzu
set(SOURCES
src/main.cpp
)
# Füge das ausführbare Ziel hinzu und verlinke ImGui
add_executable(AutoBackupScript ${SOURCES})
set(TGUI_DIR "C:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/TGUI/cmake")
find_package(TGUI 1 REQUIRED)
target_link_libraries(AutoBackupScript PRIVATE TGUI)
# Suche und verlinke SFML
set(SFML_DIR "c:/SFML/lib/cmake/SFML") # Pfad zum SFML CMake-Modul
find_package(SFML COMPONENTS system window graphics network audio REQUIRED)
if (SFML_FOUND)
target_link_libraries(AutoBackupScript PRIVATE sfml-system sfml-window sfml-graphics sfml-network sfml-audio)
endif()
# Kopiere DLLs in das Build-Verzeichnis
if(WIN32)
file(GLOB BINARY_DEP_DLLS "c:/SFML/bin/*.dll")
file(COPY ${BINARY_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
file(GLOB MINGW_DEP_DLLS "C:/mingw64/bin/*.dll")
file(COPY ${MINGW_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
endif()
[main] Building folder: AutoBackupScript2
[build] Starting build
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/build --config Debug --target all -j 6 --
[build]
[build] Searching for SFML 2...
[build]
[build] -- Could NOT find SFML (missing: SFML_DIR)
[build]
[build] Searching for SFML 3...
[build]
[build] -- Could NOT find SFML (missing: SFML_DIR)
[build] CMake Error at TGUI/cmake/Dependencies.cmake:80 (message):
[build] CMake couldn't find SFML.
[build]
[build] Set SFML_DIR to the directory containing SFMLConfig.cmake (usually
[build] something like SFML_ROOT/lib/cmake/SFML)
[build]
[build] Call Stack (most recent call first):
[build] TGUI/cmake/Dependencies.cmake:93 (tgui_find_dependency_sfml)
[build] TGUI/src/Backend/CMakeLists.txt:153 (tgui_add_dependency_sfml)
[build] TGUI/src/CMakeLists.txt:305 (include)
[build]
[build]
[build] -- Configuring incomplete, errors occurred!
[build] mingw32-make: *** [Makefile:178: cmake_check_build_system] Error 1
[proc] The command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/build --config Debug --target all -j 6 -- exited with code: 2
[driver] Build completed: 00:00:00.482
[build] Build finished with exit code 2
Quote[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\mingw64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\mingw64\bin\g++.exe -SC:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/TGUI -Bc:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/build -G "MinGW Makefiles"