C++ library files not compiling with pspsdk

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

Moderators: cheriff, TyRaNiD

Post Reply
yotryu
Posts: 6
Joined: Tue Sep 30, 2008 10:30 am

C++ library files not compiling with pspsdk

Post by yotryu »

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
Dariusc123456
Posts: 388
Joined: Tue Aug 12, 2008 12:46 am

Post by Dariusc123456 »

Can you post your code to your program and makefile? Sometimes, its the makefile that causes the problem.
yotryu
Posts: 6
Joined: Tue Sep 30, 2008 10:30 am

Post by yotryu »

Yeah no worries.
Here's the makefile:

Code: Select all

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: Select all

#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&#40;"Celshading", 0, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER&#41;;
Thanks for the quick reply. I hope this helps you to help me ;)
Jonathan
Dariusc123456
Posts: 388
Joined: Tue Aug 12, 2008 12:46 am

Post by Dariusc123456 »

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
yotryu
Posts: 6
Joined: Tue Sep 30, 2008 10:30 am

Post by yotryu »

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
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Post by jojojoris »

the extension of a c++ source file must be .cpp
yotryu
Posts: 6
Joined: Tue Sep 30, 2008 10:30 am

Post by yotryu »

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
a_noob
Posts: 97
Joined: Sun Sep 17, 2006 8:33 am
Location: _start: jr 0xDEADBEEF

Post by a_noob »

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

Code: Select all

.øOº'ºOø.
'ºOo.oOº'
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Post by jojojoris »

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++
Heimdall
Posts: 245
Joined: Thu Nov 10, 2005 1:29 am
Location: Netherlands
Contact:

Post by Heimdall »

it shouldn't, the GCC is supposed to interpret .C as C++ files thus compiling with with g++
hlide
Posts: 739
Joined: Sun Sep 10, 2006 2:31 am

Post by hlide »

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.
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

yeah, windows fs is not case sensitive, so file.C is the same as file.c on w32
...sorry for my english...
Post Reply