Main Menu

Recent posts

#31
Installation help / Re: CMake cannot find SFML
Last post by luka - 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()

#32
Installation help / Re: CMake cannot find SFML
Last post by texus - 29 March 2024, 08:29:09
I'm not sure how much I can help with this issue.

One thing you could still try is to use the precompiled TGUI libraries for MinGW 64bit instead of building them yourself, although I doubt that it will solve anything.

Have you tried reinstalling the latest Microsoft Visual C++ Redistributable version just to be sure?

Could you create a zip file with the exe, SFML dlls, TGUI dll and the 3 gcc dlls that I mentioned in my previous post and send those to me? Then I can try testing if I find anything weird with it.
Could you also post the current CMake script that you are using? Maybe I can try building the same way here and see if I can reproduce it or not.
#33
Installation help / Re: CMake cannot find SFML
Last post by luka - 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.
#34
Installation help / Re: CMake cannot find SFML
Last post by texus - 28 March 2024, 19:28:05
0xc000012f 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.

Is the bin directory of your MinGW compiler in your PATH environment variable?
Just to be safe, can you copy libgcc_s_seh-1.dll, libstdc++-6.dll and libwinpthread-1.dll from "C:\mingw64\bin\" and place them next to your exe?
#35
Installation help / Re: CMake cannot find SFML
Last post by luka - 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).
#36
Installation help / Re: CMake cannot find SFML
Last post by texus - 28 March 2024, 18:32:01
Somewhere inside your "c:/Users/luka-/OneDrive/Desktop/AutoBackupScript2/build" folder. Probably inside the "TGUI/lib/Debug" subdirectory.

There is a way to let CMake automatically copy the dll when building. Try adding the following to your cmake script: (I didn't test this so it might not work as-is)
Code (cmake) Select
add_custom_command(
    TARGET AutoBackupScript POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:tgui>" "."
    VERBATIM)
#37
Installation help / Re: CMake cannot find SFML
Last post by luka - 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?
#38
Installation help / Re: CMake cannot find SFML
Last post by texus - 28 March 2024, 08:39:33
QuoteCould I be overlooking something, such as copying .dll files or a similar requirement?
It'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?

I don't really know VS Code. Do you have some process output somewhere? If the program crashes then it usually sets a return value other than 0. If you find some output with something similar to "program exited with code ..." then you can usually search online for that code to determine whether it ended due to a missing dll, an access violation or an uncaught exception.

There are 2 things you can test:
1) Run the exe from file explorer instead of from the IDE. If it won't run due to a missing dll, you will get an error when attempting to run the exe like that.
2) If something goes wrong in TGUI (e.g. a file can't be loaded), then it will throw an exception. If you don't catch this exception then the program terminates.

Do something like this in the main function to print something to the command line when an exception occurs, so that you can see what went wrong. I'm not sure if you will be able to see the text printed somewhere, but you might also be able to e.g. put a breakpoint in the catch code to test if it passes there. The "e.what()" value is a string that contains the TGUI error message.
Code (cpp) Select
int main()
{
    try
    {
        // <Put your existing code here>
        return 0;
    }
    catch (const tgui::Exception& e)
    {
        std::cerr << "TGUI exception: " << e.what() << std::endl;
        return 1;
    }
}
#39
Installation help / Re: CMake cannot find SFML
Last post by luka - 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?
#40
Installation help / Re: CMake cannot find SFML
Last post by luka - 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.