:: PlayerAdvance.org ::  

Précédent   :: PlayerAdvance.org :: > :: Forums Hébergés :: > OldSchool Library > Aide au développement

Aide au développement Aide sur l'utilisation d'OSLib

Publicité

Réponse
 
Outils de la discussion Modes d'affichage
Vieux 10/04/2008, 22h19   #1
schmendrick
 
Messages: n/a
Par défaut Compiling OSLib in C++

Bonjour,

first off, this library really kicks ass! great that its existing.

but what i would want to do:

compile a program with C++ instead of pure C.

i have seen a thread saying that actually it should be possible to compile C++.

unfortunately as soon as i try to compile in C++, the procedure fails with errors.

example:

i take the first example (Hello World) from the wiki page:
http://oslib.playeradvance.org/doku.php?id=day2


i copy paste the c code into a main.cpp file, i copy paste the code for the makefile into my makefile.
i copy a icon0.png file into the directory.
i compile --> success.

now i try to compile C++:
i take the main.c file and rename it to main.cpp.
i open the file, and change

Citation:
#include <oslib/oslib.h>
to

Citation:
extern "C"
{
#include <oslib/oslib.h>
}
i do not change the makefile, there is already
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
in there by default.

i now run "make clean", and run make.

i now get the following error:

Citation:
g:/pspdev/psp/sdk/lib/libosl.a(oslib.o): In function `oslSetupFTrigo':
/home/Florian/oslib/oslib.c:106: multiple definition of `osl_powerCallback'
main.o.sbss+0x4): first defined here
collect2: ld returned 1 exit status
make: *** [test.elf] Error 1


the thread i found mentioned that the guy played with the CFLAGS, so i tried

Citation:
-G0 -Wall -O2
instead of
Citation:
-G4 -Wall -O2
still no success.


can anyone help me? i would greatly appreciate it!!!!
if you can help me get it to run then i would also like to write a short tutorial for people after me trying the same thing, so the guys after me have an easier time

if you need to know the version of oslib i use, please tell me where i can find it, i do not find a version reference anywhere.


btw: yes, i also tried NOT to add the extern "C" to the sample. it still does not work.

thanks in advance!

mes remerciments

schmendrick
  Réponse avec citation

Publicité

Vieux 14/04/2008, 16h50   #2
daaa57150
Membre confirmé
 
Date d'inscription: 16/05/2007
Messages: 411
Voir l'identifiant PSN
Par défaut

Are you compiling the sources of oslib with your program ?
This looks like it (reference to oslib.c !!?), or it's the configuration of your IDE or compiler that is wrong...
I can't see an other explanation because I'm using OSLib and I write and compile all my stuff in C++, and everything works.
__________________
Essayez mon dernier jeu sur iPhone:

daaa57150 est déconnecté   Réponse avec citation
Vieux 16/04/2008, 00h24   #3
NekoGráfico
Newbie
 
Date d'inscription: 16/04/2008
Messages: 3
Par défaut

Please try using this as your makefile.

Code:
TARGET = test
OBJS = main.o 

INCDIR = 
CFLAGS = -G4 -Wall -O2 
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =
STDLIBS = -lstdc++ -losl -lpng -lz \
		  -lpspsdk -lpspctrl -lpspumd \
		  -lpsprtc -lpsppower -lpspgu \
		  -lpspaudiolib -lpspaudio  -lm -lmikmod  

LIBS=$(STDLIBS)$(YOURLIBS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = test
PSP_EBOOT_ICON = ICON0.png


PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
NekoGráfico est déconnecté   Réponse avec citation
Vieux 21/04/2008, 23h50   #4
schmendrick
 
Messages: n/a
Par défaut finally done

thank you for your suggestions!

i completely removed my development environment for psp and began reinstalling:

this time i relied on the MINPSPW project instead of doing all the cygwin stuff. after that i then used the makefile of Neko Grafico and now it compiles with C++.

Thanks!

so here a HowTo to set up Oslib with C++ to run from the scratch.
if you can think of a better place to put this, you are welcome to do so, maybe its even something for brunni to put onto the wiki? i will definetly repost it in my blog

---------------

This small turorial guides you how to get going creating C++ applications for your PSP with the OldSchool Library (at the moment of writing that is Oslib Version 2.10 Alpha) with Visual Studio Express 2008.
At the end you will have a compiled program that you then can run on your PSP (if you know how).
This tutorial will use the tools provided by the MINPSPW project. The advantage of this is that you will not need Cygwin for it to run. For getting this tutorial done you should not need any knowledge about Makefiles or toolchains as long as you are a bit familiar with visual studio and know what to do with the EBOOT.PBP that pops out after you compiled your program/project.

At first i assume you have Visual Studio (Express) installed and working and want to use it for developing Oslib. If you do not have so yet, go to

http://www.microsoft.com/express/vc/


Now you need to install the PSPSDK. But beforehand, you should install MSYS.
It can be found here.
Download the latest .exe and install it.


After you did the installation, a shell will open up asking you if you want to perform a post install. Press "y". When asked if you have MinGW installed you most probalby will want to press "n". At least you did not install MinGW with this tutorial (plus won't need it). The shell will now ask you to press ENTER. Be a good boy and do so

Now we finally need to install the PSPSDK.
For this, go to
http://minpspw.sourceforge.net/archives/cat_sdk.html and download the latest version.
For this tutorial i took the version PSPSDK 0.7.2., but if there is a newer one i'm pretty sure that'll do just as well.

Download the .exe and install. In the installer, dont forget to tick the checkbox saying that you want VS support.

For a detailed installation instruction, a tutorial on how to install MINPSPW with VC can be found on the jetcube site. You should follow that tutorial for making sure that you set up Visual Studio correctly.
At the moment this tutorial is on
http://www.jetcube.eu/archives/2008/02/entry_74.html.

Follow the tutorial until the end.

Now it's time to compile in Visual Studio with Oslib. For this, go to
http://minpspw.sourceforge.net/archives/cat_devpak.html.
Search for "Old School Lib DEVPAK".
At the moment of writing the version is "OSLib-2.10". Download it and try to execute it. The installer will probably mourn that some other package is missing and will abort installation. Remember the name of the missing package, and go back to
http://minpspw.sourceforge.net/archives/cat_devpak.html, search for the name the installer mentioned, download it and install. Now try again to install the Oslib package you already downloaded.

finally after some tries (after 2 more package-installs for me), the oslib package installer proceeds with the installation. After it sucessfully installed, open up VS.
Create a new Makefile project similar to what was described in the tutorial (the one that can be found at
http://www.jetcube.eu/archives/2008/02/entry_74.html.

in a completely new folder.

Add a main.cpp file to the project.

Go to the oslib wiki page and take the hello world example found here :
http://oslib.playeradvance.org/doku.php?id=day2

copy-paste the code to your main.cpp

to test if you really can compile C++, insert the following code into the space below the line saying "PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);"

and above the line saying "int main()"

Citation:
class TestClass
{
};
now open up the Makefile in your project folder, or if non is existing yet, create one. Creating it is simple: just create a file with the name "Makefile". Now open it up. Copy paste the following code inside that was provided by Neko Grafico (for which he deserves my special thanks)

Citation:
TARGET = main
OBJS = main.o

INCDIR =
CFLAGS = -G4 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =
STDLIBS = -lstdc++ -losl -lpng -lz \
-lpspsdk -lpspctrl -lpspumd \
-lpsprtc -lpsppower -lpspgu \
-lpspaudiolib -lpspaudio -lm -lmikmod

LIBS=$(STDLIBS)$(YOURLIBS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = test
PSP_EBOOT_ICON = ICON0.png


PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

copy a small .PNG file into the project directory where your main.cpp and Makefile are placed. Rename the .PNG file to icon0.PNG. Switch to Visual Studio. Press F7 to compile.

That's it, if everything was done correctly you should now have an EBOOT.PBP that you can copy onto your PSP! Congrats!
  Réponse avec citation
Vieux 22/04/2008, 17h09   #5
Llanowyn
Newbie
 
Date d'inscription: 06/03/2008
Messages: 3
Par défaut

I can confirm that this works. Do you know of any limitations of doing things this way as opposed to a cygwin environment?
Llanowyn est déconnecté   Réponse avec citation
Réponse

Liens sociaux

Publicité



Utilisateurs regardant la discussion actuelle : 1 (0 membre(s) et 1 invité(s))
 
Outils de la discussion
Modes d'affichage

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 22h35.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd. Tous droits réservés.
Version française #16 par l'association vBulletin francophone
Design par Ass-Itch, DJP et Dr.Vince