Reputation: 153
Trying to set up an OpenGL environment in visual studio 2013 on windows 7 using SDL, glew, and glm. Yes, I have correctly linked and sorted all of the header and dlls, I have SDL2.dll and glew32.dll with the .exe. My linker input includes opengl32.lib. Runtime Library is set to "Multi-threaded DLL".
/*main.cpp*/
#include <SDL.h>
#include <glew.h>
#include <iostream>
int main(int argc, char* argv[])
{
return 0;
}
the error is
Error 1 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\Users\user\Documents\Visual Studio 2013\Projects\OpenGLProject\OpenGLProject\MSVCRT.lib(crtexe.obj) OpenGLProject
I notice that I am able to compile if I comment out #define main SDL_main
in SDL_main.h, so that might be related to the problem; though I feel as though I am barking up the wrong tree here.
Upvotes: 0
Views: 915
Reputation: 1
I got the same problem, as the upstair said, add SDL2main.lib to the project solve the problem, be sure you add the SDL2.LIB && SDL2main.lib in the same time
Upvotes: 0
Reputation: 162317
If I remember correctly (it's been a while since I last used SDL on Windows), you also have to add a library called SDLmain
(or similar). This library defines the main
function, which does some pre-initialization and then calls SDL_main
which happens to be your "main" function.
Upvotes: 2