Git Product home page Git Product logo

Comments (13)

madebr avatar madebr commented on August 17, 2024 1

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.

madebr avatar madebr commented on August 17, 2024

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.

corentin35000 avatar corentin35000 commented on August 17, 2024

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.

madebr avatar madebr commented on August 17, 2024

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.

corentin35000 avatar corentin35000 commented on August 17, 2024

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 le WIN32from add_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.

madebr avatar madebr commented on August 17, 2024

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.

corentin35000 avatar corentin35000 commented on August 17, 2024

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

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.

corentin35000 avatar corentin35000 commented on August 17, 2024

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

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.

corentin35000 avatar corentin35000 commented on August 17, 2024

SDL_SetMainReady, does this system still work? :(

from sdl.

corentin35000 avatar corentin35000 commented on August 17, 2024

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

madebr avatar madebr commented on August 17, 2024

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.

corentin35000 avatar corentin35000 commented on August 17, 2024

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.

corentin35000 avatar corentin35000 commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.