| View previous topic :: View next topic |
| Author |
Message |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Tue May 22, 2007 3:09 am Post subject: Problem building app in C++ with SDL |
|
|
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: | 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: | #
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: | | http://forums.ps2dev.org/viewtopic.php?t=3075&view=next&sid=7c68c1f1506dd0d80a27de57a618ace9 |
But none of these suggestions work here...Please help! |
|
| Back to top |
|
 |
Cpasjuste
Joined: 29 May 2005 Posts: 214
|
Posted: Tue May 22, 2007 3:41 am Post subject: |
|
|
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: |
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). |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Tue May 22, 2007 3:45 am Post subject: Re: Problem building app in C++ with SDL |
|
|
| gambiting wrote: | | Code: | 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. |
|
| Back to top |
|
 |
Cpasjuste
Joined: 29 May 2005 Posts: 214
|
Posted: Tue May 22, 2007 4:05 am Post subject: |
|
|
| hehe jimparis is right, i did not notice that you commented them :) |
|
| Back to top |
|
 |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Tue May 22, 2007 4:11 am Post subject: |
|
|
Hi! Thanks for quick reply,but it still won't work.I've uncommented these lines in makefile,and added
| Code: | | 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. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Tue May 22, 2007 5:06 am Post subject: |
|
|
| gambiting wrote: | Hi! Thanks for quick reply,but it still won't work.I've uncommented these lines in makefile,and added
| Code: | | 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:
| Quote: | 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; |
|
|
| Back to top |
|
 |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Tue May 22, 2007 5:15 am Post subject: |
|
|
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: | /*=============================================================================
XMOTO
Copyright (C) 2005-2006 Rasmus Neckelmann (neckelmann@gmail.com)
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" {
#endif
/*===========================================================================
SDL main entry point
===========================================================================*/
//extern "C" int SDL_main(int nNumArgs,char **ppcArgs) ;
int SDL_main(int nNumArgs,char **ppcArgs) {
/* Start application */
try {
/* Setup basic info */
GameApp Game;
Game.setAppName(std::string("X-Moto"));
Game.setAppCommand(std::string("xmoto"));
Game.setCopyrightInfo(std::string("(C) Copyright 2005-2006 Rasmus Neckelmann (neckelmann@gmail.com)"));
Game.run(nNumArgs,ppcArgs);
}
catch (Exception &e) {
FS::writeLog(std::string("Exception: ") + e.getMsg());
printf("fatal exception : %s\n",e.getMsg().c_str());
SDL_Quit(); /* make sure SDL shuts down gracefully */
#if defined(WIN32)
char cBuf[1024];
sprintf(cBuf,"Fatal exception occured: %s\n"
"Consult the file xmoto.log for more information about what\n"
"might has occured.\n",e.getMsg().c_str());
MessageBox(NULL,cBuf,"X-Moto Error",MB_OK|MB_ICONERROR);
#endif
}
return 0;
}
#ifdef __cplusplus
}
#endif
#endif
|
Please help. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Tue May 22, 2007 5:41 am Post subject: |
|
|
| Get rid of the "extern". |
|
| Back to top |
|
 |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Tue May 22, 2007 5:47 am Post subject: |
|
|
| J.F. wrote: | | Get rid of the "extern". | Still the same problem.... |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Tue May 22, 2007 7:48 am Post subject: |
|
|
Probably because you aren't including any includes in the CFLAGS. Here's the line from PSP Basilisk:
| Code: | | CFLAGS = -O2 -G0 -I../include -I. -I../uae_cpu |
|
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Tue May 22, 2007 8:35 am Post subject: |
|
|
| Quote: | | Code: | 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 |
|
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. |
|
| Back to top |
|
 |
Cpasjuste
Joined: 29 May 2005 Posts: 214
|
Posted: Tue May 22, 2007 10:04 am Post subject: |
|
|
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: |
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). |
|
|
| Back to top |
|
 |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Tue May 22, 2007 2:43 pm Post subject: |
|
|
| 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: |
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). |
| 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. |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Tue May 22, 2007 4:38 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Wed May 23, 2007 1:08 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
SamuraiX
Joined: 31 Jan 2006 Posts: 76 Location: USA
|
Posted: Wed May 23, 2007 3:08 am Post subject: |
|
|
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: | # Makefile.in generated by automake 1.9.6 from Makefile.am.
# src/Makefile. Generated from Makefile.in by configure.
# Copyright (C) 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 = $(shell psp-config --pspsdk-path)
########## Added ###############
PSPBIN = $(PSPSDK)/../bin
################################
SDL_CONFIG = $(PSPBIN)/sdl-config
O = o
OBJEXT = o
########## Updated ###############
DEFAULT_CFLAGS = $(shell $(PSPBIN)/sdl-config --cflags)
##################################
MORE_CFLAGS = -g -O2 -Wall
CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -O2 -G0 -I../include -I. -I../uae_cpu
CXXFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -fno-exceptions
INCDIR =
USE_PSPSDK_LIBC = 1
CFLAGS = -G0 -O2 -Wall
ASFLAGS = $(CFLAGS)
########## Added ###############
DEFAULT_LIBS = $(shell $(PSPBIN)/sdl-config --libs)
################################
LIBS = $(DEFAULT_LIBS) -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 = $(TARGET).$(O) foe.$(O) foecommand.$(O) barragemanager.$(O) boss.$(O) ship.$(O) laser.$(O) \
# frag.$(O) background.$(O) letterrender.$(O) shot.$(O) \
# screen.$(O) vector.$(O) degutil.$(O) rand.$(O) mt19937int.$(O) \
# soundmanager.$(O) attractmanager.$(O)
# VMath.$(OBJEXT) SwapEndian.$(OBJEXT) FileCompression.$(OBJEXT) Color.$(OBJEXT)
# \
#tim.$(OBJEXT) tim_io_stdio.$(OBJEXT) \
#tim_jpeg.$(OBJEXT) tim_memory_crt.$(OBJEXT) tim_png.$(OBJEXT) \
#tinystr.$(OBJEXT) tinyxml.$(OBJEXT) \
#tinyxmlerror.$(OBJEXT) tinyxmlparser.$(OBJEXT) \
#md5.$(OBJEXT) md5file.$(OBJEXT) \
#blocksort.$(OBJEXT) bzlib.$(OBJEXT) compress.$(OBJEXT) \
#crctable.$(OBJEXT) decompress.$(OBJEXT) huffman.$(OBJEXT) \
#randtable.$(OBJEXT)\
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) \
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)
EXTRA_TARGETS = EBOOT.PBP
include $(PSPSDK)/lib/build.mak
|
|
|
| Back to top |
|
 |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Wed May 23, 2007 3:47 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Wed May 23, 2007 4:40 am Post subject: |
|
|
| 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? ). |
|
| Back to top |
|
 |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Wed May 23, 2007 5:25 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Wed May 23, 2007 5:44 am Post subject: |
|
|
Changing CFLAGS certainly won't change the objects that are getting linked together.
Your problem starts here:
| Code: |
# \
#tim.$(OBJEXT) tim_io_stdio.$(OBJEXT) \
#tim_jpeg.$(OBJEXT) tim_memory_crt.$(OBJEXT) tim_png.$(OBJEXT) \
#tinystr.$(OBJEXT) tinyxml.$(OBJEXT) \
#tinyxmlerror.$(OBJEXT) tinyxmlparser.$(OBJEXT) \
#md5.$(OBJEXT) md5file.$(OBJEXT) \
#blocksort.$(OBJEXT) bzlib.$(OBJEXT) compress.$(OBJEXT) \
#crctable.$(OBJEXT) decompress.$(OBJEXT) huffman.$(OBJEXT) \
#randtable.$(OBJEXT)\
OBJS = GameMain.$(OBJEXT) BuiltInFont.$(OBJEXT) Image.$(OBJEXT) VApp.$(OBJEXT) \
VBezier.$(OBJEXT) VDraw.$(OBJEXT) VDrawOpenGL.$(OBJEXT) \
|
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. |
|
| Back to top |
|
 |
SamuraiX
Joined: 31 Jan 2006 Posts: 76 Location: USA
|
Posted: Wed May 23, 2007 5:53 am Post subject: |
|
|
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: | | set path=%path%;C:/cygwin/usr/local/pspdev/bin |
Anyway... your environment seems like it must not be setup right.... I believe. Try re-installing SDL lib. |
|
| Back to top |
|
 |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Wed May 23, 2007 6:14 am Post subject: |
|
|
| jimparis wrote: | Changing CFLAGS certainly won't change the objects that are getting linked together.
Your problem starts here:
| Code: |
# \
#tim.$(OBJEXT) tim_io_stdio.$(OBJEXT) \
#tim_jpeg.$(OBJEXT) tim_memory_crt.$(OBJEXT) tim_png.$(OBJEXT) \
#tinystr.$(OBJEXT) tinyxml.$(OBJEXT) \
#tinyxmlerror.$(OBJEXT) tinyxmlparser.$(OBJEXT) \
#md5.$(OBJEXT) md5file.$(OBJEXT) \
#blocksort.$(OBJEXT) bzlib.$(OBJEXT) compress.$(OBJEXT) \
#crctable.$(OBJEXT) decompress.$(OBJEXT) huffman.$(OBJEXT) \
#randtable.$(OBJEXT)\
OBJS = GameMain.$(OBJEXT) BuiltInFont.$(OBJEXT) Image.$(OBJEXT) VApp.$(OBJEXT) \
VBezier.$(OBJEXT) VDraw.$(OBJEXT) VDrawOpenGL.$(OBJEXT) \
|
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 |
|
| Back to top |
|
 |
Rey Mafia
Joined: 15 Mar 2007 Posts: 3
|
Posted: Wed May 23, 2007 11:08 pm Post subject: |
|
|
I have a similar problem, I've tried compiling this code:
| Code: |
/* rectangles.c
* Draws random rectangles on screen.
*/
#include <SDL.h>
#include <pspctrl.h>
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char* argv[] ) {
SDL_Surface *screen;
SDL_Event event;
SDL_Color color;
SDL_Rect rect;
int x, y;
int done = 0;
SceCtrlData pad;
/* Initialization
*/
if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
fprintf( stderr, "Error SDL_Init: %s\n", SDL_GetError() );
exit( 1 );
}
screen = SDL_SetVideoMode( 480, 272, 32, SDL_SWSURFACE );
if ( screen == NULL ) {
fprintf( stderr, "Error SDL_SetVideoMode: %s\n", SDL_GetError() );
exit( 1 );
}
// Hides cursor
SDL_ShowCursor( 0 );
/* Main loop
*/
while( !done ) {
// Entrada
sceCtrlReadBufferPositive( &pad, 1 );
// CROSS saves a screenshot, any other button exits
if ( pad.Buttons != 0 ) {
if ( pad.Buttons & PSP_CTRL_CROSS ) {
SDL_SaveBMP( screen, "screenshot.bmp" );
}
else {
done = 1;
}
}
// Random position and color
rect.x = rand() % 480;
rect.y = rand() % 272;
rect.w = rand() % ( 480 - rect.x );
rect.h = rand() % ( 272 - rect.y );
color.r = rand() % 255;
color.g = rand() % 255;
color.b = rand() % 255;
// Draws a rectangle
SDL_FillRect( screen, &rect, SDL_MapRGB( screen->format, color.r, color.g, color.b ) );
SDL_Flip( screen );
}
SDL_Quit();
return 0;
}
|
and this Makefile:
| Code: |
TARGET = rectangles
PSPSDK = $(shell psp-config --pspsdk-path)
PSPBIN = $(shell psp-config --psp-prefix)/bin
SDL_CONFIG = $(PSPBIN)/sdl-config
OBJS = rectangles.o
#PSP_EBOOT_ICON = ICON0.PNG
PSP_EBOOT_TITLE = Random_rectangles
DEFAULT_CFLAGS = $(shell $(SDL_CONFIG) --cflags)
MORE_CFLAGS = -G0 -O2
CFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS)
CXXFLAGS = $(DEFAULT_CFLAGS) $(MORE_CFLAGS) -fno-exceptions -fno-rtti
LIBS = $(shell $(SDL_CONFIG) --libs)
EXTRA_TARGETS = EBOOT.PBP
include $(PSPSDK)/lib/build.mak
|
It works like a charm when the source file is rectangles.c, but fails when it's rectangles.cpp:
| Quote: |
/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 |
|
| Back to top |
|
 |
gambiting
Joined: 17 Aug 2006 Posts: 154
|
Posted: Wed May 23, 2007 11:43 pm Post subject: |
|
|
| Can you write exactly the whole error you encounter?It will be helpfull... |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Thu May 24, 2007 2:17 am Post subject: |
|
|
| 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. |
|
|
| Back to top |
|
 |
Rey Mafia
Joined: 15 Mar 2007 Posts: 3
|
Posted: Thu May 24, 2007 8:07 am Post subject: |
|
|
This is the full console output:
| Quote: |
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 ??. |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Thu May 24, 2007 3:55 pm Post subject: |
|
|
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.
|
|
|
| Back to top |
|
 |
Rey Mafia
Joined: 15 Mar 2007 Posts: 3
|
Posted: Sat May 26, 2007 1:23 pm Post subject: |
|
|
I solved it, just had a look at SDL_main.h:
| Code: |
#ifdef __cplusplus
extern "C"
#endif
int main(int argc, char *argv[]) {
|
Thanks. |
|
| Back to top |
|
 |
|