[comp.sys.next] C++

gessel@cs.swarthmore.edu (Daniel Mark Gessel) (04/09/91)

Has anyone gotten all of C++ working? Porting code without the stream 
libraries involves large amounts of work. Any ftp site with the header files
and libriaries (ideal solution for me)?

Thanks,

Dan

-- 
Daniel Mark Gessel
Internet: gessel@cs.swarthmore.edu

madden@prang.TEST.Vitalink.COM (Brendan Maddog Madden) (04/16/91)

Someone had asked about experiences with C++ on NeXTStep 2.0.  I will try to
summerize what I had to do to get it working.  I recieved a lot of help from
a few people (Steve Preston from Mit, especially).  I have my NeXTStation
at home and was able to get the libg++ sources at work.  I am using libg++
1.36.3.  The GNU libg++ README and texinfo files say that you should use
a version of the libg++ library that has a version number less than or 
equal to the version of the cc++ compiler.  NeXT uses 1.36.4 in NeXTStep 2.0.
I figured that it would not be wise to use a newer version of libg++.  I can't
remember the location's exact name where I got the libg++ sources.  You can
ftp to 128.95.136.1 (somewhere in washington) and then the files are located
in /pub/gnu.

I had trouble with compiling libg++ because of <time.h>
The files that compile with this header file don't compile.  You need to add
the following to the top of time.h in /g++-include/time.h

#ifdef NeXT
#define _TIME_H 1
#endif

This will allow those to compile properly.                          

Also you want to edit the libg++ Makefile and add the line

XTRAFLAGS = -DNO_LIBGXX_MALLOC -DNO_GNU_LIB3           

I had a lot of trouble because I originally did this wrong in my installation.

I am not sure about the underscores in those defines but you will know what
I mean if you look through the Makefile.  I am doing this from memory.

Also, I had trouble for a while with unresolved externals when I first started
linking my application with libg++.a.  The best way to do this is not to use
ld directly to link your C++ application.  Use cc++ to do your link.  You 
can use the -v compile option to see what this produces.  cc++ actually 
invokes two passes on the linker.  cc++ is also smart enough to pick up the
right libraries libc++.a and lib_sys.a (I think).  Don't confuse libc++.a
with libg++.a.  They are very different in size for example.  libg++ is
needed for the streams and all that.  I think libc++.a takes care of       
interaction with c and c++ but I am no expert here.  So you can compile your
application something like this

cc++ -c *.c
cc++ *.o -lg++

The first step for the compile, the second for the link.  The -v option will
help you to see if the link is finding libg++.a and you will also see it 
bring in the other necessary libraries.  I didn't really get this right 
for a couple of weeks until I let cc++ do the link for me.  After this I 
just tried some simple cout and it seems happy.

Brendan Madden
madden@eng.vitalink.com

I will only be at this Email address for another week. 
for a couple of weeks until I was just advised to let c++ do the linking.
with libg++.a.  They are very different.  All of the stuff