undefined reference to SDL_Init

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Neizan
Posts: 10
Joined: Wed Oct 31, 2007 8:19 am

undefined reference to SDL_Init

Post by Neizan »

Hi,

I´m here again and I have another new problem.

I'm trying to use SDL libraries. My program looks like this:

Code: Select all

#include <pspkernel.h>
#include <SDL/SDL.h>

...

int main&#40;int argc, char* argv&#91;&#93;&#41;
&#123;
    SetupCallbacks&#40;&#41;;

    SDL_Init&#40;SDL_INIT_VIDEO|SDL_INIT_AUDIO&#41;;

...
    
    SDL_Quit&#40;&#41;;
    sceKernelExitGame&#40;&#41;;
    return 0;
&#125;

...
When I compile, I get the following error:

Code: Select all

main.cpp&#58;&#40;.text+0x144&#41;&#58; referencia a `SDL_Init' sin definir
main.cpp&#58;&#40;.text+0x15c&#41;&#58; referencia a `SDL_Quit' sin definir
In English:

Code: Select all

main.cpp&#58;&#40;.text+0x144&#41;&#58; undefined reference to `SDL_Init'
main.cpp&#58;&#40;.text+0x15c&#41;&#58; undefined reference to `SDL_Quit'
SDL.h looks like this:

Code: Select all

#ifndef _SDL_H
#define _SDL_H

#include "SDL_main.h"
#include "SDL_types.h"
#include "SDL_getenv.h"
#include "SDL_error.h"
#include "SDL_rwops.h"
#include "SDL_timer.h"
#include "SDL_audio.h"
#include "SDL_cdrom.h"
#include "SDL_joystick.h"
#include "SDL_events.h"
#include "SDL_video.h"
#include "SDL_byteorder.h"
#include "SDL_version.h"

#include "begin_code.h"

...

extern DECLSPEC int SDLCALL SDL_Init&#40;Uint32 flags&#41;;

...

extern DECLSPEC void SDLCALL SDL_Quit&#40;void&#41;;

...

#include "close_code.h"

...
SDL_Init and SDL_Quit are declared as extern functions, but I searched in every library included and they aren't defined there.


Any suggestion?


EDIT: I don't know so much about Makefile, may be I need to add some library there?

Code: Select all

...
LIBS = -unknown_option
...
Sorry for my ignorance :S
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

SDL/README.PSP
Building applications
---------------------
Write your source file as you would a normal SDL program. Use the standard
Makefile as supplied with any PSPSDK sample program. Above the final "include"
line, add:

PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)
Post Reply