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

Author Topic: [SOLVED]dll issues when building with RelWithDebInfo configuration  (Read 1737 times)

0 Members and 1 Guest are viewing this topic.

ChocolatePinecone

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
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")
« Last Edit: May 06, 2020, 01:14:21 pm by ChocolatePinecone »

ChocolatePinecone

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: dll issues when building with RelWithDebInfo configuration
« Reply #1 on: May 06, 2020, 01:10:39 pm »
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!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10818
    • View Profile
    • development blog
    • Email
Re: [SOLVED]dll issues when building with RelWithDebInfo configuration
« Reply #2 on: May 12, 2020, 02:51:37 pm »
I'm not sure if and how it can be done exactly, but I have opened an issue on GitHub, so we can keep track of this.

https://github.com/SFML/SFML/issues/1659
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything