Hi Alex,
You're using gcc which is a C compiler...what you want is g++ (the c++
compiler).
alex(a)loes.org.lu wrote:
Hi
I'm trying to compile a c++ program on kubuntu 7.10, but it doesn't. A
while ago, all went fine. I suppose, there was an update for some
package needed for compiling. Here are the failure messages:
gcc filterhtml.cc -o filterhtml
/tmp/ccIsh2ZJ.o: In function
`__static_initialization_and_destruction_0(int, int)':
filterhtml.cc:(.text+0x23): undefined reference to
`std::ios_base::Init::Init()'
/tmp/ccIsh2ZJ.o: In function `__tcf_0':
filterhtml.cc:(.text+0x6c): undefined reference to
`std::ios_base::Init::~Init()'
/tmp/ccIsh2ZJ.o: In function `FilterHTML::run()':
filterhtml.cc:(.text+0x9a): undefined reference to
`std::basic_ifstream<char, std::char_traits<char> >::basic_ifstream()'
filterhtml.cc:(.text+0xa8): undefined reference to
`std::basic_ofstream<char, std::char_traits<char> >::basic_ofstream()'
filterhtml.cc:(.text+0xbd): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::c_str() const'
filterhtml.cc:(.text+0xd7): undefined reference to
`std::basic_ifstream<char, std::char_traits<char> >::open(char const*,
std::_Ios_Openmode)'
filterhtml.cc:(.text+0xea): undefined reference to
`std::basic_ios<char, std::char_traits<char> >::operator!() const'
filterhtml.cc:(.text+0x109): undefined reference to `std::cerr'
filterhtml.cc:(.text+0x10e): 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*)'
filterhtml.cc:(.text+0x120): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::operator<<
<char, std::char_traits<char>, std::allocator<char>
(std::basic_ostream<char,
std::char_traits<char> >&,
std::basic_string<char,
std::char_traits<char>, std::allocator<char> >
const&)'
filterhtml.cc:(.text+0x130): 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*)'
filterhtml.cc:(.text+0x138): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&)'
filterhtml.cc:(.text+0x140): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
::operator<<(std::basic_ostream<char,
std::char_traits<char> >&
(*)(std::basic_ostream<char,
std::char_traits<char> >&))'
filterhtml.cc:(.text+0x17a): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::c_str() const'
filterhtml.cc:(.text+0x196): undefined reference to
`std::basic_ofstream<char, std::char_traits<char> >::open(char const*,
std::_Ios_Openmode)'
filterhtml.cc:(.text+0x1a9): undefined reference to
`std::basic_ios<char, std::char_traits<char> >::operator!() const'
filterhtml.cc:(.text+0x1cf): undefined reference to `std::cerr'
filterhtml.cc:(.text+0x1d4): 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*)'
filterhtml.cc:(.text+0x1e6): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::operator<<
<char, std::char_traits<char>, std::allocator<char>
(std::basic_ostream<char,
std::char_traits<char> >&,
std::basic_string<char,
std::char_traits<char>, std::allocator<char> >
const&)'
filterhtml.cc:(.text+0x1f6): 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*)'
filterhtml.cc:(.text+0x1fe): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&)'
filterhtml.cc:(.text+0x206): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
::operator<<(std::basic_ostream<char,
std::char_traits<char> >&
(*)(std::basic_ostream<char,
std::char_traits<char> >&))'
filterhtml.cc:(.text+0x22d): undefined reference to
`std::basic_istream<char, std::char_traits<char> >::get(char&)'
filterhtml.cc:(.text+0x285): 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)'
filterhtml.cc:(.text+0x298): undefined reference to
`std::basic_ios<char, std::char_traits<char> >::eof() const'
filterhtml.cc:(.text+0x2c9): undefined reference to
`std::basic_ofstream<char, std::char_traits<char> >::~basic_ofstream()'
filterhtml.cc:(.text+0x2df): undefined reference to
`std::basic_ofstream<char, std::char_traits<char> >::~basic_ofstream()'
filterhtml.cc:(.text+0x2ed): undefined reference to
`std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
filterhtml.cc:(.text+0x315): undefined reference to
`std::basic_ifstream<char, std::char_traits<char> >::~basic_ifstream()'
/tmp/ccIsh2ZJ.o: In function `main':
filterhtml.cc:(.text+0x381): undefined reference to `std::cerr'
filterhtml.cc:(.text+0x386): 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*)'
filterhtml.cc:(.text+0x38e): undefined reference to
`std::basic_ostream<char, std::char_traits<char> >& std::endl<char,
std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<char> >&)'
filterhtml.cc:(.text+0x396): undefined reference to
`std::basic_ostream<char, std::char_traits<char>
::operator<<(std::basic_ostream<char,
std::char_traits<char> >&
(*)(std::basic_ostream<char,
std::char_traits<char> >&))'
filterhtml.cc:(.text+0x3ad): undefined reference to
`std::allocator<char>::allocator()'
filterhtml.cc:(.text+0x3ce): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::basic_string(char const*,
std::allocator<char> const&)'
filterhtml.cc:(.text+0x3eb): undefined
reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::~basic_string()'
filterhtml.cc:(.text+0x3fe): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::~basic_string()'
filterhtml.cc:(.text+0x40e): undefined reference to
`std::allocator<char>::~allocator()'
filterhtml.cc:(.text+0x419): undefined reference to
`std::allocator<char>::allocator()'
filterhtml.cc:(.text+0x43a): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::basic_string(char const*,
std::allocator<char> const&)'
filterhtml.cc:(.text+0x44d): undefined
reference to
`std::allocator<char>::~allocator()'
filterhtml.cc:(.text+0x46f): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::~basic_string()'
filterhtml.cc:(.text+0x482): undefined reference to
`std::basic_string<char, std::char_traits<char>, std::allocator<char>
::~basic_string()'
filterhtml.cc:(.text+0x492): undefined reference to
`std::allocator<char>::~allocator()'
filterhtml.cc:(.text+0x4b3): undefined reference to
`std::allocator<char>::~allocator()'
/tmp/ccIsh2ZJ.o: In function
`FilterHTML::setSource(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&)':
filterhtml.cc:(.text._ZN10FilterHTML9setSourceERKSs[FilterHTML::setSource(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)]+0x14):
undefined reference to `std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::operator=(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >
const&)'
/tmp/ccIsh2ZJ.o: In function
`FilterHTML::setDestination(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)':
filterhtml.cc:(.text._ZN10FilterHTML14setDestinationERKSs[FilterHTML::setDestination(std::basic_string<char,
std::char_traits<char>, std::allocator<char> > const&)]+0x17):
undefined reference to `std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::operator=(std::basic_string<char,
std::char_traits<char>, std::allocator<char> >
const&)'
/tmp/ccIsh2ZJ.o: In function `FilterHTML::FilterHTML()':
filterhtml.cc:(.text._ZN10FilterHTMLC1Ev[FilterHTML::FilterHTML()]+0xe):
undefined reference to `std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::basic_string()'
filterhtml.cc:(.text._ZN10FilterHTMLC1Ev[FilterHTML::FilterHTML()]+0x1c):
undefined reference to `std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::basic_string()'
filterhtml.cc:(.text._ZN10FilterHTMLC1Ev[FilterHTML::FilterHTML()]+0x2f):
undefined reference to `std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::~basic_string()'
/tmp/ccIsh2ZJ.o: In function `FilterHTML::~FilterHTML()':
filterhtml.cc:(.text._ZN10FilterHTMLD1Ev[FilterHTML::~FilterHTML()]+0x11):
undefined reference to `std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::~basic_string()'
filterhtml.cc:(.text._ZN10FilterHTMLD1Ev[FilterHTML::~FilterHTML()]+0x22):
undefined reference to `std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::~basic_string()'
filterhtml.cc:(.text._ZN10FilterHTMLD1Ev[FilterHTML::~FilterHTML()]+0x3b):
undefined reference to `std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::~basic_string()'
/tmp/ccIsh2ZJ.o:(.eh_frame+0x12): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
As you see, a lot of undefined referencies. But I don't know why.
Here is the source:
// Datei filterhtml.cc
//
// Loesung zu Aufgabe 3.2.7.2
// aus "C++-Entwicklung mit Linux", 3. Auflage
// (C) 2004, T. Wieland.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
class FilterHTML
{
private:
string srcfilename, destfilename;
public:
FilterHTML() {}
void setSource(const string& _src)
{ srcfilename = _src; }
void setDestination(const string& _dest)
{ destfilename = _dest; }
int run();
};
int FilterHTML::run()
{
ifstream inpfile;
ofstream outpfile;
bool tocopy = true;
char inpchar;
inpfile.open(srcfilename.c_str());
if (!inpfile)
{
cerr << "Quelldatei " << srcfilename << " kann nicht
geoeffnet
werden!" << endl;
return -1;
}
outpfile.open(destfilename.c_str());
if (!outpfile)
{
cerr << "Zieldatei " << destfilename << " kann nicht
geoeffnet
werden!" << endl;
return -2;
}
while (!inpfile.eof())
{
inpfile.get(inpchar);
switch(inpchar)
{
case '<': tocopy = false;
break;
case '>': tocopy = true;
break;
default: if (tocopy)
outpfile << inpchar;
}
}
return 0;
}
int main(int argc, char* argv[])
{
FilterHTML filter;
if (argc != 3)
{
cerr << "Aufruf: filterhtml <quelldatei> <zieldatei>"
<< endl;
return -1;
}
filter.setSource(argv[1]);
filter.setDestination(argv[2]);
int res = filter.run();
return res;
}
Perhaps, an include is missing?
Please help
Al
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
Lilux-help mailing list
Lilux-help(a)lilux.lu
http://lilux.lu/mailman/listinfo/lilux-help