undefined reference to `std::basic_string

This is a discussion on undefined reference to `std::basic_string within the C++ Programming forums, part of the General Programming Boards category; I get this big error while trying to compile a simple C program under Cygwin Code: $ gcc FileClass2.cpp In ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    20

    undefined reference to `std::basic_string

    I get this big error while trying to compile a simple C program

    under Cygwin


    Code:
    $ gcc FileClass2.cpp
    In file included from FileClass2.cpp:3:
    require.h:58:26: warning: no newline at end of file
    /cygdrive/c/DOKUME~1/KHAJA~1.MOH/LOKALE~1/Temp/ccI3GSd5.o:FileClass2.cpp:(.text+
    0xd): undefined reference to `std::basic_string<char, std::char_traits<char>, st
    d::allocator<char> >::size() const'
    /cygdrive/c/DOKUME~1/KHAJA~1.MOH/LOKALE~1/Temp/ccI3GSd5.o:FileClass2.cpp:(.text+
    0x60): undefined reference to `std::basic_string<char, std::char_traits<char>, s
    td::allocator<char> >::operator[](unsigned int) const'
    /cygdrive/c/DOKUME~1/KHAJA~1.MOH/LOKALE~1/Temp/ccI3GSd5.o:FileClass2.cpp:(.text+
    0x9f): undefined reference to `std::basic_string<char, std::char_traits<char>, s
    td::allocator<char> >::operator[](unsigned int) const'
    /cygdrive/c/DOKUME~1/KHAJA~1.MOH/LOKALE~1/Temp/ccI3GSd5.o:FileClass2.cpp:(.text+
    0xce): undefined reference to `std::basic_string<char, std::char_traits<char>, s
    td::allocator<char> >::operator[](unsigned int) const'
    /cygdrive/c/DOKUME~1/KHAJA~1.MOH/LOKALE~1/Temp/ccI3GSd5.o:FileClass2.cpp:(.text+
    0x205): undefined reference to `___gxx_personality_sj0'
    collect2: ld returned 1 exit status
    Last edited by Salem; 09-04-2006 at 06:32 AM. Reason: code tagged - please learn to use them!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,272
    You have a C++ program, not a C program.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    20

    undefined reference to `std::basic_string

    oh sorry a CPP program

    is there any solution for this

    i know something to do with linker

    but not able to sort it out

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Stop compiling as C, and move to the C++ board. You can't compile C++ on a C compiler.


    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,833
    Moved to C++ board.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Mar 2009
    Posts
    2

    Ashish Patel

    just compile with g++ compiler

    g++ -c <cpp-file>
    g++ -o <bin-file> <obj-file>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 12:45 PM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  4. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 05:42 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21