C Board  

Go Back   C Board > General Programming Boards > C++ Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 09-04-2006, 03:17 AM   #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 05:32 AM. Reason: code tagged - please learn to use them!
kpmkhaja is offline   Reply With Quote
Old 09-04-2006, 03:24 AM   #2
C++ Witch
 
laserlight's Avatar
 
Join Date: Oct 2003
Location: Singapore
Posts: 12,460
You have a C++ program, not a C program.
__________________
C + C++ Compiler: MinGW port of GCC
Build + Version Control System: SCons + Bazaar

Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
laserlight is online now   Reply With Quote
Old 09-04-2006, 03:53 AM   #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
kpmkhaja is offline   Reply With Quote
Old 09-04-2006, 04:09 AM   #4
+++ OK NO CARRIER
 
quzah's Avatar
 
Join Date: Oct 2001
Posts: 11,292
Stop compiling as C, and move to the C++ board. You can't compile C++ on a C compiler.


Quzah.
__________________
Hundreds of thousands of dipshits can't be wrong.


Are you up for the suck?
quzah is offline   Reply With Quote
Old 09-04-2006, 05:32 AM   #5
and the hat of Destiny
 
Salem's Avatar
 
Join Date: Aug 2001
Location: The edge of the known universe
Posts: 22,495
Moved to C++ board.
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.

Salem is offline   Reply With Quote
Old 03-18-2009, 10:38 PM   #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>
zoom2ashish is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting an error with OpenGL: collect2: ld returned 1 exit status Lorgon Jortle C++ Programming 6 05-08-2009 08:18 PM
Undefined Reference Compiling Error AlakaAlaki C++ Programming 1 06-27-2008 11:45 AM
Screwy Linker Error - VC2005 Tonto C++ Programming 5 06-19-2007 02:39 PM
C OpenGL Compiler Error? Matt3000 C Programming 12 07-07-2006 04:42 PM
c++ linking problem for x11 kron Linux Programming 1 11-19-2004 10:18 AM


All times are GMT -6. The time now is 12:20 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

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