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 

C++ library files not compiling with pspsdk

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



Joined: 30 Sep 2008
Posts: 6

PostPosted: Tue Sep 30, 2008 10:54 am    Post subject: C++ library files not compiling with pspsdk Reply with quote

Hey all,
I'm new to the psp development scene and am having some trouble using the C++ standard library files (like "string" and "math" etc).
Basically, I have set up MinPSPW to work with VC++ 2008 and I can compile the samples no worries, but on trying to include any files not part of the psp library (and things like "stdlib.h"), I get hundreds of errors.
My makefile has
INCDIR = C:/pspsdk/psp/include/c++/4.3.2/
and without it the compiler won't find the files, but like I said I get hundreds of errors, most looking like this:
1>C:/pspsdk/psp/include/c++/4.3.2/bits/basic_string.h(836) : error: expected declaration specifiers before 'template'
but there are some variations.
I'm assuming I have something setup incorrectly or it's because I'm not using cygwin and all that to do it (honestly, I've tried that before but being able to use VC++ and build from it is much more appealing).

If anybody can give some suggestions I'd greatly appreciate it :)

Thanks in advance,
Jonathan
Back to top
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Tue Sep 30, 2008 12:10 pm    Post subject: Reply with quote

Can you post your code to your program and makefile? Sometimes, its the makefile that causes the problem.
Back to top
View user's profile Send private message AIM Address
yotryu



Joined: 30 Sep 2008
Posts: 6

PostPosted: Tue Sep 30, 2008 12:48 pm    Post subject: Reply with quote

Yeah no worries.
Here's the makefile:
Code:

TARGET = celshading
OBJS = lightmap.o celshading.o ../common/callbacks.o

INCDIR = C:/pspsdk/psp/include/c++/4.3.2
CFLAGS = -G0 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LDFLAGS =
LIBS= -lstdc++ -lpspgum -lpspgu -lm

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Celshading Sample

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

lightmap.o : lightmap.raw
   bin2o -i lightmap.raw lightmap.o lightmap


Now the program code compiles unless I add a line to include one of the files I want to use. For example:
#include <string>
will cause hundreds of errors... literally, about 700+
The full program code is just one of the samples (celshading) that I have been playing around with just to see what the PSP can do ;)
The includes of the file look like this:
Code:

#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspdebug.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <pspctrl.h>

#include <pspgu.h>
#include <pspgum.h>

#include <string>

#include "../common/callbacks.h"

PSP_MODULE_INFO("Celshading", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);


Thanks for the quick reply. I hope this helps you to help me ;)
Jonathan
Back to top
View user's profile Send private message
Dariusc123456



Joined: 12 Aug 2008
Posts: 394

PostPosted: Tue Sep 30, 2008 1:26 pm    Post subject: Reply with quote

First, remove line "PSP_MAIN_THREAD", because you have it user mode already. Maybe it will lower the errors. Ill see whats the problem, maybe its the line in the makefile that lead to the ../psp/include/c++ , dont exist. Ill see what I can do for you soon
Back to top
View user's profile Send private message AIM Address
yotryu



Joined: 30 Sep 2008
Posts: 6

PostPosted: Tue Sep 30, 2008 7:36 pm    Post subject: Reply with quote

Ok turns out one big problem was that I missed one of the first errors... it was a missing file.
So now I'm left with 38 errors (from including <string>), all of which are:
1. error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std' OR
2. error: expected '=', ',', ';', 'asm' or '__attribute__' before '__gnu_cxx' OR
3. error: expected identifier or '(' before string constant
I thought this might mean errors in the code but I really don't know. The errors are located when this is encountered (errors 1 and 2):
_GLIBCXX_BEGIN_NAMESPACE(X)

where:
# define _GLIBCXX_BEGIN_NAMESPACE(X) namespace X _GLIBCXX_VISIBILITY_ATTR(default) {

and a couple for this too (error 3):
extern "C++" {

I've not had experience with gcc errors before so I'm really not sure what I'm looking for and I can't find anything to help on these.
Thanks again for any help anyone can give :)

Jonathan
Back to top
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Tue Sep 30, 2008 10:57 pm    Post subject: Reply with quote

the extension of a c++ source file must be .cpp
Back to top
View user's profile Send private message
yotryu



Joined: 30 Sep 2008
Posts: 6

PostPosted: Wed Oct 01, 2008 12:13 am    Post subject: Reply with quote

Wow. I can't believe I let that slip past me...
I guess that's one thing that can happen if you're using other files instead of creating your own. Teach me to try out samples :P
Thanks very much for the basic advice jojojoris. I'll admit at first I thought it was a rather pointless comment...
Again thanks for the help guys :)

Jonathan
Back to top
View user's profile Send private message
a_noob



Joined: 17 Sep 2006
Posts: 97
Location: _start: jr 0xDEADBEEF

PostPosted: Wed Oct 01, 2008 3:03 pm    Post subject: Reply with quote

it can be .cpp .C .cc or .c++ all are valid C++ files
_________________
Code:
.øOº'ºOø.
'ºOo.oOº'
Back to top
View user's profile Send private message AIM Address MSN Messenger
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Thu Oct 02, 2008 2:16 am    Post subject: Reply with quote

a_noob wrote:
it can be .cpp .C .cc or .c++ all are valid C++ files


that's not true.
the toolchain compiles .C files with psp-gcc and .cpp/.c++ with psp-g++
Back to top
View user's profile Send private message
Heimdall



Joined: 10 Nov 2005
Posts: 259
Location: Netherlands

PostPosted: Thu Oct 02, 2008 2:28 am    Post subject: Reply with quote

it shouldn't, the GCC is supposed to interpret .C as C++ files thus compiling with with g++
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
hlide



Joined: 10 Sep 2006
Posts: 750

PostPosted: Thu Oct 02, 2008 5:06 am    Post subject: Reply with quote

jojojoris wrote:
a_noob wrote:
it can be .cpp .C .cc or .c++ all are valid C++ files


that's not true.
the toolchain compiles .C files with psp-gcc and .cpp/.c++ with psp-g++

you're wrong or are using a cygwin/mingw32 gcc which doesn't handle case matching.
Back to top
View user's profile Send private message
kralyk



Joined: 06 Apr 2008
Posts: 114
Location: Czech Republic, central EU

PostPosted: Thu Oct 02, 2008 5:15 am    Post subject: Reply with quote

yeah, windows fs is not case sensitive, so file.C is the same as file.c on w32
_________________
...sorry for my english...
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