Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #6221 > unrolled thread

Strange linker problem

Started byRuben Safir <ruben@mrbrklyn.com>
First post2011-06-05 01:33 +0000
Last post2011-06-05 01:33 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.c++


Contents

  Strange linker problem Ruben Safir <ruben@mrbrklyn.com> - 2011-06-05 01:33 +0000

#6221 — Strange linker problem

FromRuben Safir <ruben@mrbrklyn.com>
Date2011-06-05 01:33 +0000
SubjectStrange linker problem
Message-ID<iseme4$qse$1@reader1.panix.com>
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@stat18:~/cplus> make
g++ -Wall -o quiz quiz.o 
quiz.o: In function `std::basic_ios<char, std::char_traits<char> 
>::basic_ios(std::basic_ios<char, std::char_traits<char> > 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 <iostream>
#include "questions.h"
#include <string>
#include <vector>

  int main(int argv, char *argc[]){
    Questions::menu();
  
  
  
    return 0;
}


questions.h

#ifndef QUESTION
#define QUESTION
#include <cstdlib>
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>

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 &copy);



};

class Deck{

  public:
    std::vector<Question> 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

[toc] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web