Compatible Support Forums: undefined reference to `ostream::operator<<(char const *)'

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

undefined reference to `ostream::operator<<(char const *)'

#1 User is offline   lenja 

  • stranger
  • Group: Members
  • Posts: 4
  • Joined: 10-April 04

Posted 10 April 2004 - 04:22 PM

Compiler: gcc-2.91.66
Simple program: lheed_a2ia.c
Linked library: lheed.so (GCC: (GNU) egcs-2.91.66 19990314/Linux (egcs-1.1.2 release))
I have got errors in link:

gmake all-recursive
gmake[1]: Entering directory `/home/lenja/lheed_a2ia'
Making all in lheed_a2ia
gmake[2]: Entering directory `/home/lenja/lheed_a2ia/lheed_a2ia'
/bin/sh ../libtool --silent --mode=link --tag=CXX g++ -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall
-pedantic -W -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align
-Wconversion -fno-builtin -g -O2 -O0 -g3 -Wall -fno-exceptions -fno-check-new -o lheed_a2ia lheed_a2ia.o
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: the use of `tmpnam' is dangerous, better use `mkstemp'
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: undefined reference to `cerr'
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: undefined reference to `__pure_virtual'
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: undefined reference to `__cp_push_exception'
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: undefined reference to `char type_info node'
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: undefined reference to `__ctype_b'
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: undefined reference to `endl(ostream &)'
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: undefined reference to `char type_info function'
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: undefined reference to `__uncatch_exception'
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: undefined reference to `__out_of_range(char const *)'
undefined reference to `ostream::operator<<(char const *)'
/home/lenja/checkreader/adsdb_8_2/lib/redhat61/libAdsDBApi.so: collect2: ld returned 1 exit status
gmake[2]: *** [lheed_a2ia] Error 1
gmake[2]: Leaving directory `/home/lenja/lheed_a2ia/lheed_a2ia'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/home/lenja/lheed_a2ia'
gmake: *** [all] Error 2
*** failed ***

What is the matter. Help me!

Leonid (pplenja@svs.ru)

0

#2 User is offline   lenja 

  • stranger
  • Group: Members
  • Posts: 4
  • Joined: 10-April 04

Posted 10 April 2004 - 04:31 PM

Addition on:

I have tried to compile other way:

gcc -g -O2 -v -Q -Wall -o lheed /home/lenja/adsdb_8_2/lib/redhat61/lheed.so -I/home/lenja/adsdb_8_2/inc lheed_a2ia.c

but have got the same errors.
I havn't sources for lheed.so.

Thank you,
Lenja
0

#3 User is offline   mindcooler 

  • stranger
  • Group: Members
  • Posts: 2
  • Joined: 11-April 04

Posted 11 April 2004 - 10:11 PM

Well, you are trying to build C++ so you should replace gcc with g++. So, replace
$ gcc -g -O2 -v -Q -Wall -o lheed /home/lenja/adsdb_8_2/lib/redhat61/lheed.so -I/home/lenja/adsdb_8_2/inc lheed_a2ia.c

with:
$ g++ -g -O2 -v -Q -Wall -o lheed /home/lenja/adsdb_8_2/lib/redhat61/lheed.so -I/home/lenja/adsdb_8_2/inc lheed_a2ia.c

One other thing, you are running an ancient version of gcc (and what appears to be an ancient version of redhat), you should really consider upgrading to something more recent (and usable).

/ mindcooler
0

#4 User is offline   lenja 

  • stranger
  • Group: Members
  • Posts: 4
  • Joined: 10-April 04

Posted 12 April 2004 - 04:10 PM

Thank you for advice but I have compiled program with g++ and have got the same errors.
0

#5 User is offline   blackpage 

  • member
  • Group: Members
  • Posts: 120
  • Joined: 23-March 04

Posted 12 April 2004 - 07:36 PM

gidday there,

it looks to me as if you are missing some necessary headers or "#includes". Unfortunately I have completely diverted from C++-programming, but as far as I can remember ostream should be declared in either "ostream"/"ostream.h"/"ostream.hh" or "stdio.h". So my best guess would be to check the source-files if all included headers are in place and match the needed version of the compiler.

sorry that I can't spew out anything more specific
0

#6 User is offline   mindcooler 

  • stranger
  • Group: Members
  • Posts: 2
  • Joined: 11-April 04

Posted 14 April 2004 - 11:16 AM

Don't try to include the headers blackpage mentioned, they're all wrong. For std::cerr, std::endl etc you include <iostream> (no .h). But it seems to me that you are not just missing some includes, you seem to be missing to link c+++ as c++ code. If you want further help, post a complete, compilable, but smallest possible example that exhibits your problem.
0

#7 User is offline   lenja 

  • stranger
  • Group: Members
  • Posts: 4
  • Joined: 10-April 04

Posted 14 April 2004 - 11:08 PM

Thank you for advice!
I will try.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users