Hi, I am getting some link errors I do not understand when compiling the code below with the latest snapshot. Help is appreciated. // Commands: // // Intel 8.0 // icpc -cxxlib-gcc -gcc-version=330 -Kc++eh -Kpic -Krtti -Kc++ -pc64 -Qoption,cpp,-tnone -DGCC33 -o testIcpc amd64StreamTest.C // // gcc 3.3 (for AMD64 add -m64) // g++ -fpic -fno-implicit-templates -fno-implicit-inline-templates -DGCC33 -o testGcc33 amd64StreamTest.C // // gcc 3.4 (for AMD64 add -m64) // g++34 -fpic -fno-implicit-templates -fno-implicit-inline-templates -o testGcc34 amd64StreamTest.C #include <stdio.h> #include <fcntl.h> #include <fstream> using std::ifstream; using std::ofstream; using std::fstream; using std::filebuf; #include <ext/stdio_filebuf.h> using std::basic_istream; using std::basic_ostream; using std::basic_iostream; using std::basic_filebuf; using std::char_traits; using std::ios_base; using __gnu_cxx::stdio_filebuf; template<typename _CharT, typename _Traits> class omi_stdio_ifstream : public basic_istream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; friend class ios_base; // For sync_with_stdio. // Default ctor explicit omi_stdio_ifstream() : basic_istream<char_type, traits_type>(NULL), #if defined(GCC33) myBuf(0,ios_base::in,false, 0) #else myBuf(0,ios_base::in) #endif {this->init(&myBuf);} // Standard ctor explicit omi_stdio_ifstream(const char* myName, ios_base::openmode myMode = ios_base::in) : basic_istream<char_type, traits_type>(NULL), #if defined(GCC33) myBuf(0,ios_base::in,false, 0) #else myBuf(0,ios_base::in) #endif { this->init(&myBuf); this->open(myName, myMode); } // ctor that takes a C FILE* explicit omi_stdio_ifstream(std::__c_file* myFile) : basic_istream<char_type, traits_type>(NULL), myBuf(myFile, ios_base::in) {this->init(&myBuf);} // ctor that takes a file descriptor explicit omi_stdio_ifstream(int fd) : basic_istream<char_type, traits_type>(NULL), #if defined(GCC33) myBuf(fd,ios_base::in,false, 0) #else myBuf(fd,ios_base::in) #endif {this->init(&myBuf);} ~omi_stdio_ifstream() {} stdio_filebuf<char_type>* rdbuf() const {return const_cast<stdio_filebuf<char_type>*>(&myBuf);} int fd() {return myBuf.fd();} bool is_open() {return myBuf.is_open();} void open(const char* name, std::ios_base::openmode opMode = ios_base::in) { if (! myBuf.open(name, opMode | ios_base::in)) this->setstate(ios_base::failbit); } void close() { if (! myBuf.close()) this->setstate(ios_base::failbit); } private: stdio_filebuf<char_type> myBuf; }; template<typename _CharT, typename _Traits> class omi_stdio_ofstream : public basic_ostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; friend class ios_base; // For sync_with_stdio. // Default ctor explicit omi_stdio_ofstream() : basic_ostream<char_type, traits_type>(NULL), #if defined(GCC33) myBuf(0,ios_base::in,false, 0) #else myBuf(0,ios_base::in) #endif {this->init(&myBuf);} // Standard ctor explicit omi_stdio_ofstream(const char* myName, ios_base::openmode myMode = ios_base::out) : basic_ostream<char_type, traits_type>(NULL), #if defined(GCC33) myBuf(0,ios_base::out,false, 0) #else myBuf(0,ios_base::out) #endif { this->init(&myBuf); this->open(myName, myMode); } // ctor that takes a C FILE* explicit omi_stdio_ofstream(std::__c_file* myFile) : basic_ostream<char_type, traits_type>(NULL), myBuf(myFile,ios_base::out) {this->init(&myBuf);} // ctor that takes a file descriptor explicit omi_stdio_ofstream(int fd) : basic_ostream<char_type, traits_type>(NULL), #if defined(GCC33) myBuf(fd, ios_base::out,false, 0) #else myBuf(fd, ios_base::out) #endif {this->init(&myBuf);} ~omi_stdio_ofstream() {} stdio_filebuf<char_type>* rdbuf() const {return const_cast<stdio_filebuf<char_type>*>(&myBuf);} int fd() {return myBuf.fd();} bool is_open() {return myBuf.is_open();} void open(const char* name, std::ios_base::openmode opMode = ios_base::out) { if (! myBuf.open(name, opMode | ios_base::in)) this->setstate(ios_base::failbit); } void close() { if (! myBuf.close()) this->setstate(ios_base::failbit); } private: stdio_filebuf<char_type> myBuf; }; template<typename _CharT, typename _Traits> class omi_stdio_fstream : public basic_iostream<_CharT, _Traits> { public: // Types: typedef _CharT char_type; typedef _Traits traits_type; typedef typename traits_type::int_type int_type; typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; friend class ios_base; // For sync_with_stdio. // Default ctor explicit omi_stdio_fstream() : basic_iostream<char_type, traits_type>(NULL), #if defined(GCC33) myBuf(0,ios_base::in|ios_base::out,false, 0) #else myBuf(0,ios_base::in|ios_base::out) #endif {this->init(&myBuf);} // Standard ctor explicit omi_stdio_fstream(const char* myName, ios_base::openmode myMode = ios_base::in|ios_base::out) : basic_iostream<char_type, traits_type>(NULL), #if defined(GCC33) myBuf(0,ios_base::in|ios_base::out,false, 0) #else myBuf(0,ios_base::in|ios_base::out) #endif { this->init(&myBuf); this->open(myName, myMode); } // ctor that takes a C FILE* explicit omi_stdio_fstream(std::__c_file* myFile) : basic_iostream<char_type, traits_type>(NULL), myBuf(myFile, ios_base::in|ios_base::out) {this->init(&myBuf);} // ctor that takes a file descriptor explicit omi_stdio_fstream(int fd) : basic_iostream<char_type, traits_type>(NULL), #if defined(GCC33) myBuf(fd,ios_base::in|ios_base::out,false, 0) #else myBuf(fd,ios_base::in|ios_base::out) #endif {this->init(&myBuf);} ~omi_stdio_fstream() {} stdio_filebuf<char_type>* rdbuf() const {return const_cast<stdio_filebuf<char_type>*>(&myBuf);} int fd() {return myBuf.fd();} bool is_open() {return myBuf.is_open();} void open(const char* name, std::ios_base::openmode opMode = ios_base::in|ios_base::out) { if (! myBuf.open(name, opMode | ios_base::in)) this->setstate(ios_base::failbit); } void close() { if (! myBuf.close()) this->setstate(ios_base::failbit); } private: stdio_filebuf<char_type> myBuf; }; template<typename _CharT, typename _Traits = char_traits<_CharT> > class omi_stdio_ifstream; template<typename _CharT, typename _Traits = char_traits<_CharT> > class omi_stdio_ofstream; template<typename _CharT, typename _Traits = char_traits<_CharT> > class omi_stdio_fstream; template class stdio_filebuf<char>; // Instantiate the stream templates template class omi_stdio_ifstream<char>; template class omi_stdio_ofstream<char>; template class omi_stdio_fstream<char>; typedef omi_stdio_ifstream<char> omi_ifstream; typedef omi_stdio_ofstream<char> omi_ofstream; typedef omi_stdio_fstream<char> omi_fstream; int main() { fprintf(stderr,"Open the file\n"); int fd = open("myTest.txt", O_WRONLY); fprintf(stderr,"Create the stream\n"); omi_ofstream myStrm(fd); fprintf(stderr,"Write to the stream\n"); myStrm << "Hello world" << std::endl; fprintf(stderr,"Close the stream\n"); myStrm.close(); } Looking at the link errors it appears that the templates in the STL do not get instantiated properly. Here is on of the link errors: /scratch/cckQreRG.o(.text+0x38): In function `std::__verify_grouping(char const*, unsigned long, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': : undefined reference to `unsigned long const& std::min<unsigned long>(unsigned long const&, unsigned long const&)' /scratch/cckQreRG.o(.gnu.linkonce.t._ZN17omi_stdio_fstreamIcSt11char_traitsIcEEC2Ev+0x23): In function `omi_stdio_fstream<char, std::char_traits<char> >::omi_stdio_fstream()': Note that I am using explicit template instantiation. However, the compiler should properly instantiate templates in the STL if they are used as base classes. Also note that using automatic instantiation is not an option in the application from which this example was extracted. The code compiles fine with the Intel compiler. gcc 3.3 core dumps with an internal compiler error. Since the dump is no longer present in the 3.4 snapshot I did not file a bug. Help is appreciated. Thanks, Robert -- Robert Schweikert MAY THE SOURCE BE WITH YOU rjschwei@xxxxxxx LINUX