-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL_MAIN_USE_CALLBACKS & macOS => linker error, undefined symbol: _main #11857
Comments
Did you include SDL_main.h after defining SDL_MAIN_USE_CALLBACKS? Like this: SDL/examples/renderer/01-clear/clear.c Lines 9 to 11 in 90efb63
|
Yes, and there seems to be a problem with the macros. Right after the
The last two are undefined, that's what the string literal is printed by Adding the following code to int SDL_main(int argc, char **argv) {
return SDL_EnterAppMainCallbacks(argc, argv, SDL_AppInit, SDL_AppIterate, SDL_AppEvent, SDL_AppQuit);
}
#undef main
int main(int argc, char *argv[]) {
(void)argc;
(void)argv;
return SDL_RunApp(0, NULL, SDL_main, NULL);
} But, of course, that's not how it's intended. |
Hmm...I wonder if we got bitten by name-mangling here. Let me see if I can reproduce this over here. |
My code is a mixture of C and C++. Hence, the C++ linker kicks in. However, I think it's a macro bug on the APPLE platform because the file where the link error is reported is a C file. I looked at the handling of Maybe adding much more compile time message output and checks with erroring out is the best first step to hunt down this problem. |
Okay, wait, rereading this again, why is Stick this in before the #ifdef SDL_MAIN_HANDLED
#error SDL_MAIN_HANDLED shouldn't be defined here!
#endif
#ifdef SDL_WIKI_DOCUMENTATION_SECTION
#error SDL_WIKI_DOCUMENTATION_SECTION shouldn't be defined, ever!
#endif
#include <SDL3/SDL_main.h> |
I didn't define SDL_MAIN_HANDLED anywhere nor do I use SDL_WIKI_... Adding the pre-processor stuff before the |
Okay, so we have to figure out where that is getting defined, because it's not defined by SDL's headers (except in that wiki documentation section, which is why we checked that here, too). Scour your build scripts, grep in the project, etc? |
From README-cmake.md and the example template, does this CMakeLists.txt |
Works. |
It has to be somewhere in your project files, or something your project is picking up, like some external configuration thing that's gone wrong. If just straight-up grepping for |
Kicking this out of the milestone for now, but I'm still under the impression this isn't our bug, so I'm probably closing this soon unless I hear otherwise. |
I get the following link error:
Am I missing something?
The text was updated successfully, but these errors were encountered: