Hi there! I am running a SuSE Linux 9.0 machine. These are the header files of the C++ pr0gram I am trying to compile. Header of the file Array.h #ifndef _ARRAY_H_ #define _ARRAY_H_ #include <stdio.h> template <class T> class Array { ... } #endif Header of the file Array.cc #include "Array.h" template <class T> Array<T> &Array<T>::operator=(const Array<T> &other) { ... } Header of the file Array_templ_Main.cc #include <iostream.h> #include "Array.h" int main() { ... } The compilation command with GCC is as follows: ntienjem@njueya:~/examples> gcc -o mar Array.cc Array_templ_main.cc I got the following errors: In file included from /usr/include/g++/backward/iostream.h:31, from Array_templ_main.cc:1: /usr/include/g++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated. /tmp/cc5yDF9x.o(.text+0x5e): In function `main': : undefined reference to `std::cout' /tmp/cc5yDF9x.o(.text+0x63): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.text+0x96): In function `main': : undefined reference to `std::cout' /tmp/cc5yDF9x.o(.text+0x9b): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)' /tmp/cc5yDF9x.o(.text+0xa4): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.text+0x114): In function `__static_initialization_and_destruction_0(int, int)': : undefined reference to `std::ios_base::Init::Init[in-charge]()' /tmp/cc5yDF9x.o(.text+0x143): In function `__tcf_0': : undefined reference to `std::ios_base::Init::~Init [in-charge]()' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiED1Ev+0x19): In function `Array<int>::~Array [in-charge]()': : undefined reference to `operator delete[](void*)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x48): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::cout' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x4d): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x56): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x5f): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x68): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x71): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEC1Ej+0x27): In function `Array<int>::Array[in-charge](unsigned)': : undefined reference to `operator new[](unsigned)' /tmp/cc5yDF9x.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status QUESTION: Does someone know how to solve this problem? Thanks so much in advance for your valuable hints. ===== Ebenezer Ntienjem mailto: ebenezer_ntienjem@yahoo.com __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail
Ebenezer Ntienjem wrote:
Hi there!
I am running a SuSE Linux 9.0 machine. These are the header files of the C++ pr0gram I am trying to compile.
Header of the file Array.h
#ifndef _ARRAY_H_ #define _ARRAY_H_
#include <stdio.h>
template <class T> class Array { ... } #endif
Header of the file Array.cc
#include "Array.h"
template <class T> Array<T> &Array<T>::operator=(const Array<T> &other) { ... }
Header of the file Array_templ_Main.cc
#include <iostream.h>
#include "Array.h"
int main() { ... }
The compilation command with GCC is as follows:
ntienjem@njueya:~/examples> gcc -o mar Array.cc Array_templ_main.cc
I got the following errors:
In file included from /usr/include/g++/backward/iostream.h:31, from Array_templ_main.cc:1: /usr/include/g++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated. /tmp/cc5yDF9x.o(.text+0x5e): In function `main': : undefined reference to `std::cout' /tmp/cc5yDF9x.o(.text+0x63): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.text+0x96): In function `main': : undefined reference to `std::cout' /tmp/cc5yDF9x.o(.text+0x9b): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)' /tmp/cc5yDF9x.o(.text+0xa4): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.text+0x114): In function `__static_initialization_and_destruction_0(int, int)': : undefined reference to `std::ios_base::Init::Init[in-charge]()' /tmp/cc5yDF9x.o(.text+0x143): In function `__tcf_0': : undefined reference to `std::ios_base::Init::~Init [in-charge]()' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiED1Ev+0x19): In function `Array<int>::~Array [in-charge]()': : undefined reference to `operator delete[](void*)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x48): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::cout' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x4d): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x56): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x5f): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x68): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x71): In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEC1Ej+0x27): In function `Array<int>::Array[in-charge](unsigned)': : undefined reference to `operator new[](unsigned)' /tmp/cc5yDF9x.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status
QUESTION:
Does someone know how to solve this problem?
Thanks so much in advance for your valuable hints.
===== Ebenezer Ntienjem mailto: ebenezer_ntienjem@yahoo.com
__________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail
You have to put : using namespace std; before your coding, or something like that. I can't recall exactly, because I have not a linux machine near me.. :(
Hi there! Thanks so much. The solution sent to me by Marcus is g++ -o mar Array.cc Array_templ_main.cc Sincerely, Ebenezer --- gustavo <gdutra@topsystems.com.uy> wrote:
Ebenezer Ntienjem wrote:
Hi there!
I am running a SuSE Linux 9.0 machine. These are the header files of the C++ pr0gram I am trying to compile.
Header of the file Array.h
#ifndef _ARRAY_H_ #define _ARRAY_H_
#include <stdio.h>
template <class T> class Array { ... } #endif
Header of the file Array.cc
#include "Array.h"
template <class T> Array<T> &Array<T>::operator=(const Array<T> &other) { ... }
Header of the file Array_templ_Main.cc
#include <iostream.h>
#include "Array.h"
int main() { ... }
The compilation command with GCC is as follows:
ntienjem@njueya:~/examples> gcc -o mar Array.cc Array_templ_main.cc
I got the following errors:
In file included from /usr/include/g++/backward/iostream.h:31, from Array_templ_main.cc:1: /usr/include/g++/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated. /tmp/cc5yDF9x.o(.text+0x5e): In function `main': : undefined reference to `std::cout' /tmp/cc5yDF9x.o(.text+0x63): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.text+0x96): In function `main': : undefined reference to `std::cout' /tmp/cc5yDF9x.o(.text+0x9b): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(int)' /tmp/cc5yDF9x.o(.text+0xa4): In function `main': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)' /tmp/cc5yDF9x.o(.text+0x114): In function `__static_initialization_and_destruction_0(int, int)': : undefined reference to `std::ios_base::Init::Init[in-charge]()' /tmp/cc5yDF9x.o(.text+0x143): In function `__tcf_0': : undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiED1Ev+0x19):
In function `Array<int>::~Array [in-charge]()': : undefined reference to `operator delete[](void*)'
/tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x48):
In function `Array<int>::operator[](unsigned)': : undefined reference to `std::cout'
/tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x4d):
In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x56):
In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned)'
/tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x5f):
In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x68):
In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(unsigned)'
/tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEixEj+0x71):
In function `Array<int>::operator[](unsigned)': : undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/cc5yDF9x.o(.gnu.linkonce.t._ZN5ArrayIiEC1Ej+0x27):
In function `Array<int>::Array[in-charge](unsigned)': : undefined reference to `operator new[](unsigned)' /tmp/cc5yDF9x.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0' collect2: ld returned 1 exit status
QUESTION:
Does someone know how to solve this problem?
Thanks so much in advance for your valuable hints.
===== Ebenezer Ntienjem mailto: ebenezer_ntienjem@yahoo.com
__________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail
You have to put :
using namespace std;
before your coding, or something like that. I can't recall exactly, because I have not a linux machine near me.. :(
-- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists.suse.com/archive/suse-programming-e
===== Ebenezer Ntienjem mailto: ebenezer_ntienjem@yahoo.com __________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail
Ebenezer Ntienjem <ebenezer_ntienjem@yahoo.com> [22 Jul 2004 07:43]:
#include <iostream.h>
Replace that with a #include <iostream> To get rid of the backwards warning. In that case you possibly either have to prepend std:: to symbols from iostream, add some #using std::<symbol> where <symbol> has to be replaced by the name needed, e.g. : using std::ostream; using std::cout; etc. Or use the sledgehammer and add a using namespace std; gcc -o mar Array.cc Array_templ_main.cc *Always* use g++ to compile C++ code. gcc won't pull in the additional libraries needed for C++ code. Philipp
participants (3)
-
Ebenezer Ntienjem
-
gustavo
-
Philipp Thomas