forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem building app in C++ with SDL

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Tue May 22, 2007 3:09 am    Post subject: Problem building app in C++ with SDL Reply with quote

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
View user's profile Send private message
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Tue May 22, 2007 3:41 am    Post subject: Reply with quote

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
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Tue May 22, 2007 3:45 am    Post subject: Re: Problem building app in C++ with SDL Reply with quote

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
View user's profile Send private message
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Tue May 22, 2007 4:05 am    Post subject: Reply with quote

hehe jimparis is right, i did not notice that you commented them :)
Back to top
View user's profile Send private message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Tue May 22, 2007 4:11 am    Post subject: Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue May 22, 2007 5:06 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Tue May 22, 2007 5:15 am    Post subject: Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue May 22, 2007 5:41 am    Post subject: Reply with quote

Get rid of the "extern".
Back to top
View user's profile Send private message AIM Address
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Tue May 22, 2007 5:47 am    Post subject: Reply with quote

J.F. wrote:
Get rid of the "extern".
Still the same problem....
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue May 22, 2007 7:48 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Tue May 22, 2007 8:35 am    Post subject: Reply with quote

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
View user's profile Send private message
Cpasjuste



Joined: 29 May 2005
Posts: 214

PostPosted: Tue May 22, 2007 10:04 am    Post subject: Reply with quote

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
View user's profile Send private message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Tue May 22, 2007 2:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Tue May 22, 2007 4:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Wed May 23, 2007 1:08 am    Post subject: Reply with quote

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
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Wed May 23, 2007 3:08 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Wed May 23, 2007 3:47 am    Post subject: Reply with quote

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
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Wed May 23, 2007 4:40 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Wed May 23, 2007 5:25 am    Post subject: Reply with quote

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
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Wed May 23, 2007 5:44 am    Post subject: Reply with quote

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
View user's profile Send private message
SamuraiX



Joined: 31 Jan 2006
Posts: 76
Location: USA

PostPosted: Wed May 23, 2007 5:53 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Wed May 23, 2007 6:14 am    Post subject: Reply with quote

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
View user's profile Send private message
Rey Mafia



Joined: 15 Mar 2007
Posts: 3

PostPosted: Wed May 23, 2007 11:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
gambiting



Joined: 17 Aug 2006
Posts: 154

PostPosted: Wed May 23, 2007 11:43 pm    Post subject: Reply with quote

Can you write exactly the whole error you encounter?It will be helpfull...
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu May 24, 2007 2:17 am    Post subject: Reply with quote

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
View user's profile Send private message
Rey Mafia



Joined: 15 Mar 2007
Posts: 3

PostPosted: Thu May 24, 2007 8:07 am    Post subject: Reply with quote

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
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu May 24, 2007 3:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Rey Mafia



Joined: 15 Mar 2007
Posts: 3

PostPosted: Sat May 26, 2007 1:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group