undefined reference to `ostream::operator<<(char const *)'
This is a discussion about undefined reference to `ostream::operator<<(char const *)' in the Everything Linux category; 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: Entering directory `/home/lenja/lheed_a2ia' Making all in lheed_a2ia gmake: Entering directory `/home/lenja/lheed_a2 ...
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.mu)
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.mu)
Participate in our website and join the conversation
This subject has been archived. New comments and votes cannot be submitted.
Apr 10
Apr 14
0
2 minutes
Responses to this topic
OP
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
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
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
$ 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
OP
Thank you for advice but I have compiled program with g++ and have got the same errors.
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
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
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.
OP
Thank you for advice!
I will try.
I will try.