Subject: c++ targets
To: None <tech-toolchain@netbsd.org>
From: Andrew Brown <atatat@atatdot.net>
List: tech-toolchain
Date: 09/17/1999 19:17:17
forgive me if this is mentioned somewhere that i didn't find, but is
there a "general solution" to the problem of c++ targets other than
simply setting CC to c++ so that c++ gets called at the link instead
of cc?

for example:

   % cat Makefile
   PROG=   prog1
   SRCS=   main.cc
   NOMAN=  an island
   .include <bsd.prog.mk>
   % cat main.cc
   #include <stream.h>
   void main(void)
   {
	   cout << "Hello, world." << endl;
   }
   % make
   g++ -O  -Werror  -c main.cc
   cc   -o prog1 main.o 
   main.o: Undefined symbol `_cout' referenced from text segment
   main.o: Undefined symbol `___ls__7ostreamPCc' referenced from text segment
   main.o: Undefined symbol `_endl__FR7ostream' referenced from text segment
   *** Error code 1

as you can see, the object files get made using the c++ compiler, but
the target (built from the objects, hence using the .o suffix rule)
uses only the c compiler, which lacks a rather useful library.
setting CC to c++ at the top of the makefile fixes the link, but
strikes me as a "nasty hack".

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
andrew@crossbar.com       * "information is power -- share the wealth."