I am trying to compile a program that uses SDL in Visual Studio Community 2019. I keep getting the error LIBCMTD.lib(exe_main.obj): error LNK2019: unresolved external symbol main referenced in function "int _cdecl invokemain(void)" (?invokemain@@YAHXZ). I looked online for this error and found out that the most likely cause of this error is _ATL_MIN_CRT. Does anyone know if there is another cause for this error and if not, how do I remove _ATL_MIN_CRT?
Asked
Active
Viewed 203 times
-1
-
Make sure the binaries are compatible with your compiler. Also for Visual Studio there likely will be separate libraries for Release and Debug. It is not safe to mix these meaning you must use the debug libs in debug mode of your application. Same goes for release. – drescherjm Jan 31 '21 at 00:53
-
***unresolved external symbol main*** Isn't there a define you need to use to enable sdl_main? Related: [https://stackoverflow.com/questions/11976084/why-sdl-defines-main-macro](https://stackoverflow.com/questions/11976084/why-sdl-defines-main-macro) – drescherjm Jan 31 '21 at 00:54
-
@drescherjm I can't find separate release and debug libraries for SDL2. Where do I define `sdl_main`? I tried including other libs in the directory and got these errors: `SDL2main.lib(SDL_windows_main.obj) : error LNK2001: unresolved external symbol SDL_main Hint on symbols that are defined and could potentially match: "int __cdecl SDL_main(void)" (?SDL_main@@YAHXZ) SDL2main.lib(SDL_windows_main.obj) : error LNK2001: unresolved external symbol __imp_CommandLineToArgvW fatal error LNK1120: 2 unresolved externals` – Daniel Eremin Feb 01 '21 at 05:09
-
Ok, I figured out the problem. I needed to add shell32.lib and add `int argc, char* argv[]` to the main function. – Daniel Eremin Feb 01 '21 at 05:40
1 Answers
0
Make sure both SDL2.lib AND SDL2main.lib are included included. Then include shell32.lib. After that add int argc, char* argv[]
to the main function.

Daniel Eremin
- 9
- 4