Using SDL2_gfx issues using C++

Posted by Lance Zimmerman on Stack Overflow See other posts from Stack Overflow or by Lance Zimmerman
Published on 2013-11-11T21:50:55Z Indexed on 2013/11/11 21:53 UTC
Read the original article Hit count: 516

Filed under:
|

When I use the it with the common.c /common.h files that come with it, if I use the cpp instead of c extension using VS201X I get the LNK2019: unresolved external symbol _SDL_main

What that means is if I change the file containing main to test.c it compiles. When I change it back to text.cpp it fails to compile. I think that means it only works as a C compile.

Here is the code I copied from SDL2_gfxPrimitives.c. (Spaces added so they would show up.)

#include < stdio.h>
#include < stdlib.h>
#include < string.h>
#include < math.h>
#include < time.h>

#include "common.h"

#include "SDL2_gfxPrimitives.h"

static CommonState *state;

int main(int argc, char* argv[])
{
/* Initialize test framework */
state = CommonCreateState(argv, SDL_INIT_VIDEO);

return 1;
}

I need to use the library in C++ but it seems I don't know enough to figure out how. Any help would be appreciated, I've spent two days attempting to figure this out.

© Stack Overflow or respective owner

Related posts about c++

Related posts about sdl