Topic: Linking C and C++ from g++
Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: Tue, 26 Jul 1994 05:23:01 GMT Raw View
broberts@kingcong.uwaterloo.ca (Brent Robertson) writes:
>I'm trying to integrate some C++ code into an existing C app, My C++ code
>along with the other C code compiles fine. Linking is another kettle of fish
>however:
You will need to use `extern "C"' as described in the comp.lang.c++ FAQ
list.
>Undefined first referenced
> symbol in file
>cout code/rt.o
>BuildSymbol__FPcPdT1iii code/rt.o
>pop__Fv code/rt.o
>cerr code/rt.o
The undefined `cout' and `cerr' are probably because you're not
linking libg++ in. You need to link using `g++' rather than `gcc',
or use the `-lg++' option at the end of the link command.
The other undefined symbols, which c++filt (from the GNU binutils
distribution) decodes as
BuildSymbol(char *, double *, double *, int, int, int)
pop(void)
are probably C functions which need to be declared as `extern "C"'.
>But I've got iostream.h and a bunch of other includes there... What am I
>doing wrong?
#including the header files does not necessarily ensure that the appropriate
libraries will be linked in.
This is a GNU C++ issue rather than a C++ standards issue,
so I'm cross-posting and redirecting followups to gnu.g++.help.
--
Fergus Henderson - fjh@munta.cs.mu.oz.au
Author: broberts@kingcong.uwaterloo.ca (Brent Robertson)
Date: Thu, 21 Jul 1994 01:50:50 GMT Raw View
I'm trying to integrate some C++ code into an existing C app, My C++ code
along with the other C code compiles fine. Linking is another kettle of fish
however:
Undefined first referenced
symbol in file
cout code/rt.o
BuildSymbol__FPcPdT1iii code/rt.o
pop__Fv code/rt.o
cerr code/rt.o
[ rt.C is the sole C++ source file in the entire app ]
But I've got iostream.h and a bunch of other includes there... What am I
doing wrong?
--
Brent :)
--------------------------------------------------------------------------------
broberts@kingcong.uwaterloo.ca University of Waterloo
Electrical and Computer Engineering
DC 3590A (519) 885-1211 ext. 5167