Skip to content
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

Linking Error on Windows using Clion #156

Open
VanSharkholme opened this issue Nov 7, 2024 · 4 comments
Open

Linking Error on Windows using Clion #156

VanSharkholme opened this issue Nov 7, 2024 · 4 comments

Comments

@VanSharkholme
Copy link

Hi,
I'm trying to use the simulator on Windows with Clion, however when there's an error of undefined reference to 'SDL_main' during linking. The steps I took are as follows: I cloned this project, then downloaded MinGW 14.2.0 and SDL2-2.30.9, then copied everything in the SDL2 x86_64-w64-mingw32 folder to the root folder of the MinGW, finally I configured the toolset in the Clion and tried to compile this project. The compilation completed with no errors but during linking I got the error mentioned above. Heres the output:

F:/MinGW/mingw64_lvgl/bin/../lib/gcc/x86_64-w64-mingw32/14.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: F:/MinGW/mingw64_lvgl/lib/libSDL2main.a(SDL_windows_main.o): in function main_getcmdline': /Users/valve/release/SDL2/SDL2-2.28.4-source/foo-x64/../src/main/windows/SDL_windows_main.c:80:(.text+0x152): undefined reference to SDL_main'
collect2.exe: error: ld returned 1 exit status
mingw32-make[3]: *** [CMakeFiles\main.dir\build.make:123: F:/test/lvgl_sim/lv_port_pc_eclipse/bin/main.exe] Error 1
mingw32-make[2]: *** [CMakeFiles\Makefile2:109: CMakeFiles/main.dir/all] Error 2
mingw32-make[1]: *** [CMakeFiles\Makefile2:142: CMakeFiles/run.dir/rule] Error 2
mingw32-make: *** [Makefile:181: run] Error 2

Maybe there's something wrong when I'm installing SDL2? I don't know.
Thanks in advance for your help

@VanSharkholme
Copy link
Author

I solved this problem by changing the main function name to SDL_main in the file main.c, and the rest is working now

@VanSharkholme
Copy link
Author

VanSharkholme commented Nov 8, 2024

It turns out the problem is not solved, after changing the function name the main function that actually gets executed is the one in __main__.c, not the one in main.c

@VanSharkholme
Copy link
Author

I added "#include <SDL2/SDL.h>" in the main.c and now it works

@kisvegabor
Copy link
Member

It's very interesting. SDL.h is included here.

Anyway, thank you for sharing the solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants