a link error in gcc 3.4.3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a small program
#include <iostream.h>
#include <fstream.h>

class uf : public fstream
{
public:
    int Open(char* name, std::_Ios_Openmode mode){clear();
      open(name, mode); return good();}
    int Close(){close();cout << "Close" << endl;}
    ~uf(){if (rdbuf()->is_open()) {close();cout << "Close1" << endl;}}
};

int
main()
{
    uf fo;
    fo.Open("1", ios::in);
    fo.seekp(0, ios::end);
    cout << "Open in in, file size: " <<  fo.tellp() << endl;
    fo.Close();
}

When I use gcc3.4.3 to compile this program(g++ f.cpp -o test), it give
a error as following
g++ f.cpp -o test
In file included from
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3/backward/iostream.h:31,

                 from f.cpp:1:
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3/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 <iostream> instead
of the deprecated header <iostream.h>. To disable this warning use
-Wno-deprecated.
/tmp/ccR0k40N.o(.gnu.linkonce.r._ZTC2uf0_Sd+0xc): undefined reference to
`std::basic_iostream<char, std::char_traits<char> >::~basic_iostream()'
/tmp/ccR0k40N.o(.gnu.linkonce.r._ZTC2uf0_Sd+0x10): undefined reference
to `std::basic_iostream<char, std::char_traits<char>
>::~basic_iostream()'
collect2: ld returned 1 exit status

There is a warning in it because I use iostream.h not use iostream.

But when linked, there are two errors, these all refer to
std::basic_iostream<char, std::char_traits<char> >::~basic_iostream()
I don't know why this question occurs.

By the way, when I use gcc3.4.2, it only gives warning and links
successfully.

I add #define _GLIBCXX_EXPORT_TEMPLATE in my program in the first line.
And it links successfully.
It give a other waring:
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3/ostream:131:
warning: inline function `std::basic_ostream<_CharT, _Traits>&
std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_ostream<_CharT,
_Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char,
_Traits = std::char_traits<char>]' used but never defined

Who know funciton of  _GLIBCXX_EXPORT_TEMPLATE?
And why I must add it into program?

--
Best Wish with You!
                        Li Qihong
China Integrated Circuit Design Center
Address: No.1 Gaojiayuan,Chaoyang District,Beijing,China.
Postcode: 100015 P.O.Box 8545
Tel: (86-10)64365577-2104
Email: liqh@xxxxxxxxxx




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux