C++ problem
C++ problem
I know this post is not about cracking PSP AES but hopefully it's useful :p
I get a linker issue with this simple c++ file:
#include <stdio.h>
#include <stdlib.h>
class myClass
{
public:
int a;
};
int main()
{
myClass *p = new myClass;
p->a = 5;
printf("Hello Jello...[%d]\n",p->a);
return 0;
}
Here's the make:
$ make
rm -f *.elf *.o
ee-g++ -D_EE -O2 -G0 -Wall -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -I. -c stlt
ry.cpp -o stltry.o
ee-gcc -mno-crt0 -T/usr/local/ps2dev/ps2sdk/ee/startup/linkfile -L/usr/local/ps2dev/ps2sdk/ee/lib -Wl,-Ttext -Wl,0xa0000
\
-o stl.elf /usr/local/ps2dev/ps2sdk/ee/startup/crt0.o stltry.o -lpad -lc -lkernel -lc -lsyscall -lkernel
stltry.o(.data+0x11): In function `main':
stltry.cpp: undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [stl.elf] Error 1
The makefile uses these:
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
I'm using the latest toolchain script on cygwin which I just built tonite. If I just use myClass p or myClass *p it works fine. When I make a new one on the heap it shits.
Any ideas ??
I get a linker issue with this simple c++ file:
#include <stdio.h>
#include <stdlib.h>
class myClass
{
public:
int a;
};
int main()
{
myClass *p = new myClass;
p->a = 5;
printf("Hello Jello...[%d]\n",p->a);
return 0;
}
Here's the make:
$ make
rm -f *.elf *.o
ee-g++ -D_EE -O2 -G0 -Wall -I/usr/local/ps2dev/ps2sdk/ee/include -I/usr/local/ps2dev/ps2sdk/common/include -I. -c stlt
ry.cpp -o stltry.o
ee-gcc -mno-crt0 -T/usr/local/ps2dev/ps2sdk/ee/startup/linkfile -L/usr/local/ps2dev/ps2sdk/ee/lib -Wl,-Ttext -Wl,0xa0000
\
-o stl.elf /usr/local/ps2dev/ps2sdk/ee/startup/crt0.o stltry.o -lpad -lc -lkernel -lc -lsyscall -lkernel
stltry.o(.data+0x11): In function `main':
stltry.cpp: undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [stl.elf] Error 1
The makefile uses these:
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
I'm using the latest toolchain script on cygwin which I just built tonite. If I just use myClass p or myClass *p it works fine. When I make a new one on the heap it shits.
Any ideas ??
You could also add -lstdc++ and then support exceptions...
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Well here's what I get byt just including <vector> in the same file:
rm -f *.elf *.o
ee-g++ -D_EE -O2 -G0 -Wall -fno-exceptions -I/usr/local/ps2dev/ps2sdk/ee/include
-I/usr/local/ps2dev/ps2sdk/common/include -I. -c stltry.cpp -o stltry.o
In file included from /usr/local/ps2dev/ee/include/c++/3.2.2/cwchar:51,
from /usr/local/ps2dev/ee/include/c++/3.2.2/bits/fpos.h:45,
from /usr/local/ps2dev/ee/include/c++/3.2.2/iosfwd:46,
from /usr/local/ps2dev/ee/include/c++/3.2.2/bits/stl_algobase.h
:70,
from /usr/local/ps2dev/ee/include/c++/3.2.2/vector:67,
from stltry.cpp:3:
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:71: `difftime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:72: `mktime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:73: `time' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:74: `asctime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:75: `ctime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:76: `gmtime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:77: `localtime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:78: `strftime' not declared
make: *** [stltry.o] Error 1
rm -f *.elf *.o
ee-g++ -D_EE -O2 -G0 -Wall -fno-exceptions -I/usr/local/ps2dev/ps2sdk/ee/include
-I/usr/local/ps2dev/ps2sdk/common/include -I. -c stltry.cpp -o stltry.o
In file included from /usr/local/ps2dev/ee/include/c++/3.2.2/cwchar:51,
from /usr/local/ps2dev/ee/include/c++/3.2.2/bits/fpos.h:45,
from /usr/local/ps2dev/ee/include/c++/3.2.2/iosfwd:46,
from /usr/local/ps2dev/ee/include/c++/3.2.2/bits/stl_algobase.h
:70,
from /usr/local/ps2dev/ee/include/c++/3.2.2/vector:67,
from stltry.cpp:3:
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:71: `difftime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:72: `mktime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:73: `time' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:74: `asctime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:75: `ctime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:76: `gmtime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:77: `localtime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:78: `strftime' not declared
make: *** [stltry.o] Error 1
Last edited by apache37 on Tue Apr 19, 2005 4:14 am, edited 1 time in total.
*rollseyes*
Okay, I remember fixing some things for the vector<> template to work... Now, it surely is related to the #include order you do.
Yes, I know, this is not really good. Try #include the various stdio.h and stuff from ps2sdk BEFORE including anything else in your test file.
Okay, I remember fixing some things for the vector<> template to work... Now, it surely is related to the #include order you do.
Yes, I know, this is not really good. Try #include the various stdio.h and stuff from ps2sdk BEFORE including anything else in your test file.
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Yes, something changed in the toolchain, becuase I was able to compile Stella at one time. Now I get this.
Code: Select all
In file included from /usr/local/ps2dev/ee/include/c++/3.2.2/cwchar:51,
from /usr/local/ps2dev/ee/include/c++/3.2.2/bits/fpos.h:45,
from /usr/local/ps2dev/ee/include/c++/3.2.2/iosfwd:46,
from /usr/local/ps2dev/ee/include/c++/3.2.2/ios:44,
from /usr/local/ps2dev/ee/include/c++/3.2.2/ostream:45,
from /usr/local/ps2dev/ee/include/c++/3.2.2/iostream:45,
from ../emucore/m6502/src/bspf/src/bspf.hxx:49,
from ../emucore/Event.hxx:24,
from ../emucore/Booster.cxx:19:
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:71: `difftime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:72: `mktime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:73: `time' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:74: `asctime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:75: `ctime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:76: `gmtime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:77: `localtime' not declared
/usr/local/ps2dev/ee/include/c++/3.2.2/ctime:78: `strftime' not declared
make[2]: *** [Booster.o] Error 1
make[1]: *** [ps2] Error 2
make: *** [default] Error 2
Okay, I think I know what's wrong. Can you guys try to remove/rename the time.h file in the ee/include directory ?
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
I have already ps2sdk patches that solve the cstddef and ctime problems. Maybe somebody code could send me a Personal Message on this board where to mail these.
A more severe problem, though, is that libstdc++ seems to be built against newlib, causing lot's of unresolved symbols.
Maybe the cross toolchain should be revisited, usually you do
1) build cross binutils
2) build a minimal cross-gcc
3) use minimal gcc to build cross libraries ("ps2sdk")
4) build a full gcc, using headers and libs from 3)
5) use full gcc to rebuild cross libraries again [optional step]
Basically this means doing away with newlib, but probably ps2sdk is not complete yet as a substitute. It probably also means moving a lot more symbols into libc so that -lc does not depend on anything but crt* and -lgcc.
A more severe problem, though, is that libstdc++ seems to be built against newlib, causing lot's of unresolved symbols.
Maybe the cross toolchain should be revisited, usually you do
1) build cross binutils
2) build a minimal cross-gcc
3) use minimal gcc to build cross libraries ("ps2sdk")
4) build a full gcc, using headers and libs from 3)
5) use full gcc to rebuild cross libraries again [optional step]
Basically this means doing away with newlib, but probably ps2sdk is not complete yet as a substitute. It probably also means moving a lot more symbols into libc so that -lc does not depend on anything but crt* and -lgcc.
ps2sdk is really not a complete newlib substitute. Any attempt to fully use the libstdc++ (that is, to use full STL streams and stuff) without newlib will result in a failure anyway.spambait wrote:Basically this means doing away with newlib, but probably ps2sdk is not complete yet as a substitute. It probably also means moving a lot more symbols into libc so that -lc does not depend on anything but crt* and -lgcc.
Now, it is true that one can compile some parts of the libstdc++ using ps2sdk as a substitute. If you have patches to submit, on ps2sdk and/or the toolchain script, feel free to do so, as I said, either here, or on IRC.
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Thank you. I'll try to complete time.h so that it complies with the posix standard...
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.