Strange error in running CPP file [duplicate]What is a command to compile and run C++ programs?Error linking standard header file in gcclinking cpp object file to c object file and create executableBuilding TrueCrypt on Ubuntu 14.04“configure: error: C++ preprocessor ”/lib/cpp“ fails sanity check”Huge amount of undefined references when compiling pjsip / pjsua samplescpp vs c++ compiler?Installing VMware on 18.10: Failed to build vmmonlibssh example file - exec formate error

Call local emergency number using a foreign mobile number

In what way were Renaissance battles like chess matches?

How does an all-female medieval country maintain itself?

Washing the skin of a dead rat

Do any Star Trek characters play rock band instruments?

Double feature: Bibliophile edition

Stuck on this definite integral

What manages Upper Memory Blocks (UMBs) in MS-DOS?

Have supporters of "right-wing populist" parties in Europe explained why they trust Trump?

Why was the Vulcan bomber used for the Falklands raid?

How are side-channel attacks executed? What does an attacker need to execute a side channel attack?

How can you castle legally in Chess960 when the castling rook is on the king's destination square?

What spacing difference is acceptable with a contracted tile job?

Which Formula One races did Scuderia Ferrari not take part in?

How to check if python package is latest version programmatically?

Body swap, then building it back to health

Struggling to understand degenerate perturbation theory

Modification of a public property - LWC

Is there an integrated terminal option in file managers such as Nautilus in Ubuntu?

What is the difference between money and currency?

How often to check credit card statement

Is there a systematic theory for Gibbs measures (better if on Hilbert spaces)?

Hikers in Halloween

When is the best time to visit the Australian outback?



Strange error in running CPP file [duplicate]


What is a command to compile and run C++ programs?Error linking standard header file in gcclinking cpp object file to c object file and create executableBuilding TrueCrypt on Ubuntu 14.04“configure: error: C++ preprocessor ”/lib/cpp“ fails sanity check”Huge amount of undefined references when compiling pjsip / pjsua samplescpp vs c++ compiler?Installing VMware on 18.10: Failed to build vmmonlibssh example file - exec formate error






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









0


















This question already has an answer here:



  • What is a command to compile and run C++ programs?

    5 answers



I created a very simple file in CPP, namely trash.cpp. Ran it using gcc trash.cpp



#include <iostream>
#include <string>

int main()
try
throw 6;

catch(int e)
std::cout << "Int exception thrown " << std::to_string(e) << std::endl;




It is showing very strange error. I dont know what to search for, so I'm posting my problem here.



aman@aman-Vostro-3578:~$ gcc trash.cpp
/tmp/ccffWxA1.o: In function `main':
trash.cpp:(.text+0x1e): undefined reference to `__cxa_allocate_exception'
trash.cpp:(.text+0x30): undefined reference to `typeinfo for int'
trash.cpp:(.text+0x38): undefined reference to `__cxa_throw'
trash.cpp:(.text+0x4e): undefined reference to `__cxa_begin_catch'
trash.cpp:(.text+0x61): undefined reference to `std::cout'
trash.cpp:(.text+0x66): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
trash.cpp:(.text+0x89): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
trash.cpp:(.text+0x93): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
trash.cpp:(.text+0x9e): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
trash.cpp:(.text+0xaa): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
trash.cpp:(.text+0xaf): undefined reference to `__cxa_end_catch'
trash.cpp:(.text+0xd4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
trash.cpp:(.text+0xde): undefined reference to `__cxa_end_catch'
/tmp/ccffWxA1.o: In function `__static_initialization_and_destruction_0(int, int)':
trash.cpp:(.text+0x11e): undefined reference to `std::ios_base::Init::Init()'
trash.cpp:(.text+0x133): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > __gnu_cxx::__to_xstring<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char>(int (*)(char*, unsigned long, char const*, __va_list_tag*), unsigned long, char const*, ...)':
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x113): undefined reference to `std::allocator<char>::allocator()'
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x159): undefined reference to `std::allocator<char>::~allocator()'
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x186): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider::~_Alloc_hider()':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderD2Ev[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderD5Ev]+0x14): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<char*, void>(char*, char*, std::allocator<char> const&)':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IPcvEET_S7_RKS3_[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IPcvEET_S7_RKS3_]+0x25): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_local_data()'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IPcvEET_S7_RKS3_[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IPcvEET_S7_RKS3_]+0x3a): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider::_Alloc_hider(char*, std::allocator<char> const&)'
/tmp/ccffWxA1.o: In function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag)':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x56): undefined reference to `std::__throw_logic_error(char const*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x8f): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xa1): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data(char*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xb4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_capacity(unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xc0): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xd6): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char*, char*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xe9): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length(unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x103): undefined reference to `__cxa_begin_catch'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x10f): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x114): undefined reference to `__cxa_rethrow'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x11c): undefined reference to `__cxa_end_catch'
/tmp/ccffWxA1.o:(.data.rel.local.DW.ref._ZTIi[DW.ref._ZTIi]+0x0): undefined reference to `typeinfo for int'
/tmp/ccffWxA1.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status



A very rough guess says, that I have f'd up with my dependencies.



Please have a look.



[Edit]
Plus, another rough guess is, maybe I need to include, libraries externally to GCC. Not sure though.
[Edit]
A very dumb question though.










share|improve this question


















marked as duplicate by mikewhatever, karel, Melebius, Kulfy, Fabby Jun 27 at 23:45


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    Your program runs in C++ without errors, so its logic is right. Rewrite the code in C and it will run with gcc. Or convert the code from C++ to C: How to convert C++ Code to C.

    – karel
    Jun 27 at 14:40












  • I think this question is not required. Can I delete it?

    – Aman Pandey
    Jun 27 at 14:47











  • Yeah, dude thanks. Believe me, I'm not that bad. Just having a very rough day.

    – Aman Pandey
    Jun 27 at 14:51

















0


















This question already has an answer here:



  • What is a command to compile and run C++ programs?

    5 answers



I created a very simple file in CPP, namely trash.cpp. Ran it using gcc trash.cpp



#include <iostream>
#include <string>

int main()
try
throw 6;

catch(int e)
std::cout << "Int exception thrown " << std::to_string(e) << std::endl;




It is showing very strange error. I dont know what to search for, so I'm posting my problem here.



aman@aman-Vostro-3578:~$ gcc trash.cpp
/tmp/ccffWxA1.o: In function `main':
trash.cpp:(.text+0x1e): undefined reference to `__cxa_allocate_exception'
trash.cpp:(.text+0x30): undefined reference to `typeinfo for int'
trash.cpp:(.text+0x38): undefined reference to `__cxa_throw'
trash.cpp:(.text+0x4e): undefined reference to `__cxa_begin_catch'
trash.cpp:(.text+0x61): undefined reference to `std::cout'
trash.cpp:(.text+0x66): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
trash.cpp:(.text+0x89): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
trash.cpp:(.text+0x93): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
trash.cpp:(.text+0x9e): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
trash.cpp:(.text+0xaa): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
trash.cpp:(.text+0xaf): undefined reference to `__cxa_end_catch'
trash.cpp:(.text+0xd4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
trash.cpp:(.text+0xde): undefined reference to `__cxa_end_catch'
/tmp/ccffWxA1.o: In function `__static_initialization_and_destruction_0(int, int)':
trash.cpp:(.text+0x11e): undefined reference to `std::ios_base::Init::Init()'
trash.cpp:(.text+0x133): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > __gnu_cxx::__to_xstring<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char>(int (*)(char*, unsigned long, char const*, __va_list_tag*), unsigned long, char const*, ...)':
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x113): undefined reference to `std::allocator<char>::allocator()'
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x159): undefined reference to `std::allocator<char>::~allocator()'
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x186): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider::~_Alloc_hider()':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderD2Ev[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderD5Ev]+0x14): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<char*, void>(char*, char*, std::allocator<char> const&)':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IPcvEET_S7_RKS3_[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IPcvEET_S7_RKS3_]+0x25): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_local_data()'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IPcvEET_S7_RKS3_[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IPcvEET_S7_RKS3_]+0x3a): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider::_Alloc_hider(char*, std::allocator<char> const&)'
/tmp/ccffWxA1.o: In function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag)':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x56): undefined reference to `std::__throw_logic_error(char const*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x8f): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xa1): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data(char*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xb4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_capacity(unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xc0): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xd6): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char*, char*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xe9): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length(unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x103): undefined reference to `__cxa_begin_catch'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x10f): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x114): undefined reference to `__cxa_rethrow'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x11c): undefined reference to `__cxa_end_catch'
/tmp/ccffWxA1.o:(.data.rel.local.DW.ref._ZTIi[DW.ref._ZTIi]+0x0): undefined reference to `typeinfo for int'
/tmp/ccffWxA1.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status



A very rough guess says, that I have f'd up with my dependencies.



Please have a look.



[Edit]
Plus, another rough guess is, maybe I need to include, libraries externally to GCC. Not sure though.
[Edit]
A very dumb question though.










share|improve this question


















marked as duplicate by mikewhatever, karel, Melebius, Kulfy, Fabby Jun 27 at 23:45


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • 1





    Your program runs in C++ without errors, so its logic is right. Rewrite the code in C and it will run with gcc. Or convert the code from C++ to C: How to convert C++ Code to C.

    – karel
    Jun 27 at 14:40












  • I think this question is not required. Can I delete it?

    – Aman Pandey
    Jun 27 at 14:47











  • Yeah, dude thanks. Believe me, I'm not that bad. Just having a very rough day.

    – Aman Pandey
    Jun 27 at 14:51













0












0








0









This question already has an answer here:



  • What is a command to compile and run C++ programs?

    5 answers



I created a very simple file in CPP, namely trash.cpp. Ran it using gcc trash.cpp



#include <iostream>
#include <string>

int main()
try
throw 6;

catch(int e)
std::cout << "Int exception thrown " << std::to_string(e) << std::endl;




It is showing very strange error. I dont know what to search for, so I'm posting my problem here.



aman@aman-Vostro-3578:~$ gcc trash.cpp
/tmp/ccffWxA1.o: In function `main':
trash.cpp:(.text+0x1e): undefined reference to `__cxa_allocate_exception'
trash.cpp:(.text+0x30): undefined reference to `typeinfo for int'
trash.cpp:(.text+0x38): undefined reference to `__cxa_throw'
trash.cpp:(.text+0x4e): undefined reference to `__cxa_begin_catch'
trash.cpp:(.text+0x61): undefined reference to `std::cout'
trash.cpp:(.text+0x66): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
trash.cpp:(.text+0x89): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
trash.cpp:(.text+0x93): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
trash.cpp:(.text+0x9e): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
trash.cpp:(.text+0xaa): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
trash.cpp:(.text+0xaf): undefined reference to `__cxa_end_catch'
trash.cpp:(.text+0xd4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
trash.cpp:(.text+0xde): undefined reference to `__cxa_end_catch'
/tmp/ccffWxA1.o: In function `__static_initialization_and_destruction_0(int, int)':
trash.cpp:(.text+0x11e): undefined reference to `std::ios_base::Init::Init()'
trash.cpp:(.text+0x133): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > __gnu_cxx::__to_xstring<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char>(int (*)(char*, unsigned long, char const*, __va_list_tag*), unsigned long, char const*, ...)':
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x113): undefined reference to `std::allocator<char>::allocator()'
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x159): undefined reference to `std::allocator<char>::~allocator()'
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x186): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider::~_Alloc_hider()':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderD2Ev[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderD5Ev]+0x14): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<char*, void>(char*, char*, std::allocator<char> const&)':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IPcvEET_S7_RKS3_[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IPcvEET_S7_RKS3_]+0x25): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_local_data()'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IPcvEET_S7_RKS3_[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IPcvEET_S7_RKS3_]+0x3a): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider::_Alloc_hider(char*, std::allocator<char> const&)'
/tmp/ccffWxA1.o: In function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag)':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x56): undefined reference to `std::__throw_logic_error(char const*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x8f): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xa1): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data(char*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xb4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_capacity(unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xc0): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xd6): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char*, char*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xe9): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length(unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x103): undefined reference to `__cxa_begin_catch'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x10f): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x114): undefined reference to `__cxa_rethrow'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x11c): undefined reference to `__cxa_end_catch'
/tmp/ccffWxA1.o:(.data.rel.local.DW.ref._ZTIi[DW.ref._ZTIi]+0x0): undefined reference to `typeinfo for int'
/tmp/ccffWxA1.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status



A very rough guess says, that I have f'd up with my dependencies.



Please have a look.



[Edit]
Plus, another rough guess is, maybe I need to include, libraries externally to GCC. Not sure though.
[Edit]
A very dumb question though.










share|improve this question


















This question already has an answer here:



  • What is a command to compile and run C++ programs?

    5 answers



I created a very simple file in CPP, namely trash.cpp. Ran it using gcc trash.cpp



#include <iostream>
#include <string>

int main()
try
throw 6;

catch(int e)
std::cout << "Int exception thrown " << std::to_string(e) << std::endl;




It is showing very strange error. I dont know what to search for, so I'm posting my problem here.



aman@aman-Vostro-3578:~$ gcc trash.cpp
/tmp/ccffWxA1.o: In function `main':
trash.cpp:(.text+0x1e): undefined reference to `__cxa_allocate_exception'
trash.cpp:(.text+0x30): undefined reference to `typeinfo for int'
trash.cpp:(.text+0x38): undefined reference to `__cxa_throw'
trash.cpp:(.text+0x4e): undefined reference to `__cxa_begin_catch'
trash.cpp:(.text+0x61): undefined reference to `std::cout'
trash.cpp:(.text+0x66): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
trash.cpp:(.text+0x89): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
trash.cpp:(.text+0x93): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
trash.cpp:(.text+0x9e): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
trash.cpp:(.text+0xaa): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
trash.cpp:(.text+0xaf): undefined reference to `__cxa_end_catch'
trash.cpp:(.text+0xd4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
trash.cpp:(.text+0xde): undefined reference to `__cxa_end_catch'
/tmp/ccffWxA1.o: In function `__static_initialization_and_destruction_0(int, int)':
trash.cpp:(.text+0x11e): undefined reference to `std::ios_base::Init::Init()'
trash.cpp:(.text+0x133): undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > __gnu_cxx::__to_xstring<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char>(int (*)(char*, unsigned long, char const*, __va_list_tag*), unsigned long, char const*, ...)':
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x113): undefined reference to `std::allocator<char>::allocator()'
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x159): undefined reference to `std::allocator<char>::~allocator()'
trash.cpp:(.text._ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z[_ZN9__gnu_cxx12__to_xstringINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEcEET_PFiPT0_mPKS8_P13__va_list_tagEmSB_z]+0x186): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider::~_Alloc_hider()':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderD2Ev[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderD5Ev]+0x14): undefined reference to `std::allocator<char>::~allocator()'
/tmp/ccffWxA1.o: In function `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string<char*, void>(char*, char*, std::allocator<char> const&)':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IPcvEET_S7_RKS3_[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IPcvEET_S7_RKS3_]+0x25): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_local_data()'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2IPcvEET_S7_RKS3_[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC5IPcvEET_S7_RKS3_]+0x3a): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider::_Alloc_hider(char*, std::allocator<char> const&)'
/tmp/ccffWxA1.o: In function `void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag)':
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x56): undefined reference to `std::__throw_logic_error(char const*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x8f): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xa1): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data(char*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xb4): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_capacity(unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xc0): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_data() const'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xd6): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy_chars(char*, char*, char*)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0xe9): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_set_length(unsigned long)'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x103): undefined reference to `__cxa_begin_catch'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x10f): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_dispose()'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x114): undefined reference to `__cxa_rethrow'
trash.cpp:(.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructIPcEEvT_S7_St20forward_iterator_tag]+0x11c): undefined reference to `__cxa_end_catch'
/tmp/ccffWxA1.o:(.data.rel.local.DW.ref._ZTIi[DW.ref._ZTIi]+0x0): undefined reference to `typeinfo for int'
/tmp/ccffWxA1.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status



A very rough guess says, that I have f'd up with my dependencies.



Please have a look.



[Edit]
Plus, another rough guess is, maybe I need to include, libraries externally to GCC. Not sure though.
[Edit]
A very dumb question though.





This question already has an answer here:



  • What is a command to compile and run C++ programs?

    5 answers







dependencies compiling gcc c++ c






share|improve this question
















share|improve this question













share|improve this question




share|improve this question








edited Jun 27 at 14:58







Aman Pandey

















asked Jun 27 at 14:11









Aman PandeyAman Pandey

987 bronze badges




987 bronze badges





marked as duplicate by mikewhatever, karel, Melebius, Kulfy, Fabby Jun 27 at 23:45


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











marked as duplicate by mikewhatever, karel, Melebius, Kulfy, Fabby Jun 27 at 23:45


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by mikewhatever, karel, Melebius, Kulfy, Fabby Jun 27 at 23:45


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 1





    Your program runs in C++ without errors, so its logic is right. Rewrite the code in C and it will run with gcc. Or convert the code from C++ to C: How to convert C++ Code to C.

    – karel
    Jun 27 at 14:40












  • I think this question is not required. Can I delete it?

    – Aman Pandey
    Jun 27 at 14:47











  • Yeah, dude thanks. Believe me, I'm not that bad. Just having a very rough day.

    – Aman Pandey
    Jun 27 at 14:51












  • 1





    Your program runs in C++ without errors, so its logic is right. Rewrite the code in C and it will run with gcc. Or convert the code from C++ to C: How to convert C++ Code to C.

    – karel
    Jun 27 at 14:40












  • I think this question is not required. Can I delete it?

    – Aman Pandey
    Jun 27 at 14:47











  • Yeah, dude thanks. Believe me, I'm not that bad. Just having a very rough day.

    – Aman Pandey
    Jun 27 at 14:51







1




1





Your program runs in C++ without errors, so its logic is right. Rewrite the code in C and it will run with gcc. Or convert the code from C++ to C: How to convert C++ Code to C.

– karel
Jun 27 at 14:40






Your program runs in C++ without errors, so its logic is right. Rewrite the code in C and it will run with gcc. Or convert the code from C++ to C: How to convert C++ Code to C.

– karel
Jun 27 at 14:40














I think this question is not required. Can I delete it?

– Aman Pandey
Jun 27 at 14:47





I think this question is not required. Can I delete it?

– Aman Pandey
Jun 27 at 14:47













Yeah, dude thanks. Believe me, I'm not that bad. Just having a very rough day.

– Aman Pandey
Jun 27 at 14:51





Yeah, dude thanks. Believe me, I'm not that bad. Just having a very rough day.

– Aman Pandey
Jun 27 at 14:51










1 Answer
1






active

oldest

votes


















3


















You are trying to compile it with a C compiler, not C++. To compile using a C++ compiler, try this command:



g++ trash.cpp





share|improve this answer


























  • I believe that was a very dumb question. Thanks though. Everyone. Was having a very rough day.

    – Aman Pandey
    Jun 27 at 14:54


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3


















You are trying to compile it with a C compiler, not C++. To compile using a C++ compiler, try this command:



g++ trash.cpp





share|improve this answer


























  • I believe that was a very dumb question. Thanks though. Everyone. Was having a very rough day.

    – Aman Pandey
    Jun 27 at 14:54















3


















You are trying to compile it with a C compiler, not C++. To compile using a C++ compiler, try this command:



g++ trash.cpp





share|improve this answer


























  • I believe that was a very dumb question. Thanks though. Everyone. Was having a very rough day.

    – Aman Pandey
    Jun 27 at 14:54













3














3










3









You are trying to compile it with a C compiler, not C++. To compile using a C++ compiler, try this command:



g++ trash.cpp





share|improve this answer














You are trying to compile it with a C compiler, not C++. To compile using a C++ compiler, try this command:



g++ trash.cpp






share|improve this answer













share|improve this answer




share|improve this answer










answered Jun 27 at 14:36









SurvivalMachineSurvivalMachine

2,0185 gold badges12 silver badges24 bronze badges




2,0185 gold badges12 silver badges24 bronze badges















  • I believe that was a very dumb question. Thanks though. Everyone. Was having a very rough day.

    – Aman Pandey
    Jun 27 at 14:54

















  • I believe that was a very dumb question. Thanks though. Everyone. Was having a very rough day.

    – Aman Pandey
    Jun 27 at 14:54
















I believe that was a very dumb question. Thanks though. Everyone. Was having a very rough day.

– Aman Pandey
Jun 27 at 14:54





I believe that was a very dumb question. Thanks though. Everyone. Was having a very rough day.

– Aman Pandey
Jun 27 at 14:54



Popular posts from this blog

Tamil (spriik) Luke uk diar | Nawigatjuun

Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?