| Clearner1 (38) | |||
|
while i am compiling the code below it pops: unresolved external:SDL Symbol RWReadFile referenced in function SDL_main what is that mean and how can i fix this i am using visual studio check the code :
| |||
|
Last edited on
|
|||
| Ogoyant (153) | |||
|
There is a common issue with the SDL_main function that generates Error LNK2019: unresolved external symbol _SDL_main referenced in function _main I'm not sure if it's related in this case. However, there is a definition in SDL_main.h (which is included by SDL.h) that goes like this:
Try defining your main() as int main(int argc, char **argv) (to match SDL's) and see if it's resolved.
| |||
|
Last edited on
|
|||
| Clearner1 (38) | |
|
still not working l...i will list the errors for you: Error 1 error LNK2019: unresolved external symbol _SDL_RWFromFile referenced in function _SDL_main C:\Users\mohammed\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Source.obj ConsoleApplication8 Error 2 error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function _SDL_main C:\Users\mohammed\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Source.obj ConsoleApplication8 Error 3 error LNK2019: unresolved external symbol _SDL_Flip referenced in function _SDL_main C:\Users\mohammed\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Source.obj ConsoleApplication8 Error 4 error LNK2019: unresolved external symbol _SDL_FreeSurface referenced in function _SDL_main C:\Users\mohammed\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Source.obj ConsoleApplication8 Error 5 error LNK2019: unresolved external symbol _SDL_LoadBMP_RW referenced in function _SDL_main C:\Users\mohammed\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Source.obj ConsoleApplication8 Error 6 error LNK2019: unresolved external symbol _SDL_UpperBlit referenced in function _SDL_main C:\Users\mohammed\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Source.obj ConsoleApplication8 Error 7 error LNK2019: unresolved external symbol _SDL_Delay referenced in function _SDL_main C:\Users\mohammed\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Source.obj ConsoleApplication8 Error 8 error LNK2019: unresolved external symbol _SDL_Quit referenced in function _SDL_main C:\Users\mohammed\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\Source.obj ConsoleApplication8 Error 9 error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup C:\Users\mohammed\documents\visual studio 2012\Projects\ConsoleApplication8\ConsoleApplication8\MSVCRTD.lib(crtexe.obj) ConsoleApplication8 Error 10 error LNK1120: 9 unresolved externals C:\Users\mohammed\documents\visual studio 2012\Projects\ConsoleApplication8\Debug\ConsoleApplication8.exe ConsoleApplication8 | |
|
|
|
| Ogoyant (153) | |||||
I see. For what it's worth, another approach I've read was to
(although I am certainly unsure of the consequences of #undef-ing main! I mention it because I've just come across it in discussions involving SDL_main). However, I now got a chance to refer to some old SDL code of mine (which did not generate errors) and I see that I have pretty much this structure in it:
--- EDIT: By the way, I realized that you are not calling SDL_Init() in your program above. It should be called at the very beginning of the SDL program. | |||||
|
Last edited on
|
|||||
| Clearner1 (38) | |
|
one weird error 1>c:\users\mohammed\documents\visual studio 2012\consoleapplication1\consoleapplication1\source.cpp(21): error C3861: 'OnEvent': identifier not found | |
|
|
|
| EssGeEich (1007) | |||||
|
You must declare OnEvent before main. Examples:
Or also:
| |||||
|
Last edited on
|
|||||
| Ogoyant (153) | |
|
Yes, of course -- like EssGeEich says, OnEvent() has to be declared before main() for this to compile, since it is a function written by myself and not part of SDL itself, but rather a function meant to handle SDL_Events. I posted the code above as a figurative example put together by parts of my code in order to show the overall structure, I didn't mean it as an explicit compilable one. However, if you declare OnEvent() before main(), it will actually compile. | |
|
|
|
| Clearner1 (38) | |
| i think the errors are because there are include and libs file missing .... the brand new errors are another unresolved externals...i am sorry guys...i got you annoyed...the last time ...just give me an entire code and i will copy paste and see what is going on.....thanks for your trying | |
|
|
|
| EssGeEich (1007) | |||
|
Well you must link to SDL library. If you use Microsoft's Visual Studio compiler, you can:
Otherwise you must add SDL.lib in your IDE manually. Also you must add SDL's directory in your IDE no matter which way you choose. | |||
|
|
|||
| Ogoyant (153) | |||
You must also #pragma comment(lib, "SDLmain.lib") Make sure that you have set these settings in your project: http://lazyfoo.net/SDL_tutorials/lesson01/windows/msvsnet2010e/index.php Also: my non-compilable example code above uses SDL_image but SDL_image is not part of the standalone SDL, it is an additional header file that allows some greater flexibility requiring image file types, etc. . So -- sorry to have gotten you confused, at the time of writing I supposed that it was apparent that the code was portraying structure and was not readily compilable. If your project is set up properly and your additional dependencies and other settings are correct, this should compile fine:
If this doesn't compile, there's something left to be added in your project settings. Try it out. EDIT: SDL requires SDL.lib and SDLmain.lib to be added in Project Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies (or requires using the #pragma comment commands for "SDL.lib" and "SDLmain.lib"). Furthermore, make sure that SDL's include directory is added in: Project Properties -> Configuration Properties -> VC++ Directories -> Include Directories and also add SDL's lib directory in Project Properties -> Configuration Properties -> VC++ Directories -> Library Directories. Steps 3-8 in the tutorial I linked for setting up SDL in Visual Studio describe this process. | |||
|
Last edited on
|
|||
| Clearner1 (38) | |||
|
thank you Ogoyant, EssGeEich these two was all i want:
now it is working fine and i can continue on SDL tutorials | |||
|
|
|||
| Ogoyant (153) | |
|
Great, glad to hear you got it working Clearner1 Ogoyant | |
|
|
|
| Clearner1 (38) | |
| thanks for your care | |
|
|
|