MESSAGE
DATE | 2011-06-05 |
FROM | Ruben Safir
|
SUBJECT | Subject: [NYLXS - HANGOUT] C++ iostream linking
|
I have a newish workstation on an operton64 system with a fresh opensuse 11.4 x86 64 bit install.
I'm trying to compile a program that I started, nothing special, that uses iostream but I'm getting this linker error
ruben-at-stat18:~/cplus> make g++ -Wall -o quiz quiz.o quiz.o: In function `std::basic_ios >::basic_ios(std::basic_ios > const&)': quiz.cpp:(.text._ZNSt9basic_iosIcSt11char_traitsIcEEC2ERKS2_ [_ZNSt9basic_iosIcSt11char_traitsIcEEC5ERKS2_]+0x1f): undefined reference to `std::ios_base::ios_base(std::ios_base const&)' collect2: ld returned 1 exit status make: *** [quiz] Error 1
It compiles fine on my other workstation
#include #include "questions.h" #include #include
int main(int argv, char *argc[]){ Questions::menu(); return 0; }
questions.h
#ifndef QUESTION #define QUESTION #include #include #include #include #include
namespace Questions {
class Question{
public: Question(std::string q, std::string a): quest(q), answer(a){ }
private: std::string quest; std::string response; std::string answer; Question(Question const ©);
};
class Deck{
public: std::vector deck; Deck(){ std::string home = std::getenv("HOME"); database = home + "/quiz.db"; size = 0; }
void get_stack(); Question get_question(); void give_quiz(); void add_questions(Question &enter); void add_database(); private: int size; std::string database;
};
void menu(std::ostream &os = std::cout);
void menu(std::ostream &os){
os << "Welcome the the C++ Quiz" << "\n\n\n\n" << std::endl; std::string tmp = " \n " "Select from one of the following: \n\n" "a) Insert Question and Answer into the database\n" "b) Read 25 Questions and run Quiz\n\n\nResponse==> "; os << tmp << std::endl;
}
} //end of namespace Question #endif
Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-suse-linux/4.5/lto-wrapper Target: x86_64-suse-linux Configured with: ../configure --prefix=/usr --infodir=/usr/share/info -- mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 -- enable-languages=c,c++,objc,fortran,obj-c++,java,ada --enable- checking=release --with-gxx-include-dir=/usr/include/c++/4.5 --enable-ssp --disable-libssp --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap -- with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit --enable- libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific- runtime-libs --program-suffix=-4.5 --enable-linux-futex --without-system- libunwind --enable-gold --with-plugin-ld=/usr/bin/gold --with- arch-32=i586 --with-tune=generic --build=x86_64-suse-linux Thread model: posix gcc version 4.5.1 20101208 [gcc-4_5-branch revision 167585] (SUSE Linux)
This is the makefile
quiz : quiz.o g++ -Wall -o quiz quiz.o
quiz.o : quiz.cpp g++ -Wall -c quiz.cpp
I'm not certain why it can't find the iostream copy constructor.
Ruben
|
|