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"
Quote from: texus on 26 March 2024, 08:40:15The set(SFML_DIR "c:/SFML/lib/cmake/SFML") should be sufficient when placed before the find_package or add_subdirectory line.
TGUI tries to find SFML with "find_package(SFML 2 CONFIG COMPONENTS graphics REQUIRED)".
- Which files does c:/SFML/lib/cmake/SFML contain?
- Which SFML version is located in c:/SFML?
- Did you build SFML yourself or download a precompiled version from their website?
- Which MinGW version are you using?
[main] Building folder: AutoBackupScript2
[main] Configuring project: AutoBackupScript2
[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"
[cmake] Not searching for unused variables given on the command line.
[cmake]
[cmake] Searching for SFML 2...
[cmake]
[cmake] -- Could NOT find SFML (missing: SFML_DIR)
[cmake]
[cmake] Searching for SFML 3...
[cmake]
[cmake] -- Could NOT find SFML (missing: SFML_DIR)
[cmake] CMake Error at cmake/Dependencies.cmake:80 (message):
[cmake] CMake couldn't find SFML.
[cmake]
[cmake] Set SFML_DIR to the directory containing SFMLConfig.cmake (usually
[cmake] something like SFML_ROOT/lib/cmake/SFML)
[cmake]
[cmake] Call Stack (most recent call first):
[cmake] cmake/Dependencies.cmake:93 (tgui_find_dependency_sfml)
[cmake] src/Backend/CMakeLists.txt:153 (tgui_add_dependency_sfml)
[cmake] src/CMakeLists.txt:305 (include)
[cmake]
[cmake]
[cmake] -- Configuring incomplete, errors occurred!
[proc] The 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" exited with code: 1
Project/
├── CMakeLists.txt (Main project)
├── src/
│ └── main.cpp
└── TGUI/
cmake_minimum_required(VERSION 3.17)
project(AutoBackupScript VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
# Füge die Quelldateien hinzu
set(SOURCES
src/main.cpp
)
include_directories(headers)
# Füge das ausführbare Ziel hinzu und verlinke ImGui
add_executable(AutoBackupScript ${SOURCES})
#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()
#target_link_libraries(AutoBackupScript PRIVATE TGUI)
set(SFML_DIR "c:/SFML/lib/cmake/SFML")
#include_directories(${CMAKE_SOURCE_DIR}/TGUI)
#include_directories(${CMAKE_SOURCE_DIR})
#add_subdirectory(TGUI)
#find_package(TGUI 1 REQUIRED)
#target_link_libraries(AutoBackupScript PRIVATE TGUI::TGUI)
# 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()
Quote from: texus on 25 March 2024, 18:24:54all TGUI widgets need to be destroyed before the Gui object is destroyed.Oh, that's it. I swapped two lines in the code (see below) and it settled the matter, thank you!
//How it was:
Scene scene;
tgui::Gui gui;
//How it is now:
tgui::Gui gui;
Scene scene;
class Scene
{
public:
std::list<tgui::Group::Ptr> groups;
private:
using iterator = std::list<tgui::Group::Ptr>::iterator;
iterator current_group;
void change_scene(iterator &from, iterator &to);
};
scene.groups.emplace_back(tgui::Group::create());
//Some widgets initialization and adding them to the group
gui.add(scene.groups.begin());
It works pretty nice until I close the program (and ~Scene() is called) and get Seg fault message. I've attached the picture from the debugger.bool linked = 1;
tgui::Texture link_t[2];
for (short i = 0; i < 2; ++i)
link_t[i].load("lu.png", {unsigned(50 * i), 0, 50, 50});
auto link_b = gui.get<tgui::Button>("link_b");
auto lb_func = [&link_b, &linked, &link_t]()
{
linked = !linked;
link_b->getRenderer()->setTexture(link_t[linked]);
};
gui.get<tgui::Button>("link_b")->onClick(lb_func);
It's expected the texture to be changed every time I click the button, but actually it changes only once. bool linked = 1;
tgui::Texture linked_t, unlinked_t;
linked_t.load("linked.png");
unlinked_t.load("unlinked.png");
auto link_b = gui.get<tgui::Button>("link_b");
if (linked)
link_b->getRenderer()->setTexture(linked_t);
else
link_b->getRenderer()->setTexture(unlinked_t);
auto lb_func = [&link_b, &linked, &linked_t, &unlinked_t]()
{
linked = !linked;
if (linked)
link_b->getRenderer()->setTexture(linked_t);
else
link_b->getRenderer()->setTexture(unlinked_t);
};
gui.get<tgui::Button>("link_b")->onClick(lb_func);
And it works pretty good! I think the problem that my first piece of code uses the textures with the same ID. Perhaps, that's the reason why setTexture() doesn't change the texture.