Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - luka

#1
Installation help / Re: CMake cannot find SFML
30 March 2024, 17:29:36
QuoteEDIT: Your dll file isn't even recognized as a valid DLL by the tools that I have to dump dll information.
EDIT 2: The first 1536 bytes (= exactly 3 * 512 bytes) in your DLL are all 0-bytes, so the file looks corrupted. Have you tried deleting the file and letting your cmake project generate it again?

I tried deleting it and copying it with the CMake script, but I still encountered the same error. So, I attempted to locate the file where it's being copied from, but I couldn't find anything. Is it possible that the file is not in the folder and CMake creates it?

Copying the tgui-d.dll from TGUI 1.2.0 works in VS Code and directly from the directory. Thank you very much.
#2
Installation help / Re: CMake cannot find SFML
30 March 2024, 06:21:04
Thank you. I tried reinstalling it, and here's the zip archive. I included the entire build directory to ensure you have everything. The 'CMakeLists.txt' is provided below.


https://www.file2send.eu/de/download/GEhzYpN1BJhd2Y1m0MgbUMYLQyCJkkVeKlb6AedpqskgnzPtTUlKRuBdINyfGF1J

cmake_minimum_required(VERSION 3.17)
project(AutoBackupScript VERSION 0.1.0 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 20)

include_directories(headers)
set(SFML_DIR "c:/SFML/lib/cmake/SFML")  # Pfad zum SFML CMake-Modul
add_subdirectory(TGUI)

# list of source files
set(SOURCES
    #src/main.cpp
    src/ScalableLoginScreen.cpp
)


# add executable
add_executable(AutoBackupScript ${SOURCES})


target_link_libraries(AutoBackupScript PRIVATE TGUI::TGUI)

# searching and linking sfml
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()

add_custom_command(
    TARGET AutoBackupScript POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:tgui>" "."
    VERBATIM)

# copying the Dll files in the build directory
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()

#3
Installation help / Re: CMake cannot find SFML
28 March 2024, 19:44:43
Quote0xc000012f seems to mean that the "Microsoft Visual C++ Redistributable" isn't installed, which is a bit weird in this case. To run any software that was build with Visual Studio, you need to have the redistributable installed for that Visual Studio version. It raises a question though: what code is built with Visual C++? You are building with MinGW, the precompiled SFML libraries were build with MinGW, and TGUI is being build together with your project and also with the MinGW compiler.
It seems like it, but that is super confusing.

They are already in there. My CMake script copies all SFML and MinGW .dll files into the build directory while configuring the project.
#4
Installation help / Re: CMake cannot find SFML
28 March 2024, 19:12:42
The command copied or created the .dll, but the application still crashes. When attempting to start the .exe in the build directory, I now receive an error stating that the file doesn't exist or is not suitable for Windows. Error code: 0xc000012f

In VS Code, the application crashes with the error "Command executed, took 85ms and failed (Exit code 1).
#5
Installation help / Re: CMake cannot find SFML
28 March 2024, 17:28:59
Quote from: texus on 28 March 2024, 08:39:33It's possible, but it's hard to say if you don't actually get an error message. Are the sfml and dll files placed next to the exe?

The SFML .dll files are present, but when attempting to run the .exe directly from the build directory, I receive an error stating that the tgui-d.dll is not found. Where can I find it?
#6
Installation help / Re: CMake cannot find SFML
28 March 2024, 01:05:50
Apologies for bothering you once more. Despite the initial joy of successfully compiling the program, it appears to crash every time I attempt to run it, without any error messages. Could I be overlooking something, such as copying .dll files or a similar requirement?
#7
Installation help / Re: CMake cannot find SFML
27 March 2024, 22:48:56
Quote from: texus on 27 March 2024, 22:45:23
Quoteis that something I should consider in general or is it more something for debugging?

It's only for debugging.
The higher the number, the faster the project will build (as the number indicates how many source files can be compiled simultaneously). At least as long as the number doesn't exceed the amount of CPU threads your processor has (a higher number will work but won't make it faster) and as long as you have sufficient RAM (which becomes important for very high values).
Setting it to 1 means that all operations are done sequentially and nothing is done in parallel. This makes building much slower, but then the logs will properly show you which step is being executed when the error happens.

Good to know. I believe I'll need to delve deeper into CMake to fully utilize it. Thank you very much for your patience and guidance. Everything is functioning now.
#8
Installation help / Re: CMake cannot find SFML
27 March 2024, 20:14:37
Quote from: texus on 27 March 2024, 19:28:51The library name passed to "target_link_libraries" should be either "TGUI::TGUI" (recommended)

I've managed to compile this file now.
#include <TGUI/TGUI.hpp>
#include <TGUI/Backend/SFML-Graphics.hpp>


int main()
{

}

I now have an issue with the example for the SFML backend, encountering an undefined reference to the bool runExample(tgui::BackendGui& gui) function.

[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.

There is a way, is that something I should consider in general or is it more something for debugging?
#9
Installation help / Re: CMake cannot find SFML
27 March 2024, 18:39:47
I deeply appreciate your assistance thus far. Nevertheless, I've encountered a snag with 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

#10
Installation help / Re: CMake cannot find SFML
27 March 2024, 00:07:41
I apologize for any confusion. I am new to CMake, so my knowledge is somewhat limited. I have only used CMake for incorporating SFML into two projects, and you can see how I did that in my CMakeLists.txt files, which compile without any issues. I referred to this blog post (https://www.ics.com/blog/find-and-link-libraries-cmake) to integrate the TGUI library, so I'm having a bit of trouble following your steps.

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.

I tried something different. Here is the orignale Cmakelists.txt:
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()


but i encountered a similar problem.
[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


Thank you for your time and assistance.
#11
Installation help / Re: CMake cannot find SFML
26 March 2024, 21:39:10
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?

Thank you for the prompt response and assistance.

1. alle the cmake files
   - SFMLConfig.cmake
   - SFMLConfigDependencies.cmake
   - SFMLConfigVersion.cmake
   - SFMLSharedTargets.cmake
   - SFMLSharedTargets-debug.cmake
   - SFMLSharedTargets-release.cmake
   - SFMLStaticTargets.cmake
   - SFMLStaticTargets-debug.cmake
   - SFMLStaticTargets-release.cmake
2. SFML 2.6.0 is installed
3. I downloaded a precompiled version from their website.
4. I am using GCC 13.1.0 MinGW 64-bit
#12
Installation help / CMake cannot find SFML
26 March 2024, 06:27:21
Hello, I'm currently trying to integrate TGUI into my SFML project. I'm using CMake and VS Code, but I've encountered a problem where TGUI can't find SFML. I have the error message ready here, which mentions setting the SFML_DIR, but I'm not sure exactly where to do that. Any help would be greatly appreciated.

[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


I have integrated TGUI into my project as follows:

Project/
├── CMakeLists.txt (Main project)
├── src/
│  └── main.cpp
└── TGUI/

and SFML is not directly in the project folder, but it usually finds it after setting the SFML_DIR.

My CMakeLists.txt from the main project:

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()