•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,543 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,305 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 2912 | Replies: 7
![]() |
•
•
Join Date: Oct 2007
Posts: 18
Reputation:
Rep Power: 2
Solved Threads: 0
At first, here's my source code:
Well... my problem is, that i in some way must have mis-configured, my compiler. But since i'm new (Both at programming c++ and at using the compiler), i don't know how 
the error meesages are, the following:
[Linker error] undefined reference to `SDL_Init'
[Linker error] undefined reference to `SDL_WM_SetCaption'
[Linker error] undefined reference to `SDL_SetVideoMode'
[Linker error] undefined reference to `SDL_RWFromFile'
[Linker error] undefined reference to `SDL_LoadBMP_RW'
[Linker error] undefined reference to `SDL_DisplayFormat'
[Linker error] undefined reference to `SDL_FreeSurface'
[Linker error] undefined reference to `SDL_PollEvent'
[Linker error] undefined reference to `SDL_UpperBlit'
[Linker error] undefined reference to `SDL_UpdateRect'
[Linker error] undefined reference to `SDL_FreeSurface'
[Linker error] undefined reference to `SDL_Quit'
[Linker error] undefined reference to `WinMain@16'
ld returned 1 exit status
As you can see, any command that i have used, which starts with SDL, has an undefinded referance. As i have come to understand, it has something to do with the way i have inclueded my files.
If some-one out there have used the dev-c++ compiler (Which i'm using), and also have experiaence with connecting that compiler to the SDL, it would be REALY nice if you would give me a, step, by step, tutorial, in how to do it. But it would also be nice if any1 else would bother to anwser, because that might be enouth to help me.
Please take in notice, that i'm VERY new to the langauge and compiler, so please don't use any words/sentences, that only experienced users understand
#include <SDL.h>
int main(int argc, char* argv[])
{
//initialize SDL and the video system.
if (SDL_Init( SDL_INIT_VIDEO)<0)
return -1;
//signal SDL to change the text of the main window to SDL "Hello World".
SDL_WM_SetCaption("Hello world","Hello World");
//Create an SDL_Surface object, which represents, the game window.
SDL_Surface* screen=SDL_SetVideoMode(640,480,0,0);
//Load the SDL logo bitmap to a temporary surface
SDL_Surface* temp=SDL_LoadBMP("data\\structures\\sdl_logo.bmp");
//Create the working SDL surface which matches the display format of the temporary surface.
SDL_Surface* bg= SDL_DisplayFormat(temp);
//Free the memory allocated to the temporary SDL_Surface.
SDL_FreeSurface(temp);
SDL_Event event;
bool quit=false;
//this is the main message loop if the game.
while(!quit)
{
//Check message qeue for an event.
if (SDL_PollEvent(&event))
{
//If an event was found.
switch (event.type)
{
//check to see if the window was closed via the "x"
case SDL_QUIT:
//Set the quit flag to true
quit=true;
break;
//Check the keyboard to see if the ESC key was pressed.
case SDL_KEYDOWN:
switch (event.key.keysym.sym)
{
case SDLK_ESCAPE:
//set our quit flag to true
quit=true;
break;
}
break;
}
}
//Draw the background sprite:
SDL_BlitSurface(bg, NULL, screen, NULL);
//Update the current window.
SDL_UpdateRect(screen,0,0,0,0);
}
//Free the allocated memery for the background surface.
SDL_FreeSurface(bg);
//Quit SDL and allow it to clean up everything.
SDL_Quit();
//return control to windows with no errors.
return 0;
}
the error meesages are, the following:
[Linker error] undefined reference to `SDL_Init'
[Linker error] undefined reference to `SDL_WM_SetCaption'
[Linker error] undefined reference to `SDL_SetVideoMode'
[Linker error] undefined reference to `SDL_RWFromFile'
[Linker error] undefined reference to `SDL_LoadBMP_RW'
[Linker error] undefined reference to `SDL_DisplayFormat'
[Linker error] undefined reference to `SDL_FreeSurface'
[Linker error] undefined reference to `SDL_PollEvent'
[Linker error] undefined reference to `SDL_UpperBlit'
[Linker error] undefined reference to `SDL_UpdateRect'
[Linker error] undefined reference to `SDL_FreeSurface'
[Linker error] undefined reference to `SDL_Quit'
[Linker error] undefined reference to `WinMain@16'
ld returned 1 exit status
As you can see, any command that i have used, which starts with SDL, has an undefinded referance. As i have come to understand, it has something to do with the way i have inclueded my files.
If some-one out there have used the dev-c++ compiler (Which i'm using), and also have experiaence with connecting that compiler to the SDL, it would be REALY nice if you would give me a, step, by step, tutorial, in how to do it. But it would also be nice if any1 else would bother to anwser, because that might be enouth to help me.
Please take in notice, that i'm VERY new to the langauge and compiler, so please don't use any words/sentences, that only experienced users understand
•
•
Join Date: Dec 2006
Location: india
Posts: 1,085
Reputation:
Rep Power: 9
Solved Threads: 163
here is something obtained thru googling (i've no clue about either dev-c++ or sdl); see if these help.
http://www.gpwiki.org/index.php/C:Ho...s:_Dev-C.2B.2B
http://www.imrtechnology.ngemu.com/sdldevtut.htm
if they do not, abandon daniweb and try a forum where there may be people who are more knowledgable. eg. http://gpwiki.org/forums/viewforum.php?f=2
http://www.gpwiki.org/index.php/C:Ho...s:_Dev-C.2B.2B
http://www.imrtechnology.ngemu.com/sdldevtut.htm
if they do not, abandon daniweb and try a forum where there may be people who are more knowledgable. eg. http://gpwiki.org/forums/viewforum.php?f=2
•
•
Join Date: Oct 2007
Posts: 18
Reputation:
Rep Power: 2
Solved Threads: 0
Well... ty both, that seemewd to help, but now i'm getting some strange new errors
Which i don't understand...
multiple definition of `main'
first defined here
.drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
[Linker error] undefined reference to `_alloca_probe'
[Linker error] undefined reference to `_alloca_probe'
[Linker error] undefined reference to `_alloca_probe' (Yeah, this error comes three times)
ld returned 1 exit status
C:\Dev-Cpp\Projekt hej\Makefile.win [Build Error] [HEJ.exe] Error 1
The two last errors should correct themselves, if the others are corrected (At least thats what i have come to understand).
But i don't understand that it says i have two main functions, cause i don't
and neither do i understand the '_alloca_probe', i haven't even used it in my source code:
Which i don't understand...multiple definition of `main'
first defined here
.drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"MSVCRT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
[Linker error] undefined reference to `_alloca_probe'
[Linker error] undefined reference to `_alloca_probe'
[Linker error] undefined reference to `_alloca_probe' (Yeah, this error comes three times)
ld returned 1 exit status
C:\Dev-Cpp\Projekt hej\Makefile.win [Build Error] [HEJ.exe] Error 1
The two last errors should correct themselves, if the others are corrected (At least thats what i have come to understand).
But i don't understand that it says i have two main functions, cause i don't
and neither do i understand the '_alloca_probe', i haven't even used it in my source code:
#include <SDL.h>
int main(int argc, char* argv[])
{
//initialize SDL and the video system.
if (SDL_Init( SDL_INIT_VIDEO)<0)
return -1;
//signal SDL to change the text of the main window to SDL "Hello World".
SDL_WM_SetCaption("Hello world","Hello World");
//Create an SDL_Surface object, which represents, the game window.
SDL_Surface* screen=SDL_SetVideoMode(640,480,0,0);
//Load the SDL logo bitmap to a temporary surface
SDL_Surface* temp=SDL_LoadBMP("data\\structures\\sdl_logo.bmp");
//Create the working SDL surface which matches the display format of the temporary surface.
SDL_Surface* bg= SDL_DisplayFormat(temp);
//Free the memory allocated to the temporary SDL_Surface.
SDL_FreeSurface(temp);
SDL_Event event;
bool quit=false;
//this is the main message loop if the game.
while(!quit)
{
//Check message qeue for an event.
if (SDL_PollEvent(&event))
{
//If an event was found.
switch (event.type)
{
//check to see if the window was closed via the "x"
case SDL_QUIT:
//Set the quit flag to true
quit=true;
break;
//Check the keyboard to see if the ESC key was pressed.
case SDL_KEYDOWN:
switch (event.key.keysym.sym)
{
case SDLK_ESCAPE:
//set our quit flag to true
quit=true;
break;
}
break;
}
}
//Draw the background sprite:
SDL_BlitSurface(bg, NULL, screen, NULL);
//Update the current window.
SDL_UpdateRect(screen,0,0,0,0);
}
//Free the allocated memery for the background surface.
SDL_FreeSurface(bg);
//Quit SDL and allow it to clean up everything.
SDL_Quit();
//return control to windows with no errors.
return 0;
}•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,541
Reputation:
Rep Power: 40
Solved Threads: 972
_alloca_probe is probably being called from one of the library functions you call. That happens a lot.
•
•
Join Date: Oct 2007
Posts: 18
Reputation:
Rep Power: 2
Solved Threads: 0
Okay... this is strange, the same errors comes, even if i break the source code down to:
#include <SDL.h>
int main(int argc, char* argv[])
{
}![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Another [Linker error] undefined reference to `WinMain@16' (C++)
- Dev C++ linker errors, undefined reference (C++)
- [Linker error] undefined reference to `CQTMovieFile::CQTMovieFile()' (C++)
- newmat linker error (C++)
- What is it meaned [Linker error] undefined reference to `MAPILogon@24' (C++)
- Dev-C++, GLUI linker error, undefined reference (C++)
- Linker Error>Undefined reference error to xyz (C++)
Other Threads in the C++ Forum
- Previous Thread: I have just need help with one function...
- Next Thread: error with int cin



Linear Mode