Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\Users\Minkai\Documents\Visual Studio 2013\Projects…\MSVCRTD.lib(crtexe.obj)
I searched around the internet and someone said I can bypass that by adding #undef main
I tried that and now the compiler doesn’t recognize things like SDL_Init(SDL_INIT_VIDEO), SDL_CreateWindow… etc, although it still recognizes things like SDL_Window, SDL_Surface. Here’s the source code:
Error 1 error LNK2019: unresolved external symbol _SDL_GetError referenced in function _main
Error 2 error LNK2019: unresolved external symbol _SDL_Init referenced in function _main
Error 3 error LNK2019: unresolved external symbol _SDL_Quit referenced in function _main
Error 4 error LNK1120: 3 unresolved externals
I’ve double checked to make sure the Include Directories and Library Directories are fine. Linker > Input > Additional Dependencies are fine too. For Linker > System > SubSystem, I tried switching between Window and Console, doesn’t work. I put my SDL2.dll everywhere in the project to make sure.
Please help.
Some information:
Using the latest SDL SDL2-devel-2.0.3-VC.zip
IDE is Microsoft Visual Studio Express 2013 for Windows Desktop
Version 12.0.31101.00 Update 4
Error 1 error LNK2019: unresolved external symbol _main referenced in
function ___tmainCRTStartup C:\Users\Minkai\Documents\Visual Studio
2013\Projects…\MSVCRTD.lib(crtexe.obj)
Are you building a console app instead of a Windows app by accident?
Make sure you:
Build with /SUBSYSTEM:WINDOWS
link against SDLmain.lib (which provides WinMain())
have a main() function in your program in a source file that #include
SDL.h" (which will make the right function for WinMain() to call).
I will second what Ryan said, not because he knows what he’s talking about,
but because I was writing a much longer-winded version of this and realized
it was unnecessary.
-AlexOn Mon, Feb 9, 2015 at 3:27 PM, Ryan C. Gordon wrote:
Error 1 error LNK2019: unresolved external symbol _main referenced in
function ___tmainCRTStartup C:\Users\Minkai\Documents\Visual Studio
2013\Projects…\MSVCRTD.lib(crtexe.obj)
Are you building a console app instead of a Windows app by accident? Make
sure you:
Build with /SUBSYSTEM:WINDOWS
link against SDLmain.lib (which provides WinMain())
have a main() function in your program in a source file that #include
SDL.h" (which will make the right function for WinMain() to call).
Had a weird inclination to re-read my post, and sure enough, the words
didn’t come out just right.On Mon, Feb 9, 2015 at 3:29 PM, Alex Barry <@Alex_Barry> wrote:
I will second what Ryan said, not because he knows what he’s talking
about, but because I was writing a much longer-winded version of this and
realized it was unnecessary.
-Alex
On Mon, Feb 9, 2015 at 3:27 PM, Ryan C. Gordon wrote:
Error 1 error LNK2019: unresolved external symbol _main referenced in
function ___tmainCRTStartup C:\Users\Minkai\Documents\Visual Studio
2013\Projects…\MSVCRTD.lib(crtexe.obj)
Are you building a console app instead of a Windows app by accident? Make
sure you:
Build with /SUBSYSTEM:WINDOWS
link against SDLmain.lib (which provides WinMain())
have a main() function in your program in a source file that #include
SDL.h" (which will make the right function for WinMain() to call).
Error 1 error LNK2019: unresolved external symbol _main referenced in
function ___tmainCRTStartup C:\Users\Minkai\Documents\Visual Studio
2013\Projects…\MSVCRTD.lib(crtexe.obj)
Are you building a console app instead of a Windows app by accident?
Make sure you:
Build with /SUBSYSTEM:WINDOWS
link against SDLmain.lib (which provides WinMain())
have a main() function in your program in a source file that #include
SDL.h" (which will make the right function for WinMain() to call).