PDA

View Full Version : problem at the compilation to display a window with SDL and opengl



airseb
06-16-2003, 10:24 AM
Hi !
i have this program :



#include <SDL.h>
#include <GL/gl.h>
#include <GL/glu.h>



void main ()
{
SDL_Init( SDL_INIT_VIDEO ) ;
SDL_SetVideoMode( 640, 480, 32, SDL_OPENGL ) ;
}


i want to display a window but at the compilation, i have that :

error C2144: syntax error : missing ';' before type 'void'
error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
fatal error C1004: unexpected end of file found

these errors specify the file gl.h
what can i do ?
thanks.

06-16-2003, 10:37 AM
Try including <SDL_opengl.h> as below:

#include <SDL.h>
#include <SDL_opengl.h>

void main ()
{
SDL_Init( SDL_INIT_VIDEO ) ;
SDL_SetVideoMode(640, 480, 32, SDL_OPENGL );
}

airseb
06-16-2003, 10:59 AM
thanks !
but i do that and i have new errors:


#include <SDL.h>
#include <SDL_opengl.h>
#pragma comment(lib, "SDL.lib")
#pragma comment(lib, "SDLmain.lib")


void main ()
{
SDL_Init( SDL_INIT_VIDEO ) ;
SDL_SetVideoMode( 640, 480, 32, SDL_OPENGL ) ;
}

and the errors are :
Linking...
msvcrt.lib(MSVCRT.dll) : error LNK2005: _exit already defined in LIBCD.lib(crt0dat.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in LIBCD.lib(strncpy.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in LIBCD.lib(fclose.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __isctype already defined in LIBCD.lib(isctype.obj)
LIBCD.lib(crt0init.obj) : warning LNK4098: defaultlib "msvcrt.lib" conflicts with use of other libs; use /NODEFAULTLIB:library
SDLmain.lib(SDL_main.obj) : error LNK2001: unresolved external symbol _SDL_main
Debug/fenetre_SDL.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

fenetre_SDL.exe - 6 error(s), 1 warning(s)

i have also done :


#include <SDL.h>
#include <SDL_opengl.h>
#pragma comment(lib, "SDL.lib")

void main ()
{
SDL_Init( SDL_INIT_VIDEO ) ;
SDL_SetVideoMode( 640, 480, 32, SDL_OPENGL ) ;
}

and this time the errors are :
Linking...
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/fenetre_SDL.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

fenetre_SDL.exe - 2 error(s), 0 warning(s)


i don't understand, can you help me ?

[This message has been edited by airseb (edited 06-16-2003).]

mikael_aronsson
06-16-2003, 09:20 PM
Hi !

Check your code genaration options, I think SDL is compiled with multithreaded (debug) dll, and you are using some other option like multithreaded (non dll) for example, this gives this kind of error.

Check the options used in the SDL library and use the same in your project.

Mikael

airseb
06-16-2003, 10:57 PM
can you tell me exactly what i have to check ? i don't know visual c++ 6 very well...