Welcome, Guest. Please login or register. Did you miss your activation email?

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.


Messages - ChocolatePinecone

Pages: [1]
1
Solved it ! :D

I startes messing around with the lib directory and eventually found out the "SFMLSharedTargets-relwithdebinfo.cmake" was missing.
I built it from the SFML repo and added it to the "lib/cmake/SFML" directory.
Now the SFML release library build is linked to the RelWithDebInfo build and it does no longer look for the debug dlls.

On a sidenote I have been able to reproduce the "release only" bug and finally found the source because the build now has symbols.
Yay!

2
Hey all! I'm getting desperate trying to get a RelWithDebInfo build working...

Some context:
I've released a pre-alpha demo to my Discord community and have since been very busy hunting bugs.
I now found a couple of bugs that apparently only appear in a Release build and not in the Debug build.
Since the Release build does not contain any symbol data, I cannot find the source of these bugs.

Theoretically I figured building with RelWithDebInfo should provide a optimized release build that DOES contain symbol data and allows me to at least see where the error is coming from.

The problem:

When running the game after building with RelWithDebInfo and using the debug dlls, I get a weird error from within the dll I believe: "Stack cookie instrumentation code detected a stack-based buffer overrun."

When using the release dlls, I get an error about missing the needed debug dlls, so apparently it is still expecting debug dlls when building with RelWithDebInfo, which seems odd to me.

I'm using the pre-built dlls from the SFML download page.

I'm unclear if either Debug or Release dlls should be used when building with RelWithDebInfo.

Things I've tried without success:

  • Manually building dlls from the SFML master branch with the RelWithDebInfo setting (results in release dlls that are bigger than the regular release dlls) - Afterward renaming these to be picked up as debug dlls

My CmakeLists (DEBUG_MODE is only used for copying the right dlls):

Code: [Select]
cmake_minimum_required(VERSION 3.10)

# Set the project name and version
project(Rocket-Shipment)

# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Set project variables
set(VERSION_DESC \"PRE-ALPHA-DEMO\")
set(VERSION_MAJOR 0)
set(VERSION_MINOR 0)
set(VERSION_PATCH \"3\")
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
set(DEBUG_MODE true)
message(STATUS "Set debug mode on")
else()
set(DEBUG_MODE false)
message(STATUS "Set debug mode off")
endif()

# Set OS specific variables
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
set(SFML_DIR "SFML-2.5.1-win/lib/cmake/SFML")
set(OPENBROWSERCMD \"start\")
set(WINDOWS true)
message(STATUS "Set variables for Windows")
else()
set(SFML_DIR "SFML-2.5.1-linux/lib")
set(SFML_INCLUDE_DIR "SFML-2.5.1-linux/include")
set(SFML_LIBRARY_DIR "SFML-2.5.1-linux/lib")
link_directories(SFML_LIBRARY_DIR)
include_directories(SFML_INCLUDE_DIR)
set(OPENBROWSERCMD \"xdg-open\")
set(WINDOWS false)
message(STATUS "Set variables for Linux")
endif()

configure_file(
"${PROJECT_SOURCE_DIR}/BuildConfig.h.in"
"${PROJECT_BINARY_DIR}/BuildConfig.h"
)

# Find SFML
find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED)
if(SFML_FOUND)
message(STATUS "SFML_INCLUDE_DIR: ${SFML_INCLUDE_DIR}")
message(STATUS "SFML_LIBRARIES: ${SFML_LIBRARIES}")
message(STATUS "SFML_VERSION: ${SFML_VERSION}")
else()
message(FATAL_ERROR "SFML couldn't be located!")
endif()

# Add the binary tree to the search path for include files
# so that we will find BuildConfig.h
include_directories("${PROJECT_BINARY_DIR}")

# Define sources and executable
set(EXECUTABLE_NAME "Rocket-Shipment")
FILE(GLOB_RECURSE SRCFILES src/*.cpp src/*.h)

# Copy OS specific data
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
set(SFML_DLLS "SFML-2.5.1-win/bin")
if(DEBUG_MODE)
file(COPY ${SFML_DLLS}/sfml-audio-d-2.dll ${SFML_DLLS}/sfml-graphics-d-2.dll ${SFML_DLLS}/sfml-window-d-2.dll ${SFML_DLLS}/sfml-system-d-2.dll ${SFML_DLLS}/openal32.dll DESTINATION .)
message(STATUS "Added debug dlls to build directory")
else()
file(COPY ${SFML_DLLS}/sfml-audio-2.dll ${SFML_DLLS}/sfml-graphics-2.dll ${SFML_DLLS}/sfml-window-2.dll ${SFML_DLLS}/sfml-system-2.dll ${SFML_DLLS}/openal32.dll DESTINATION .)
message(STATUS "Added release dlls to build directory")
endif()
else()
# Copy needed linux package files
FILE(COPY TROUBLESHOOTING.txt DESTINATION .)
FILE(COPY ${SFML_LIBRARY_DIR} DESTINATION .)
FILE(COPY run.sh DESTINATION .)
endif()

# Copy game data folder
FILE(COPY data/ DESTINATION data/)

# Create empty custom level directory
set(CUSTOM_LEVELS "custom-levels")
FILE(MAKE_DIRECTORY ${CUSTOM_LEVELS})
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CUSTOM_LEVELS})
message(STATUS "Create custom level directory")

if(DEBUG_MODE OR NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows)
add_executable(${EXECUTABLE_NAME} Main.cpp ${SRCFILES})
message(STATUS "Create normal executable")
elseif(${CMAKE_SYSTEM_NAME} MATCHES Windows)
add_executable(${EXECUTABLE_NAME} WIN32 Main.cpp ${SRCFILES} icon.rc)
message(STATUS "Create windows executable without console window")
endif()

# Add OS specific libraries
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
target_link_libraries(${EXECUTABLE_NAME} dbghelp)
else()
target_link_libraries(${EXECUTABLE_NAME} stdc++fs)
endif()

# Add SFML
target_link_libraries(${EXECUTABLE_NAME} sfml-audio sfml-graphics sfml-window sfml-system)
message(STATUS "Added SFML")

3
General / Re: Linker errors with CMake project
« on: March 05, 2020, 08:42:30 am »
After some experimenting with tutorials I solved the problem!

I was using the pre-built version 2.5.0 of SFML downloaded from the SFML downloads page.
I changed this by using 2.5.1 which I built myself using the latest version from the git repo.

I also changed my CMakeLists file to this:

Quote
cmake_minimum_required(VERSION 3.10)

# Set the project name and version
project(Rocket-Shipment)

# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Set project variables
set(VERSION_DESC \"ALPHA-DEMO\")
set(VERSION_MAJOR 0)
set(VERSION_MINOR 0)
set(VERSION_PATCH 1)
if(CMAKE_BUILD_TYPE MATCHES Debug)
   set(DEBUG_MODE true)
   message(STATUS "Set debug mode on")
else()
   set(DEBUG_MODE false)
   message(STATUS "Set debug mode off")
endif()

# Set OS specific variables
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
   set(SFML_DIR "SFML-2.5.0-win/lib/cmake/SFML")
   set(OPENBROWSERCMD \"start\")
   set(WINDOWS true)
   message(STATUS "Set variables for Windows")
else()
   set(SFML_DIR "SFML-2.5.1-linux/lib/cmake/SFML")
   set(SFML_INCLUDE_DIR "SFML-2.5.1-linux/include")
   set(SFML_LIBRARY_DIR "SFML-2.5.1-linux/lib")
   link_directories(SFML_LIBRARY_DIR)
   include_directories(SFML_INCLUDE_DIR)
   set(OPENBROWSERCMD \"xdg-open\")
   set(WINDOWS false)
   message(STATUS "Set variables for Linux")
endif()

configure_file(
   "${PROJECT_SOURCE_DIR}/BuildConfig.h.in"
   "${PROJECT_BINARY_DIR}/BuildConfig.h"
)

# Find SFML
find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED)
if(SFML_FOUND)
   message(STATUS "SFML_INCLUDE_DIR: ${SFML_INCLUDE_DIR}")
   message(STATUS "SFML_LIBRARIES: ${SFML_LIBRARIES}")
   message(STATUS "SFML_VERSION: ${SFML_VERSION}")
else()
   message(FATAL_ERROR "SFML couldn't be located!")
endif()

# Add the binary tree to the search path for include files
# so that we will find BuildConfig.h
include_directories("${PROJECT_BINARY_DIR}")

# Define sources and executable
set(EXECUTABLE_NAME "Rocket-Shipment")
FILE(GLOB_RECURSE SRCFILES src/*.cpp src/*.h)

# Copy OS specific data
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
   set(SFML_DLLS "SFML-2.5.0-win/bin")
   if(DEBUG_MODE)
      file(COPY ${SFML_DLLS}/sfml-audio-d-2.dll ${SFML_DLLS}/sfml-graphics-d-2.dll ${SFML_DLLS}/sfml-window-d-2.dll ${SFML_DLLS}/sfml-system-d-2.dll ${SFML_DLLS}/openal32.dll DESTINATION .)
      message(STATUS "Added debug dlls to build directory")
   else()
      file(COPY ${SFML_DLLS}/sfml-audio-2.dll ${SFML_DLLS}/sfml-graphics-2.dll ${SFML_DLLS}/sfml-window-2.dll ${SFML_DLLS}/sfml-system-2.dll ${SFML_DLLS}/openal32.dll DESTINATION .)
      message(STATUS "Added release dlls to build directory")
   endif()
endif()

# Copy game data folder
FILE(COPY data/ DESTINATION data/)

if(DEBUG_MODE OR NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows)
   add_executable(${EXECUTABLE_NAME} Main.cpp ${SRCFILES})
   message(STATUS "Create normal executable")
elseif(${CMAKE_SYSTEM_NAME} MATCHES Windows)
   add_executable(${EXECUTABLE_NAME} WIN32 Main.cpp ${SRCFILES})
   message(STATUS "Create windows executable without console window")
endif()

# Add filesystem library
target_link_libraries(${EXECUTABLE_NAME} stdc++fs)

# Add SFML
target_link_libraries(${EXECUTABLE_NAME} sfml-audio sfml-graphics sfml-window sfml-system)
message(STATUS "Added SFML")

This solved the issue for me, including a linker issue with the filesystem of the std lib.

4
General / [SOLVED] Linker errors with CMake project
« on: March 03, 2020, 05:05:58 pm »
Hey all,

I've googled my ass off and tried anything I found relevant both inside and outside this forum, but cannot seem to find a solution.

Some context:
I've converted the build setup of my big project to use CMake. This worked nicely with Visual Studio I'm using on Windows.
However, I'm exploring how to make a Linux build by trying to compile the project on Ubuntu. After ironing out some issues, I've been stuck for the past few hours trying to get my building to work.
I'm still pretty new with CMake and am probably missing something.

I'm using seperate downloaded SFML directories for the windows and linux builds.
Both directories are the already built versions of SFML, not the source code.

Currently the actual compiling is succeeding, but the linker is throwing errors:

Quote
[  1%] Linking CXX executable Rocket-Shipment
CMakeFiles/Rocket-Shipment.dir/src/engine/RocketEngine.cpp.o: In function `re::RocketEngine::setMainFont(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
RocketEngine.cpp:(.text+0x15f): undefined reference to `sf::Font::loadFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
CMakeFiles/Rocket-Shipment.dir/src/engine/RocketEngine.cpp.o: In function `re::RocketEngine::changeWindowResolution(sf::VideoMode, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool)':
RocketEngine.cpp:(.text+0x36a): undefined reference to `sf::String::String(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::locale const&)'
RocketEngine.cpp:(.text+0x42c): undefined reference to `sf::String::String(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::locale const&)'
CMakeFiles/Rocket-Shipment.dir/src/engine/audio/MusicManager.cpp.o: In function `re::MusicManager::playNextSong()':
MusicManager.cpp:(.text+0x1ca): undefined reference to `sf::Music::openFromFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Etc, etc, etc.

My makefile:
Quote
cmake_minimum_required(VERSION 3.10)

# Set the project name and version
project(Rocket-Shipment)

# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Set project variables
set(VERSION_DESC \"ALPHA-DEMO\")
set(VERSION_MAJOR 0)
set(VERSION_MINOR 0)
set(VERSION_PATCH 1)
if(CMAKE_BUILD_TYPE MATCHES Debug)
   set(DEBUG_MODE true)
   message("Debug mode on")
else()
   set(DEBUG_MODE false)
   message("Debug mode off")
endif()

# Set OS specific variables
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
   set(SFML_DIR "SFML-2.5.0-win/lib/cmake/SFML")
   set(OPENBROWSERCMD \"start\")
   set(WINDOWS true)
   message("Set variables for Windows")
else()
   set(SFML_DIR "SFML-2.5.0-linux/lib/cmake/SFML")
   set(OPENBROWSERCMD \"xdg-open\")
   set(WINDOWS false)
   message("Set variables for Linux")
endif()

configure_file(
   "${PROJECT_SOURCE_DIR}/BuildConfig.h.in"
   "${PROJECT_BINARY_DIR}/BuildConfig.h"
)

# Find SFML
find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED)
if(NOT SFML_FOUND)
  message(FATAL_ERROR "SFML couldn't be located!")
endif()

# Add the binary tree to the search path for include files
# so that we will find BuildConfig.h
include_directories("${PROJECT_BINARY_DIR}")

# Define sources and executable
set(EXECUTABLE_NAME "Rocket-Shipment")
FILE(GLOB_RECURSE SRCFILES src/*.cpp src/*.h)

# Copy OS specific data
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
   set(SFML_DLLS "SFML-2.5.0-win/bin")
   if(DEBUG_MODE)
      file(COPY ${SFML_DLLS}/sfml-audio-d-2.dll ${SFML_DLLS}/sfml-graphics-d-2.dll ${SFML_DLLS}/sfml-window-d-2.dll ${SFML_DLLS}/sfml-system-d-2.dll ${SFML_DLLS}/openal32.dll DESTINATION .)
      message("Added debug dlls to build directory")
   else()
      file(COPY ${SFML_DLLS}/sfml-audio-2.dll ${SFML_DLLS}/sfml-graphics-2.dll ${SFML_DLLS}/sfml-window-2.dll ${SFML_DLLS}/sfml-system-2.dll ${SFML_DLLS}/openal32.dll DESTINATION .)
      message("Added release dlls to build directory")
   endif()
endif()

# Copy game data folder
FILE(COPY data/ DESTINATION data/)

if(DEBUG_MODE OR NOT ${CMAKE_SYSTEM_NAME} MATCHES Windows)
   add_executable(${EXECUTABLE_NAME} Main.cpp ${SRCFILES})
   message("Create normal executable")
elseif(${CMAKE_SYSTEM_NAME} MATCHES Windows)
   add_executable(${EXECUTABLE_NAME} WIN32 Main.cpp ${SRCFILES})
   message("Create windows executable without console window")
endif()

# Add SFML
#include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(${EXECUTABLE_NAME} sfml-audio sfml-graphics sfml-window sfml-system)
message("Added SFML")

Just to be clear, I'm running 'cmake ../' from the teminal to create the project and the 'make' command to compile.

I'm guessing I'm forgetting to link something or doing it wrong, but I can't seem to figure out how to solve this.
Here's to hoping you guys do!

5
Window / Re: Window render is slow when not using std::cout
« on: September 06, 2018, 03:05:26 pm »
Ok i solved it...

It seemed the "getElapsedFrameTimeAndRestart()" function was returning as int in milliseconds.

My current project is so fast that most times this value returns 0 because it is rounded down from the microseconds that a loop takes.

Probably a std::cout made some more movement happen because the statement made my loop just a bit longer to be rounded up to 1 millisecond more often.

I fixed this by now getting and returning the time in float seconds instead of int milliseconds

6
Window / [SOLVED]Window render is slow when not using std::cout
« on: September 06, 2018, 01:16:36 pm »
Hey Everyone,

I'm building my first engine and am stunned by this weird problem.

I have the following (simplified) setup for running my game loop:

// Open window
        while (Game::window.isOpen()) {
                //Register events
                sf::Event event;

                // Check if an event happened
                while (Game::window.pollEvent(event)) {
                        // Close windows if close button is pressed
                        if (event.type == sf::Event::Closed)
                                Game::window.close();
                }

                // Clear window with black background
                Game::window.clear(sf::Color::Black);

                // Let game logic catch up with real passed time
                lag += Game::getElapsedFrameTimeAndRestart(); // Add time that needs to be caught up in ms
                while (lag > 10) { // fixed update time is 10 ms
                        // Test moving ship to right
                        re::Sprite& player = scene.getSprite("player");
                        float movement = Game::getFixedUpdateTime() * 50;
                        float x = player.getPosition().x + movement;
                        player.setPosition(x, 50);

                        // Calculate remaining lag time to recover from
                        lag -= fixedUpdateTime; // Remove time that has been caught up
                }

                // Render all visible sprites
                //std::cout << "text"<< std::endl;
                Game::renderer.render();
        }
 

The render function consists of:

        // Render all sprites
        for (re::Sprite& sprite : Game::scene.getAllSprites()) {
                Renderer::mWindow.draw(sprite.getSprite());
        }

        // Draw sprites on screen
        Renderer::mWindow.display();
 

Now the weird problem is that when I run this code with the std::cout enabled, everything is rendered nicely and smoothly, but when I remove the std::cout, the rendering is slow and unstable.

I want to remove my unneccesary cout, but somehow I can't get a good rendering then...

What am I doing wrong?

7
General / Tutorial circle behind window borders and titlebar
« on: July 31, 2018, 09:53:59 pm »
Hey guys, I just started SFML and followed the tutorial here: https://www.sfml-dev.org/tutorials/2.5/start-vc.php

Everything seems to be working, but I'm annoyed that my end result  is not exactly the same as the end result of the tutorial.

My circle seems to be a bit off..
The tutorial looks like this:


Mine looks like this:


What am I missing?

Pages: [1]