Comments (13)
It's probably something silly. Please share a minimum reproducible project and I'll see whether I can reproduce your issue and how to fix it.
This is going to be complicated, my RC2D wrapper uses submodules..etc :/ I plan to upgrade the version for SDL3 from my wrapper, but I wanted to wait for v3.2.0 to avoid too many breaking changes.. since I see that it still changes a lot of things currently... would I have less problems with SDL3 given that SDLmain was deleted it seems to me?
You'll have to additionally deal with a full-blown migration.
The main entry function should not appear though.
I use SDL, SDLttf, SDLmixer and SDLimage I saw that none of the repositories were versioned yet, should I base it on master / main for SDL3_* for all the libraries?
Yes: SDL3 development happens in the main branches.
from sdl.
Linking with SDL2main has the implicit expectation you included SDL.h
in the translation unit in which the main function is declared and implemented.
So there are 2 ways to fix this:
- Don't link with SDL2main and make sure to run
SDL_SetMainReady
in the test suite fixture - Include
SDL.h
in your test suite before the headers of doctest, such that SDL can rename main to SDL_main,
from sdl.
Linking with SDL2main has the implicit expectation you included
SDL.h
in the translation unit in which the main function is declared and implemented.So there are 2 ways to fix this:
- Don't link with SDL2main and make sure to run
SDL_SetMainReady
in the test suite fixture- Include
SDL.h
in your test suite before the headers of doctest, such that SDL can rename main to SDL_main,
I have already tried to use: SDL_SetMainReady(); obviously removing SDL2main, error :
But I have this: MSVCRT.lib(exe_winmain.obj): error LNK2019: unresolved WinMain external symbol referenced in function "int __cdecl __scrt_common_main_seh(void)" (?__scrt_common_main_seh@@yahxz) (so it expects me to defined SDL2main). I also tested SDL.h before including doctest.h
It's the same... I had already tested these are two solutions
from sdl.
The linker is missing WinMain
, which means you're linking the executable as a GUI executable (Windows subsystem).
However, you probably want to use the CONSOLE subsystem.
This can be done by passing /subsystem:CONSOLE
to the linker, or drop the WIN32
from add_executable(mytest WIN32 src1.c)
in cmake.
from sdl.
L'éditeur de liens est manquant
WinMain
, ce qui signifie que vous liez l'exécutable en tant qu'exécutable GUI (sous-système Windows). Cependant, vous souhaiterez probablement utiliser le sous-système CONSOLE. Cela peut être fait en passant/subsystem:CONSOLE
à l'éditeur de liens ou en supprimant leWIN32
fromadd_executable(mytest WIN32 src1.c)
dans cmake.
I simply use this for Windows in Release mode, to avoid having the terminal open in Release mode: set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE $CONFIG:Release)
I commented out and added this:
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/subsystem:console")
But now I have another error: error LNK2019: unresolved external symbol main referenced in function "int __cdecl invoke_main( void)" (?invoke_main@@yahxz.
Especially with what you're telling me, I'm going to have the terminal open, so I wanted to keep it in GUI mode.
from sdl.
When you don't link to SDL2main, add SDL_SetMainReady
to an appropriate location and add target_compile_definitions(${PROJECT_NAME} PRIVATE SDL_MAIN_HANDLED)
.
from sdl.
When you don't link to SDL2main, add
SDL_SetMainReady
to an appropriate location and addtarget_compile_definitions(${PROJECT_NAME} PRIVATE SDL_MAIN_HANDLED)
.
I added this:
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
target_compile_definitions(${PROJECT_NAME} PRIVATE SDL_MAIN_HANDLED)
main.cpp :
#include "game.h"
#include "unit-tests/unit-tests.h"
int main(int argc, char* argv[])
{
SDL_SetMainReady();
#ifdef NDEBUG // If we are in Release mode
// Keep only error and critical logs
rc2d_log_set_priority(RC2D_LOG_ERROR);
#else // If we are in Debug mode
// Show all log levels
rc2d_log_set_priority(RC2D_LOG_DEBUG);
#endif
#ifndef DOCTEST_CONFIG_DISABLE
// Run all unit tests if Doctest is enabled
// If tests fail, exit with error code
if (rc2d_tests_runAllTests(argc, argv) != 0) return -1;
#endif
return 0;
}
from sdl.
When you don't link to SDL2main, add
SDL_SetMainReady
to an appropriate location and addtarget_compile_definitions(${PROJECT_NAME} PRIVATE SDL_MAIN_HANDLED)
.I added this: set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") target_compile_definitions(${PROJECT_NAME} PRIVATE SDL_MAIN_HANDLED)
main.cpp :
#include <rc2d/RC2D.h> #include "game.h" #include "unit-tests/unit-tests.h" int main(int argc, char* argv[]) { SDL_SetMainReady(); #ifdef NDEBUG // If we are in Release mode // Keep only error and critical logs rc2d_log_set_priority(RC2D_LOG_ERROR); #else // If we are in Debug mode // Show all log levels rc2d_log_set_priority(RC2D_LOG_DEBUG); #endif #ifndef DOCTEST_CONFIG_DISABLE // Run all unit tests if Doctest is enabled // If tests fail, exit with error code if (rc2d_tests_runAllTests(argc, argv) != 0) return -1; #endif return 0; }
I still have the error: Error: error LNK2019: unresolved external symbol main referenced in function "int __cdecl __scrt_common_main_seh(void)"
from sdl.
SDL_SetMainReady, does this system still work? :(
from sdl.
, knowing that this is not appropriate I would like to keep: set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE $CONFIG:Release). To have an application in Release mode without a terminal! And if I put this I end up with the WinMain error..
from sdl.
It's probably something silly. Please share a minimum reproducible project and I'll see whether I can reproduce your issue and how to fix it.
from sdl.
It's probably something silly. Please share a minimum reproducible project and I'll see whether I can reproduce your issue and how to fix it.
This is going to be complicated, my RC2D wrapper uses submodules..etc :/ I plan to upgrade the version for SDL3 from my wrapper, but I wanted to wait for v3.2.0 to avoid too many breaking changes.. since I see that it still changes a lot of things currently... would I have less problems with SDL3 given that SDLmain was deleted it seems to me?
from sdl.
I use SDL, SDLttf, SDLmixer and SDLimage I saw that none of the repositories were versioned yet, should I base it on master / main for SDL3_* for all the libraries?
from sdl.
Related Issues (20)
- [Suggestion] Rename concepts in the Properties API HOT 14
- SDL_SetAudioDeviceFrequencyRatio and SDL_GetAudioDeviceFrequencyRatio HOT 3
- Drawing regression in latest SDL3 HOT 22
- CMAKE_ASM_MASM_COMPILE_OBJECT not set when adding SDL as a subdirectory to CMake HOT 10
- Should SDL_GAMECONTROLLERCONFIG be SDL_GAMEPADCONFIG? HOT 1
- No implementations for SDL libraries found.
- [SDL_video] SDL_GetWindowPixelFormat still returns Uint32 instead of an SDL_PixelFormat value HOT 4
- Suggestion to consider modularity of SDL and separate libraries HOT 2
- Patching with SDL_migration.cocci does not work HOT 2
- SDL_SINT64_C vs SDL_INT64_C define mistake
- SDL2: sometimes linux automatically rescales window to a minimum size HOT 1
- Memory Leak with Newest SDL3 HOT 10
- Windows CI failing in icon.h creation
- SDL renderer "ERROR: Could not get a framebuffer" when running a SDL-release-2.30.5 program on a Debian system without X. HOT 4
- Rename some Get/Set functions to match the new naming style HOT 5
- Incorrect usage of GetStringUTFChars/NewStringUTF in android jni code
- SDL_Renderer vulkan backend fails while re-entering the app on android HOT 7
- Gamepad not recognized by SDL but via Linux and gtk HOT 2
- Clarification of thread safety of SDL_GetStringRule HOT 4
- [Suggestion] Make SDL_GetWindowOpacity() return the opacity value, instead of using an out parameter. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdl.