GPWiki.org
GPWiki.org
It is currently Sun May 19, 2013 1:53 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu May 31, 2012 2:21 pm 
Hello,
I am compiling a code in MVS 2010

[color=#000080]//Include SDL functions and datatypes
#include "SDL.h"
#include "StdAfx.h"
int main( int argc, char* args[] )
{
//The images
SDL_Surface* hello = NULL;
SDL_Surface* screen = NULL;

//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );

//Set up screen
screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );

//Load image
hello = SDL_LoadBMP( "hello.bmp" );

//Apply image to screen
SDL_BlitSurface( hello, NULL, screen, NULL );

//Update Screen
SDL_Flip( screen );

//Pause
SDL_Delay( 2000 );

//Free the loaded image
SDL_FreeSurface( hello );

//Quit SDL
SDL_Quit();

return 0;
}



the error displayed :-
------ Build started: Project: hello, Configuration: Debug Win32 ------
hello.cpp
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(5): warning C4627: '#include "SDL.h"': skipped when looking for precompiled header use
Add directive to 'StdAfx.h' or rebuild precompiled header
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(10): error C2065: 'SDL_Surface' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(10): error C2065: 'hello' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(11): error C2065: 'SDL_Surface' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(11): error C2065: 'screen' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(14): error C2065: 'SDL_INIT_EVERYTHING' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(14): error C3861: 'SDL_Init': identifier not found
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(17): error C2065: 'screen' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(17): error C2065: 'SDL_SWSURFACE' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(17): error C3861: 'SDL_SetVideoMode': identifier not found
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(20): error C2065: 'hello' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(20): error C3861: 'SDL_LoadBMP': identifier not found
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(23): error C2065: 'hello' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(23): error C2065: 'screen' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(23): error C3861: 'SDL_BlitSurface': identifier not found
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(26): error C2065: 'screen' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(26): error C3861: 'SDL_Flip': identifier not found
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(29): error C3861: 'SDL_Delay': identifier not found
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(32): error C2065: 'hello' : undeclared identifier
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(32): error C3861: 'SDL_FreeSurface': identifier not found
c:\users\sp singh\documents\visual studio 2010\projects\hello\hello\hello.cpp(35): error C3861: 'SDL_Quit': identifier not found
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



What should I do next??? Thanks for the help.


Top
  
 
PostPosted: Thu May 31, 2012 2:48 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6700
Location: Lincoln, Englandshire
I think stdafx.h needs to be the first thing in the file.

Try switching the order of the stdafx and sdl headers.

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Thu May 31, 2012 4:29 pm 
:) I DID BUT NOW THE ERROR IS COMING AS -

main.obj : error LNK2005: _SDL_main already defined in hello.obj
hello.obj : error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main
main.obj : error LNK2001: unresolved external symbol _SDL_Quit
hello.obj : error LNK2019: unresolved external symbol _SDL_FreeSurface referenced in function _SDL_main
hello.obj : error LNK2019: unresolved external symbol _SDL_Delay referenced in function _SDL_main
hello.obj : error LNK2019: unresolved external symbol _SDL_Flip referenced in function _SDL_main
hello.obj : error LNK2019: unresolved external symbol _SDL_UpperBlit referenced in function _SDL_main
hello.obj : error LNK2019: unresolved external symbol _SDL_LoadBMP_RW referenced in function _SDL_main
hello.obj : error LNK2019: unresolved external symbol _SDL_RWFromFile referenced in function _SDL_main
hello.obj : error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function _SDL_main
hello.obj : error LNK2019: unresolved external symbol _SDL_Init referenced in function _SDL_main
main.obj : error LNK2001: unresolved external symbol _SDL_Init
MSVCRT.lib(crtexew.obj) : error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
c:\users\sp singh\documents\visual studio 2010\Projects\hello\Debug\hello.exe : fatal error LNK1120: 10 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Top
  
 
PostPosted: Thu May 31, 2012 7:02 pm 
Bibliotherapist
User avatar

Joined: Wed Nov 03, 2004 1:28 pm
Posts: 6700
Location: Lincoln, Englandshire
:eek
Is there a .lib that needs to be added to the project?

_________________
10 PRINT "Bad Monkey ";
20 GOTO 10


Top
 Profile  
 
PostPosted: Fri Jun 01, 2012 8:15 am 
No there isn't. Is there any other tutorial that I should follow for Microsoft Visual c++ 2010 and SDL programming?? How should I learn game programming in C++???


Top
  
 
PostPosted: Fri Aug 31, 2012 9:07 pm 
Rookie

Joined: Mon Aug 27, 2012 7:33 am
Posts: 1
Maybe I say something stupid, but in my opinion you messed #include.

I never used "SDL.h"

Try use #include <SDL.h> if you use "SDL.h" then the compiler thinks, that SDL.h is in the same folder as the project file.


Top
 Profile  
 
PostPosted: Sat Sep 01, 2012 7:34 am 
Bytewise

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 275
Location: Here (where else?)
payo wrote:
No there isn't. Is there any other tutorial that I should follow for Microsoft Visual c++ 2010 and SDL programming?? How should I learn game programming in C++???
Your linker and undeclared identifier errors are not SDL problems nor are they game-programming related, it is about MSVC not properly being told where it can find things. The errors are just "he guys, I cannot find some stuff that you used".

You should probably try to find out how to add a (any) 3rd-party c++ library to MSVC.
(I don't use windows, so cannot help you with the details, unfortunately)

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group