| View previous topic :: View next topic |
| Author |
Message |
apache37
Joined: 04 Jun 2004 Posts: 76
|
Posted: Mon Apr 18, 2005 5:14 pm Post subject: 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 ?? |
|
| Back to top |
|
 |
apache37
Joined: 04 Jun 2004 Posts: 76
|
Posted: Mon Apr 18, 2005 5:28 pm Post subject: |
|
|
Please delete this topic. I added EE_CXXFLAGS += -fno-exceptions and it worked.
Sorry bout that :) |
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Mon Apr 18, 2005 6:03 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
apache37
Joined: 04 Jun 2004 Posts: 76
|
Posted: Mon Apr 18, 2005 6:14 pm Post subject: |
|
|
| pixel wrote: | | You could also add -lstdc++ and then support exceptions... |
Cool thanks.. Am I gonna run into trouble if I want to use <vector> ? |
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Mon Apr 18, 2005 7:16 pm Post subject: |
|
|
No, it should be okay. _________________ 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. |
|
| Back to top |
|
 |
apache37
Joined: 04 Jun 2004 Posts: 76
|
Posted: Tue Apr 19, 2005 4:13 am Post subject: |
|
|
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
Last edited by apache37 on Tue Apr 19, 2005 4:14 am; edited 1 time in total |
|
| Back to top |
|
 |
apache37
Joined: 04 Jun 2004 Posts: 76
|
Posted: Tue Apr 19, 2005 4:14 am Post subject: |
|
|
| The quote button shouuld not be so close to the edit :p |
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Tue Apr 19, 2005 4:20 am Post subject: |
|
|
*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. _________________ 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. |
|
| Back to top |
|
 |
apache37
Joined: 04 Jun 2004 Posts: 76
|
Posted: Tue Apr 19, 2005 4:31 am Post subject: |
|
|
Well here are my headers:
#include <stdio.h>
#include <stdlib.h>
#include <vector>
Maybe I need to include some specific headers before vector? |
|
| Back to top |
|
 |
BraveDog
Joined: 30 Dec 2004 Posts: 29 Location: Cleveland
|
Posted: Tue Apr 19, 2005 6:25 am Post subject: |
|
|
Yes, something changed in the toolchain, becuase I was able to compile Stella at one time. Now I get this.
| Code: |
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
|
|
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Tue Apr 19, 2005 7:13 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
spambait
Joined: 17 Apr 2005 Posts: 6
|
Posted: Tue Apr 19, 2005 7:21 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Tue Apr 19, 2005 8:32 am Post subject: |
|
|
| 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. | 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.
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. |
|
| Back to top |
|
 |
BraveDog
Joined: 30 Dec 2004 Posts: 29 Location: Cleveland
|
Posted: Tue Apr 19, 2005 11:12 am Post subject: |
|
|
Pixel,
I moved $PS2SDK/ee/include/time.h to a junk filename.
Then tried to compile and yes it is moving along with no problems now. |
|
| Back to top |
|
 |
pixel
Joined: 30 Jan 2004 Posts: 791
|
Posted: Tue Apr 19, 2005 5:48 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
|