miron@fornax.UUCP (Miron Cuperman) (03/24/91)
I am trying to compile a C++ product on the NeXT. I compiled g++ and used it to generate object-code files. Now when I try to link, it looks for the file 'ld++'. If I link this to gcc-ld, I get 'load failed' and it aborts. If I run /bin/ld, I get an undefined symbol type 0x16 ___CTOR_LIST__. If I try to build ld++ it doesn't find "a.out.h". BTW: g++ and cc++ dump core when given a '+' option (eg. '+e0'). I traced this to line 999 of gcc.c. There is a missing increment operation. It should read: >>> else if (argv[i][0] == '+') >>> n_switches++; Miron Cuperman <miron@cs.sfu.ca>
preston@LL.MIT.EDU (Steven Preston) (03/26/91)
> Come to think of it I know the gnu linker has already been tweaked for > MACH-O. Either you haven't set the build switches correctly or you > have an old version. Having a Mach-O linker apparently is only half of a solution. The C++ compiler that comes with NeXT OS2.0 still uses a "collect" step, I was surprised to find out. If you specify the -v flag, you can see the collect step. cc++ does these steps, when building an executable (with temporary filenames in place of t.R, t.S, t.O) /bin/ld -r -o t.R -lcrt0.o t.o -lc++ -lsys_s /lib/collect -o t.S t.R /bin/as t.S -o t.O /bin/ld -o t t.R t.O It is NOT one of the collect's that comes with g++, although the above sequence is what the collect2 program does, except that collect2 uses nm to generate a list of names in the t.R, which it searches for static constructors and destructors. I presume /lib/collect searches the symbol table of t.R directly, rather than use nm. The situation would be much better if cc++ put the static ctors and dtors into a __CPLUSPLUS segment, for instance, and rewrite __main(), which is called automatically by main(), to look in that segment. This is similar to the way Objective-C classes are located and linked together at startup. -- Steve Preston
miron@fornax.UUCP (Miron Cuperman) (03/26/91)
I think that a reply to my original post was lost. Please send direct email too. I now managed to get the thing working. I use collect2 from the g++ distribution with NeXT patches applied (available from various archives). The collect2 program calls /bin/ld. I added the flag -DFASCIST_ASSEMBLER to the g++ makefile so that __CTOR_LIST and __DTOR_LIST are not generated. (/bin/ld doesn't handle the symbol type). I use the system supplied libraries. Now I have to find a way to make gdb3.6 run on the NeXT, since the supplied gdb dumps core on the debugging info generated by g++1.37.1. I have yet to find how to duplicate the functionality of ptrace. I suppose I have to get the sources from NeXT. After all they are under the GPL license. ( BTW, the original NeXT 'collect' dumps core on my files. The original cc++ dumps core too with the '-g' flag. This is why I am messing around with this. :( ) Miron Cuperman <miron@cs.sfu.ca>
dennisg@kgw2.bwi.WEC.COM (Dennis Glatting) (03/27/91)
In article <2363@fornax.UUCP>, miron@fornax.UUCP (Miron Cuperman) writes: |> I think that a reply to my original post was lost. Please send |> direct email too. |> |> I now managed to get the thing working. I use collect2 from the g++ |> distribution with NeXT patches applied (available from various |> archives). The collect2 program calls /bin/ld. I added the flag |> -DFASCIST_ASSEMBLER to the g++ makefile so that __CTOR_LIST and |> __DTOR_LIST are not generated. (/bin/ld doesn't handle the symbol |> type). I use the system supplied libraries. |> |> Now I have to find a way to make gdb3.6 run on the NeXT, since the |> supplied gdb dumps core on the debugging info generated by g++1.37.1. |> I have yet to find how to duplicate the functionality of ptrace. |> |> I suppose I have to get the sources from NeXT. After all they are under |> the GPL license. |> |> ( BTW, the original NeXT 'collect' dumps core on my files. The original |> cc++ dumps core too with the '-g' flag. This is why I am messing |> around with this. :( ) |> |> Miron Cuperman <miron@cs.sfu.ca> friend, you're working too hard. the problem with the NeXT cc++ is well documented. just call NeXT or send email. i have been using cc++ for two months. In fact I recently posted a game on the purdue archives that use c++ objects as a back end. it doesn't, however, use cc++ for the link phase. to fix the collect problem place the following line in your .cshrc file: limit stacksize 10000. that is all you need to do. -- ..!uunet!kgw2!dennisg | Dennis P. Glatting dennisg@Xetron.COM | X2NeXT developer | NeXT/C++/Objective-C wienie