Problem building app in C++ with SDL

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

Moderators: cheriff, TyRaNiD

Post Reply
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Problem building app in C++ with SDL

Post by gambiting »

Hi! Currently,I'm working on Xmoto port to psp,but after finally completing work on makefile I can't get it build,"make" ends with following error:

Code: Select all

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -G0 -O2 -Wall -D_PSP_FW_VERSION=150 -I/usr/local/pspdev/psp/include/SDL -Dmain=SDL_main  -L. -L/usr/local/pspdev/psp/sdk/lib    -lglut -lGLU -lGL -lode -lSDLmain -lSDL -lSDL_gfx -lSDL_mixer -lpng -ljpeg -lz -lpsprtc -L/usr/local/pspdev/psp/lib -lSDLmain -lSDL -lm -lGL -lpspvfpu -L/usr/local/pspdev/psp/sdk/lib -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -L/usr/local/pspdev/psp/lib -lSDLmain -lSDL -lm -lGL -lpspvfpu -L/usr/local/pspdev/psp/sdk/lib -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -o Xmoto.elf
/usr/local/pspdev/psp/lib/libSDLmain.a(SDL_psp_main.o): In function `main':
psp/SDL_psp_main.c:178: undefined reference to `SDL_main'
collect2: ld returned 1 exit status
make: *** [Xmoto.elf] Error 1
And my makefile:

Code: Select all

# 
TARGET = Xmoto
PSPSDK = $(shell psp-config --pspsdk-path)
PSPBIN = $(shell psp-config --psp-prefix)/bin
SDL_CONFIG = $(PSPBIN)/sdl-config
OBJEXT = o

INCDIR =
USE_PSPSDK_LIBC = 1 
CFLAGS = -G0 -O2 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBS = -lglut -lGLU -lGL -lode -lSDLmain -lSDL -lSDL_gfx -lSDL_mixer -lpng -ljpeg -lz -lpsprtc -lstdc++ $(shell $(SDL_CONFIG) --libs)

OBJS =  GameMain.$(OBJEXT) BuiltInFont.$(OBJEXT) Image.$(OBJEXT) VApp.$(OBJEXT) \
	VBezier.$(OBJEXT) VDraw.$(OBJEXT) VDrawOpenGL.$(OBJEXT) \
	PolyDraw.$(OBJEXT) VDrawSDLgfx.$(OBJEXT) VFileIO.$(OBJEXT) \
	VTexture.$(OBJEXT) VXml.$(OBJEXT) $(am__objects_1) \
	$(am__objects_2) $(am__objects_3) $(am__objects_4) \
	DBuffer.$(OBJEXT) CRCHash.$(OBJEXT) Theme.$(OBJEXT) \
	WWW.$(OBJEXT) Locales.$(OBJEXT) Packager.$(OBJEXT) \
	BSP.$(OBJEXT) Game.$(OBJEXT) \
	GameMenus.$(OBJEXT) GUIBestTimes.$(OBJEXT) \
	GUIButton.$(OBJEXT) GUI.$(OBJEXT) GUIFrame.$(OBJEXT) \
	GUIList.$(OBJEXT) GUIStatic.$(OBJEXT) GUITabView.$(OBJEXT) \
	MotoGame.$(OBJEXT) MotoGameL.$(OBJEXT) MPhysics.$(OBJEXT) \
	PlayerData.$(OBJEXT) Renderer.$(OBJEXT) RendererInit.$(OBJEXT)\
	Replay.$(OBJEXT) Sound.$(OBJEXT) UserConfig.$(OBJEXT) \
	GUIXMoto.$(OBJEXT) RendererParticles.$(OBJEXT) \
	RendererBike.$(OBJEXT) Input.$(OBJEXT) \
	GameSerializer.$(OBJEXT) Collision.$(OBJEXT) GUIEdit.$(OBJEXT) \
	RendererFBO.$(OBJEXT) ReplayList.$(OBJEXT) Stats.$(OBJEXT) \
	ScriptDynamicObjects.$(OBJEXT) SomersaultCounter.$(OBJEXT) \
	GameEvents.$(OBJEXT) Credits.$(OBJEXT) GameInit.$(OBJEXT) \
	GameDrawFrame.$(OBJEXT) LevelsManager.$(OBJEXT) \
	Level.$(OBJEXT) Zone.$(OBJEXT) Block.$(OBJEXT) \
	Entity.$(OBJEXT) SkyApparence.$(OBJEXT) \
	BikeController.$(OBJEXT) BikeParameters.$(OBJEXT) \
	BikeAnchors.$(OBJEXT) Bike.$(OBJEXT) $(am__objects_8)
DEFAULT_CFLAGS = $(shell $(SDL_CONFIG) --cflags)
#MORE_CFLAGS = -g -O2
#CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
#CXXFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -fno-exceptions
EXTRA_TARGETS = EBOOT.PBP

include $(PSPSDK)/lib/build.mak
PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)
I know that there was the same problem on forum here:

Code: Select all

http://forums.ps2dev.org/viewtopic.php?t=3075&view=next&sid=7c68c1f1506dd0d80a27de57a618ace9
But none of these suggestions work here...Please help!
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Hi,

i dont remember the proper way to add the sdlmain linked but you can remove "-lSDLmain" from your makefile then just add the normal psp module info in your SDL_psp_main.c file, exemple :

Code: Select all

PSP_MODULE_INFO("SDL_TEST", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
This will also allow to output printf and stderr to psplink, what i cant do when linking with lsdlmain (dunno why).
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Re: Problem building app in C++ with SDL

Post by jimparis »

gambiting wrote:

Code: Select all

DEFAULT_CFLAGS = $(shell $(SDL_CONFIG) --cflags)
#MORE_CFLAGS = -g -O2
#CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
#CXXFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -fno-exceptions
Your main function needs to be called SDL_main and included in an "extern C" block. The symbol would already be redefined if you added $(shell $(SDL_CONFIG) --cflags) to your CFLAGS, but you have those lines commented out.
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

hehe jimparis is right, i did not notice that you commented them :)
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Hi! Thanks for quick reply,but it still won't work.I've uncommented these lines in makefile,and added

Code: Select all

extern "C" int SDL_main(int nNumArgs,char **ppcArgs) ;
at the beginning of the main file as the program starts with that function,but unfortuneltly,still no luck,same error.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

gambiting wrote:Hi! Thanks for quick reply,but it still won't work.I've uncommented these lines in makefile,and added

Code: Select all

extern "C" int SDL_main(int nNumArgs,char **ppcArgs) ;
at the beginning of the main file as the program starts with that function,but unfortuneltly,still no luck,same error.
"extern" doesn't tell the link-loader a function is in this object, it tells it it's NOT in this object. You use extern when you wish to access a function defined somewhere else.

From an online C reference:
extern

Indicates that an identifier is defined elsewhere.

Keyword extern indicates that the actual storage and initial value of a variable, or body of a function, is defined elsewhere, usually in a separate source code module. So, it may be applied to data definitions and function prototypes:

extern data-definition;
extern function-prototype;
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

I know what it does,but I just did what the other thread said about this problem....currently my code looks like that(still not working though)

Code: Select all

/*=============================================================================
XMOTO
Copyright (C) 2005-2006 Rasmus Neckelmann ([email protected])

This file is part of XMOTO.

XMOTO is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

XMOTO is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with XMOTO; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
=============================================================================*/

/* 
 *  Game main.
 */
#include <stdio.h>
#include <stdlib.h>

#include "Game.h"
#include "VFileIO.h"

using namespace vapp;

#ifndef GameMain.cpp
#define GameMain.cpp 
#ifdef __cplusplus
extern "C" &#123;
#endif 
/*===========================================================================
SDL main entry point
===========================================================================*/
//extern "C" int SDL_main&#40;int nNumArgs,char **ppcArgs&#41; ; 
int SDL_main&#40;int nNumArgs,char **ppcArgs&#41; &#123;

  /* Start application */
  try &#123;     
    /* Setup basic info */
    GameApp Game;
    
    Game.setAppName&#40;std&#58;&#58;string&#40;"X-Moto"&#41;&#41;;
    Game.setAppCommand&#40;std&#58;&#58;string&#40;"xmoto"&#41;&#41;;
    Game.setCopyrightInfo&#40;std&#58;&#58;string&#40;"&#40;C&#41; Copyright 2005-2006 Rasmus Neckelmann &#40;[email protected]&#41;"&#41;&#41;;
    Game.run&#40;nNumArgs,ppcArgs&#41;;
  &#125;
  catch &#40;Exception &e&#41; &#123;
    FS&#58;&#58;writeLog&#40;std&#58;&#58;string&#40;"Exception&#58; "&#41; + e.getMsg&#40;&#41;&#41;;
  
    printf&#40;"fatal exception &#58; %s\n",e.getMsg&#40;&#41;.c_str&#40;&#41;&#41;;        
    SDL_Quit&#40;&#41;; /* make sure SDL shuts down gracefully */

    #if defined&#40;WIN32&#41;
      char cBuf&#91;1024&#93;;
      sprintf&#40;cBuf,"Fatal exception occured&#58; %s\n"
                   "Consult the file xmoto.log for more information about what\n"
                   "might has occured.\n",e.getMsg&#40;&#41;.c_str&#40;&#41;&#41;;                    
      MessageBox&#40;NULL,cBuf,"X-Moto Error",MB_OK|MB_ICONERROR&#41;;
    #endif
  &#125;
  return 0;
&#125;
#ifdef __cplusplus
&#125;
#endif

#endif 
 

Please help.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Get rid of the "extern".
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

J.F. wrote:Get rid of the "extern".
Still the same problem....
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Probably because you aren't including any includes in the CFLAGS. Here's the line from PSP Basilisk:

Code: Select all

CFLAGS = -O2 -G0 -I../include -I. -I../uae_cpu
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Code: Select all

psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -G0 -O2 -Wall -D_PSP_FW_VERSION=150 -I/usr/local/pspdev/psp/include/SDL -Dmain=SDL_main  -L. -L/usr/local/pspdev/psp/sdk/lib    -lglut -lGLU -lGL -lode -lSDLmain -lSDL -lSDL_gfx -lSDL_mixer -lpng -ljpeg -lz -lpsprtc -L/usr/local/pspdev/psp/lib -lSDLmain -lSDL -lm -lGL -lpspvfpu -L/usr/local/pspdev/psp/sdk/lib -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -L/usr/local/pspdev/psp/lib -lSDLmain -lSDL -lm -lGL -lpspvfpu -L/usr/local/pspdev/psp/sdk/lib -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -o Xmoto.elf
/usr/local/pspdev/psp/lib/libSDLmain.a&#40;SDL_psp_main.o&#41;&#58; In function `main'&#58;
psp/SDL_psp_main.c&#58;178&#58; undefined reference to `SDL_main'
collect2&#58; ld returned 1 exit status
make&#58; *** &#91;Xmoto.elf&#93; Error 1 
Where are your object files on that command line? All you're doing is linking all of the libraries together, not any of your own code.
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Just do this ... :
Cpasjuste wrote:Hi,

i dont remember the proper way to add the sdlmain linked but you can remove "-lSDLmain" from your makefile then just add the normal psp module info in your SDL_psp_main.c file, exemple :

Code: Select all

PSP_MODULE_INFO&#40;"SDL_TEST", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;
This will also allow to output printf and stderr to psplink, what i cant do when linking with lsdlmain (dunno why).
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Cpasjuste wrote:Just do this ... :
Cpasjuste wrote:Hi,

i dont remember the proper way to add the sdlmain linked but you can remove "-lSDLmain" from your makefile then just add the normal psp module info in your SDL_psp_main.c file, exemple :

Code: Select all

PSP_MODULE_INFO&#40;"SDL_TEST", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;
This will also allow to output printf and stderr to psplink, what i cant do when linking with lsdlmain (dunno why).
I've added these lines at top of the SDL_psp_main.c file,and removed -lSDLmain from makefile,but it's still no go.And I really don't know why it's linking all libriaries together,rather than compiling my own code,I have OBJS line in my makefile,so I don't know why it's not compiling.Please help me,as I really want to do it.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

I don't know why, but your problem is definitely the fact that your link command that you quoted consists of all libraries and nothing else. You'll have to track down in your Makefile why that is happening, or maybe post your whole project somewhere and someone can take a look.
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Here you go,all project files with makefile....but don't expect it to build,it's just a first time build,I just need to get past that !@#% sdl error,then I will try to figure out the rest.Thanks!

http://rapidshare.com/files/32752321/src.zip
SamuraiX
Posts: 76
Joined: Tue Jan 31, 2006 6:28 am
Location: USA
Contact:

Post by SamuraiX »

Here you go..... You don't put these at the end of the file..... You need to know when and where to use them.... The order of operations is important in makefiles.


I've highlighted the changes.......


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

Code: Select all

# Makefile.in generated by automake 1.9.6 from Makefile.am.
# src/Makefile.  Generated from Makefile.in by configure.

# Copyright &#40;C&#41; 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005  Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

TARGET = Xmoto
PSPSDK = $&#40;shell psp-config --pspsdk-path&#41;

########## Added ###############
PSPBIN = $&#40;PSPSDK&#41;/../bin
################################

SDL_CONFIG = $&#40;PSPBIN&#41;/sdl-config

O = o
OBJEXT = o

########## Updated ###############
DEFAULT_CFLAGS = $&#40;shell $&#40;PSPBIN&#41;/sdl-config --cflags&#41;
##################################

MORE_CFLAGS = -g -O2 -Wall

CFLAGS = $&#40;DEFAULT_CFLAGS&#41; $&#40;MORE_CFLAGS&#41; -O2 -G0 -I../include -I. -I../uae_cpu

CXXFLAGS = $&#40;DEFAULT_CFLAGS&#41; $&#40;MORE_CFLAGS&#41; -fno-exceptions
INCDIR =
USE_PSPSDK_LIBC = 1 
CFLAGS = -G0 -O2 -Wall
ASFLAGS = $&#40;CFLAGS&#41;

########## Added ###############
DEFAULT_LIBS = $&#40;shell $&#40;PSPBIN&#41;/sdl-config --libs&#41;
################################

LIBS =  $&#40;DEFAULT_LIBS&#41; -lglut -lGLU -lGL -lode -lSDL -lSDL_gfx -lSDL_mixer -lpng -ljpeg -lz -lpsprtc -lstdc++ -lpspdebug -lpspgu -lpspctrl \
-lpspge -lpspdisplay -lpsphprm -lpspaudio -lc -lpspuser -lpspkernel -lpspdebug -lpspdisplay \
-lpspge -lpspctrl -lpspsdk -lc -lpspuser -lpspkernel

#These are files that are not included in the psp build,but I keep them here just in case
#OBJS =  $&#40;TARGET&#41;.$&#40;O&#41; foe.$&#40;O&#41; foecommand.$&#40;O&#41; barragemanager.$&#40;O&#41; boss.$&#40;O&#41; ship.$&#40;O&#41; laser.$&#40;O&#41; \
#        frag.$&#40;O&#41; background.$&#40;O&#41; letterrender.$&#40;O&#41; shot.$&#40;O&#41; \
#        screen.$&#40;O&#41; vector.$&#40;O&#41; degutil.$&#40;O&#41; rand.$&#40;O&#41; mt19937int.$&#40;O&#41; \
#        soundmanager.$&#40;O&#41; attractmanager.$&#40;O&#41;
# VMath.$&#40;OBJEXT&#41; SwapEndian.$&#40;OBJEXT&#41; FileCompression.$&#40;OBJEXT&#41;  Color.$&#40;OBJEXT&#41;
#  \
        #tim.$&#40;OBJEXT&#41; tim_io_stdio.$&#40;OBJEXT&#41; \
	#tim_jpeg.$&#40;OBJEXT&#41; tim_memory_crt.$&#40;OBJEXT&#41; tim_png.$&#40;OBJEXT&#41; \
        #tinystr.$&#40;OBJEXT&#41; tinyxml.$&#40;OBJEXT&#41; \
	#tinyxmlerror.$&#40;OBJEXT&#41; tinyxmlparser.$&#40;OBJEXT&#41; \
        #md5.$&#40;OBJEXT&#41; md5file.$&#40;OBJEXT&#41; \
        #blocksort.$&#40;OBJEXT&#41; bzlib.$&#40;OBJEXT&#41; compress.$&#40;OBJEXT&#41; \
	#crctable.$&#40;OBJEXT&#41; decompress.$&#40;OBJEXT&#41; huffman.$&#40;OBJEXT&#41; \
	#randtable.$&#40;OBJEXT&#41;\
OBJS =  GameMain.$&#40;OBJEXT&#41;  BuiltInFont.$&#40;OBJEXT&#41; Image.$&#40;OBJEXT&#41; VApp.$&#40;OBJEXT&#41; \
	VBezier.$&#40;OBJEXT&#41; VDraw.$&#40;OBJEXT&#41; VDrawOpenGL.$&#40;OBJEXT&#41; \
	PolyDraw.$&#40;OBJEXT&#41; VDrawSDLgfx.$&#40;OBJEXT&#41; VFileIO.$&#40;OBJEXT&#41; \
	VTexture.$&#40;OBJEXT&#41; VXml.$&#40;OBJEXT&#41; \
	DBuffer.$&#40;OBJEXT&#41; CRCHash.$&#40;OBJEXT&#41; Theme.$&#40;OBJEXT&#41; \
	WWW.$&#40;OBJEXT&#41; Locales.$&#40;OBJEXT&#41; Packager.$&#40;OBJEXT&#41; \
	BSP.$&#40;OBJEXT&#41; Game.$&#40;OBJEXT&#41; \
	GameMenus.$&#40;OBJEXT&#41; GUIBestTimes.$&#40;OBJEXT&#41; \
	GUIButton.$&#40;OBJEXT&#41; GUI.$&#40;OBJEXT&#41; GUIFrame.$&#40;OBJEXT&#41; \
	GUIList.$&#40;OBJEXT&#41; GUIStatic.$&#40;OBJEXT&#41; GUITabView.$&#40;OBJEXT&#41; \
	MotoGame.$&#40;OBJEXT&#41; MotoGameL.$&#40;OBJEXT&#41; MPhysics.$&#40;OBJEXT&#41; \
	PlayerData.$&#40;OBJEXT&#41; Renderer.$&#40;OBJEXT&#41; RendererInit.$&#40;OBJEXT&#41; \
	Replay.$&#40;OBJEXT&#41; Sound.$&#40;OBJEXT&#41; UserConfig.$&#40;OBJEXT&#41; \
	GUIXMoto.$&#40;OBJEXT&#41; RendererParticles.$&#40;OBJEXT&#41; \
	RendererBike.$&#40;OBJEXT&#41; Input.$&#40;OBJEXT&#41; \
	GameSerializer.$&#40;OBJEXT&#41; Collision.$&#40;OBJEXT&#41; GUIEdit.$&#40;OBJEXT&#41; \
	RendererFBO.$&#40;OBJEXT&#41; ReplayList.$&#40;OBJEXT&#41; Stats.$&#40;OBJEXT&#41; \
	ScriptDynamicObjects.$&#40;OBJEXT&#41; SomersaultCounter.$&#40;OBJEXT&#41; \
	GameEvents.$&#40;OBJEXT&#41; Credits.$&#40;OBJEXT&#41; GameInit.$&#40;OBJEXT&#41; \
	GameDrawFrame.$&#40;OBJEXT&#41; LevelsManager.$&#40;OBJEXT&#41; \
	Level.$&#40;OBJEXT&#41; Zone.$&#40;OBJEXT&#41; Block.$&#40;OBJEXT&#41; \
	Entity.$&#40;OBJEXT&#41; SkyApparence.$&#40;OBJEXT&#41; \
	BikeController.$&#40;OBJEXT&#41; BikeParameters.$&#40;OBJEXT&#41; \
	BikeAnchors.$&#40;OBJEXT&#41; Bike.$&#40;OBJEXT&#41;





EXTRA_TARGETS = EBOOT.PBP

include $&#40;PSPSDK&#41;/lib/build.mak
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

I don't know,maybe I'm retarded or something,but after applying your makefile this thing still refuses to build past that error.Does it gets past it if you build it?Maybe I have something wrong in my PSPSDK or SDL?I don't know,but it's really anoying,please help me,so we could end this.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Well, I don't think the CFLAGS needs "-I../uae_cpu". That was part of an example I gave from PSP Basilisk, which DOES need that. He needs all the include paths that are for HIS app here (Xmoto? ).
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

I've included all files and makefile so could someone please get it past that error?I'm not asking for making all the hard work for me,but just for solving a problem which I can't solve personally - if I could I wouldn't disturb you.Thx.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Changing CFLAGS certainly won't change the objects that are getting linked together.

Your problem starts here:

Code: Select all

#  \
        #tim.$&#40;OBJEXT&#41; tim_io_stdio.$&#40;OBJEXT&#41; \
        #tim_jpeg.$&#40;OBJEXT&#41; tim_memory_crt.$&#40;OBJEXT&#41; tim_png.$&#40;OBJEXT&#41; \                                                       
        #tinystr.$&#40;OBJEXT&#41; tinyxml.$&#40;OBJEXT&#41; \                                                                  
        #tinyxmlerror.$&#40;OBJEXT&#41; tinyxmlparser.$&#40;OBJEXT&#41; \                                                                                     
        #md5.$&#40;OBJEXT&#41; md5file.$&#40;OBJEXT&#41; \
        #blocksort.$&#40;OBJEXT&#41; bzlib.$&#40;OBJEXT&#41; compress.$&#40;OBJEXT&#41; \
        #crctable.$&#40;OBJEXT&#41; decompress.$&#40;OBJEXT&#41; huffman.$&#40;OBJEXT&#41; \
        #randtable.$&#40;OBJEXT&#41;\                                           
OBJS =  GameMain.$&#40;OBJEXT&#41;  BuiltInFont.$&#40;OBJEXT&#41; Image.$&#40;OBJEXT&#41; VApp.$&#40;OBJEXT&#41; \
        VBezier.$&#40;OBJEXT&#41; VDraw.$&#40;OBJEXT&#41; VDrawOpenGL.$&#40;OBJEXT&#41; \
Because of all those backslashes at the ends of the comment lines, the OBJS= definition is considered part of the preceding comment, and so you are never defining any OBJS. Delete the backslash from the end of "#randtable.$(OBJEXT)", or just remove those commented lines entirely, or add some blank lines between the comments and OBJS, etc.
SamuraiX
Posts: 76
Joined: Tue Jan 31, 2006 6:28 am
Location: USA
Contact:

Post by SamuraiX »

Strange...... I can get past the SDL issue with my changes unlike before with your original makefile. Perhaps SDL was not compiled and installed properly? I set the following paths within my cygwin batch file....

Code: Select all

set path=%path%;C&#58;/cygwin/usr/local/pspdev/bin

Anyway... your environment seems like it must not be setup right.... I believe. Try re-installing SDL lib.
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

jimparis wrote:Changing CFLAGS certainly won't change the objects that are getting linked together.

Your problem starts here:

Code: Select all

#  \
        #tim.$&#40;OBJEXT&#41; tim_io_stdio.$&#40;OBJEXT&#41; \
        #tim_jpeg.$&#40;OBJEXT&#41; tim_memory_crt.$&#40;OBJEXT&#41; tim_png.$&#40;OBJEXT&#41; \                                                       
        #tinystr.$&#40;OBJEXT&#41; tinyxml.$&#40;OBJEXT&#41; \                                                                  
        #tinyxmlerror.$&#40;OBJEXT&#41; tinyxmlparser.$&#40;OBJEXT&#41; \                                                                                     
        #md5.$&#40;OBJEXT&#41; md5file.$&#40;OBJEXT&#41; \
        #blocksort.$&#40;OBJEXT&#41; bzlib.$&#40;OBJEXT&#41; compress.$&#40;OBJEXT&#41; \
        #crctable.$&#40;OBJEXT&#41; decompress.$&#40;OBJEXT&#41; huffman.$&#40;OBJEXT&#41; \
        #randtable.$&#40;OBJEXT&#41;\                                           
OBJS =  GameMain.$&#40;OBJEXT&#41;  BuiltInFont.$&#40;OBJEXT&#41; Image.$&#40;OBJEXT&#41; VApp.$&#40;OBJEXT&#41; \
        VBezier.$&#40;OBJEXT&#41; VDraw.$&#40;OBJEXT&#41; VDrawOpenGL.$&#40;OBJEXT&#41; \
Because of all those backslashes at the ends of the comment lines, the OBJS= definition is considered part of the preceding comment, and so you are never defining any OBJS. Delete the backslash from the end of "#randtable.$(OBJEXT)", or just remove those commented lines entirely, or add some blank lines between the comments and OBJS, etc.
Yeah,you hit the right spot! That was it! after removing that slash it get past that error........but remembered me another thing I forget...is there a Lua lib for psp(I mean c++ libriary,I know that there's standalone version).And thanks for all people involved in solving this problem! ;-D
Rey Mafia
Posts: 3
Joined: Thu Mar 15, 2007 11:09 am

Post by Rey Mafia »

I have a similar problem, I've tried compiling this code:

Code: Select all

/* rectangles.c
 * Draws random rectangles on screen.
 */
#include <SDL.h>
#include <pspctrl.h>
#include <stdio.h>
#include <stdlib.h>

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

	SDL_Surface *screen;
	SDL_Event event;
	SDL_Color color;
	SDL_Rect rect;
	int x, y;
	int done = 0;

	SceCtrlData pad;

	/* Initialization
	 */
	if &#40; SDL_Init&#40; SDL_INIT_VIDEO &#41; < 0 &#41; &#123;
		fprintf&#40; stderr, "Error SDL_Init&#58; %s\n", SDL_GetError&#40;&#41; &#41;;
		exit&#40; 1 &#41;;
	&#125;

	screen = SDL_SetVideoMode&#40; 480, 272, 32, SDL_SWSURFACE &#41;;
	if &#40; screen == NULL &#41; &#123;
		fprintf&#40; stderr, "Error SDL_SetVideoMode&#58; %s\n", SDL_GetError&#40;&#41; &#41;;
		exit&#40; 1 &#41;;
	&#125;

	// Hides cursor
	SDL_ShowCursor&#40; 0 &#41;;

	/* Main loop
	 */
	while&#40; !done &#41; &#123;
		// Entrada
		sceCtrlReadBufferPositive&#40; &pad, 1 &#41;;
		// CROSS saves a screenshot, any other button exits
		if &#40; pad.Buttons != 0 &#41; &#123;
			if &#40; pad.Buttons & PSP_CTRL_CROSS &#41; &#123;
				SDL_SaveBMP&#40; screen, "screenshot.bmp" &#41;;
			&#125;
			else &#123;
				done = 1;
			&#125;
		&#125;

		// Random position and color
		rect.x = rand&#40;&#41; % 480;
		rect.y = rand&#40;&#41; % 272;

		rect.w = rand&#40;&#41; % &#40; 480 - rect.x &#41;;
		rect.h = rand&#40;&#41; % &#40; 272 - rect.y &#41;;

		color.r = rand&#40;&#41; % 255;
		color.g = rand&#40;&#41; % 255;
		color.b = rand&#40;&#41; % 255;
		
		// Draws a rectangle
		SDL_FillRect&#40; screen, &rect, SDL_MapRGB&#40; screen->format, color.r, color.g, color.b &#41; &#41;;

		SDL_Flip&#40; screen &#41;;
	&#125;

	SDL_Quit&#40;&#41;;
	return 0;
&#125;
and this Makefile:

Code: Select all

TARGET = rectangles
PSPSDK = $&#40;shell psp-config --pspsdk-path&#41;
PSPBIN = $&#40;shell psp-config --psp-prefix&#41;/bin
SDL_CONFIG = $&#40;PSPBIN&#41;/sdl-config
OBJS =	rectangles.o

#PSP_EBOOT_ICON = ICON0.PNG
PSP_EBOOT_TITLE = Random_rectangles

DEFAULT_CFLAGS = $&#40;shell $&#40;SDL_CONFIG&#41; --cflags&#41;
MORE_CFLAGS = -G0 -O2

CFLAGS = $&#40;DEFAULT_CFLAGS&#41; $&#40;MORE_CFLAGS&#41;
CXXFLAGS = $&#40;DEFAULT_CFLAGS&#41; $&#40;MORE_CFLAGS&#41; -fno-exceptions -fno-rtti

LIBS = $&#40;shell $&#40;SDL_CONFIG&#41; --libs&#41;

EXTRA_TARGETS = EBOOT.PBP

include $&#40;PSPSDK&#41;/lib/build.mak
It works like a charm when the source file is rectangles.c, but fails when it's rectangles.cpp:
/usr/local/pspdev/psp/lib/libSDLmain.a(SDL_psp_main.o): In function `main':
psp/SDL_psp_main.c:178: undefined reference to`SDL_main'
Any idea why it works different with C++? Or is it that I can compile only C code? Thanks in advance for your help.
Last edited by Rey Mafia on Thu May 24, 2007 7:52 am, edited 1 time in total.
gambiting
Posts: 154
Joined: Thu Aug 17, 2006 5:39 pm

Post by gambiting »

Can you write exactly the whole error you encounter?It will be helpfull...
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Rey Mafia wrote:I have the same problem
Then why would you expect us to say anything different? Read the thread!
jimparis wrote:Your main function needs to be called SDL_main and included in an "extern C" block.
Rey Mafia
Posts: 3
Joined: Thu Mar 15, 2007 11:09 am

Post by Rey Mafia »

This is the full console output:
user@system:~/Programs/psp/rectangles$ make
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -I/usr/local/pspdev/psp/include/SDL -Dmain=SDL_main -G0 -O2 -D_PSP_FW_VERSION=150 -L. -L/usr/local/pspdev/psp/sdk/lib rectangles.o -L/usr/local/pspdev/psp/lib -lSDLmain -lSDL -lm -L/usr/local/pspdev/psp/sdk/lib -lpspdebug -lpspgu -lpspctrl -lpspge -lpspdisplay -lpsphprm -lpspsdk -lpsprtc -lpspaudio -lc -lpspuser -lpsputility -lpspkernel -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o rectangles.elf
/usr/local/pspdev/psp/lib/libSDLmain.a(SDL_psp_main.o): In function `main':
psp/SDL_psp_main.c:178: undefined reference to `SDL_main'
collect2: ld returned 1
make: *** [rectangles.elf] Error 1
I get the same error message, but mine is not caused by a misplaced backslash, the error appears just by renaming the source file from rectangles.c to rectangles.cpp ??.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Wow. OK, read this sentence very carefully, I'm done with this thread now:
jimparis wrote:Your main function needs to be called SDL_main and included in an "extern C" block.
Rey Mafia
Posts: 3
Joined: Thu Mar 15, 2007 11:09 am

Post by Rey Mafia »

I solved it, just had a look at SDL_main.h:

Code: Select all

#ifdef __cplusplus
extern "C"
#endif
int main&#40;int argc, char *argv&#91;&#93;&#41; &#123;
Thanks.
Post Reply