Possible Duplicate:
Compiling with int main(void) fails; main(int argc, char *argv[]) succeeds. Why?
I am making a simple game engine using OpenGL and SDL. All the initialization code for SDL and OpenGL is in a dll. The application then simple calls the function to initialize everything. The dll is compiled and had no issues but when I try and compile an application referencing the dll it doesn't work. It says I have an Undefined reference to `WinMain@16'. I initially thought this was because it was set as a win32 app and I just needed to swap it over to console app.
Turns out it was already on console app. So why am I getting this error? Here is the code for the application:
#include "GameManager.h" int main() { GameManager gameManager; gameManager.EngineStartUp(480, 640); return 0; } And here is the code for the dll:
#include "GameManager.h" #include <iostream> #include "SDL/SDL.h" #include "gl/gl.h" #include "gl/glu.h" GameManager::GameManager() { //ctor } GameManager::~GameManager() { //dtor } //Initializes OpenGL and SDL bool GameManager::EngineStartUp(int WindowHeight, int WindowWidth) { if(SDL_Init(SDL_INIT_EVERYTHING) < 0) { return false; } if((Surf_Display = SDL_SetVideoMode(WindowWidth, WindowHeight, 32, SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER | SDL_OPENGL)) = NULL){ return false; } glClearColor(0.415f, 0.432f, 1.0f, 1); glClearDepth(1.0f); glViewport(0, 0, WindowWidth, WindowHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, WindowWidth, WindowHeight, 0, 1, -1); glMatrixMode(GL_MODELVIEW); glEnable(GL_TEXTURE_2D); glLoadIdentity(); return true; }
int main()toint main(int argc, char* argv[])and link with SDL_main. See here: stackoverflow.com/questions/8673378/…