g ++ est en train de sortir une erreur obscure, undefined reference to '__gxx_personality_sj0'
dans deux lignes de mon projet. Qu'est-ce que cela signifie dans ce contexte? J'ai beaucoup googlé et j'ai découvert que cela est généralement lié à l'inclusion de code C en C++ ou quelque chose comme ça, ce qui n'est pas ce que je vais faire. (Je sais que le code n'est pas de haute qualité, mais devrait compiler, je crois).Obscure erreur de compilation sur le morceau de code C++ débutant
Projecto.cpp
#include "Projecto.h"
#include <iostream>
#include <iomanip>
#include <string>
Projecto::~Projecto() {} //THIS LINE GETS THAT ERROR
void Projecto::adicionaVerba(float quantia){
verba+=quantia;
if(verba > verbamaxima)
verba -= quantia;
}
std::string Projecto::Tipo()
{ //THIS LINE GETS THAT ERROR
return "Projecto";
}
void Projecto::Imprime()
{
Identificador::Imprime();
cout << verbamaxima << endl;
}
bool Projecto::operator> (const Projecto &proj2) const
{
return proj2.verba > this->verba;
}
Projecto.h
#ifndef PROJECTO_H_
#define PROJECTO_H_
#include <iostream>
#include <iomanip>
#include "Identificador.h"
#include <string>
#include <vector>
using namespace std;
class Projecto: public Identificador {
protected:
int verbamaxima;
vector<string> projecto;
float verba;
public:
Projecto(int verbamaxima = 0):Identificador("Projecto") {verba=0;}
~Projecto();
string Tipo();
void Imprime();
void adicionaVerba(float quantia);
bool operator> (const Projecto &proj2) const;
};
#endif /* IDENTIFICADOR_H_ */
Identificador.cpp
#include "Identificador.h"
using namespace std;
#include <iostream>
#include <iomanip>
using namespace std;
Identificador::Identificador(string nome):codigo(id)
{
Identificador::nome = nome;
id+=2;
}
Identificador::~Identificador()
{
}
int Identificador::id = 1000;
string Identificador::Tipo(){}
void Identificador::Imprime()
{
cout << Tipo() << endl;
cout << Codigo() << endl;
cout << Nome() << endl;
}
int Identificador::Codigo() const
{
return codigo;
}
string Identificador::Nome()
{
return nome;
}
Identificador.h
#ifndef IDENTIFICADOR_H_
#define IDENTIFICADOR_H_
#include <iostream>
#include <iomanip>
using namespace std;
class Identificador {
protected:
static int id;
const int codigo;
string nome;
public:
Identificador(string nome);
virtual ~Identificador();
virtual string Tipo();
virtual void Imprime();
int Codigo() const;
string Nome();
};
#endif /* IDENTIFICADOR_H_ */
Merci d'avoir lu jusqu'ici!
EDIT:
J'utilise Eclipse avec le toolchain mingw. J'ai récemment installé la distribution Mingw de Nuwen à la place de la version officielle. Compiler le projet, je reçois ce que la sortie de la console (jamais arrivé auparavant):
**** Build of configuration Debug for project estudo_CI1 ****
**** Internal Builder is used for build ****
g++ -oestudo_CI1.exe src\main.o src\Universidade.o src\Projecto.o src\Investigador.o src\Identificador.o
Warning: .drectve `-aligncomm:___mingw_gMTRemoveKeyDtor,2 ' unrecognized
Warning: .drectve `-aligncomm:___mingw_gMTKeyDtor,2 ' unrecognized
Warning: .drectve `-aligncomm:___mingw_usemthread_dll,2' unrecognized
Warning: .drectve `-aligncomm:___hexdig_D2A,2' unrecognized
src\Projecto.o: In function `ZN8ProjectoD2Ev':
C:/Users/Francisco/workspace_aeda/estudo_CI1/Debug/../src/Projecto.cpp:16: undefined reference to `__gxx_personality_sj0'
src\Projecto.o: In function `ZN8ProjectoD1Ev':
C:/Users/Francisco/workspace_aeda/estudo_CI1/Debug/../src/Projecto.cpp:16: undefined reference to `__gxx_personality_sj0'
src\Projecto.o: In function `ZN8ProjectoD0Ev':
C:/Users/Francisco/workspace_aeda/estudo_CI1/Debug/../src/Projecto.cpp:16: undefined reference to `__gxx_personality_sj0'
src\Projecto.o: In function `ZN8Projecto4TipoEv':
C:/Users/Francisco/workspace_aeda/estudo_CI1/Debug/../src/Projecto.cpp:27: undefined reference to `__gxx_personality_sj0'
src\Projecto.o: In function `ZNSt12_Vector_baseISsSaISsEE12_Vector_implD1Ev':
C:/strawberry/c/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_vector.h:(.text$_ZNSt6vectorISsSaISsEED1Ev[std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::~vector()]+0xc): undefined reference to `__gxx_personality_sj0'
src\Projecto.o:C:/strawberry/c/bin/../lib/gcc/mingw32/3.4.5/../../../../include/c++/3.4.5/bits/stl_vector.h:(.text$_ZNSt12_Vector_baseISsSaISsEED2Ev[std::_Vector_base<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::~_Vector_base()]+0xc): more undefined references to `__gxx_personality_sj0' follow
/mingw/lib/libstdc++.a(ios_init.o):ios_init.cc:(.text$_ZNSt8ios_base4InitC2Ev+0x719): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ios_init.o):ios_init.cc:(.text$_ZNSt8ios_base4InitC2Ev+0x739): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ios_init.o):ios_init.cc:(.text$_ZNSt8ios_base4InitC2Ev+0x759): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ios_init.o):ios_init.cc:(.text$_ZNSt8ios_base4InitC2Ev+0x779): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ios_init.o):ios_init.cc:(.text$_ZNSt8ios_base4InitC2Ev+0x799): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ios_init.o):ios_init.cc:(.text$_ZNSt8ios_base4InitC2Ev+0x7b9): more undefined references to `_Unwind_Resume' follow
/mingw/lib/libstdc++.a(eh_throw.o):eh_throw.cc:(.text$__cxa_throw+0x4e): undefined reference to `_Unwind_RaiseException'
/mingw/lib/libstdc++.a(eh_throw.o):eh_throw.cc:(.text$__cxa_rethrow+0x37): undefined reference to `_Unwind_Resume_or_Rethrow'
/mingw/lib/libstdc++.a(misc-inst.o):misc-inst.cc:(.text$_ZStrsIwSt11char_traitsIwESaIwEERSt13basic_istreamIT_T0_ES7_RSbIS4_S5_T1_E[std::basic_istream<wchar_t, std::char_traits<wchar_t> >& std::operator>><wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >(std::basic_istream<wchar_t, std::char_traits<wchar_t> >&, std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >&)]+0x270): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ios.o):ios.cc:(.text$_ZNSt8ios_baseD2Ev+0xd1): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ios.o):ios.cc:(.text$_ZNSt8ios_baseD0Ev+0xd6): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ios.o):ios.cc:(.text$_ZNSt8ios_base13_M_grow_wordsEib+0x126): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ios.o):ios.cc:(.text$_ZNSt8ios_base13_M_grow_wordsEib+0x18e): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ios.o):ios.cc:(.text$_ZNSt8ios_base17_M_call_callbacksENS_5eventE+0x4b): more undefined references to `_Unwind_Resume' follow
/mingw/lib/libstdc++.a(eh_personality.o):eh_personality.cc:(.text$__gxx_personality_v0+0xce): undefined reference to `_Unwind_GetIPInfo'
/mingw/lib/libstdc++.a(eh_personality.o):eh_personality.cc:(.text$__cxa_call_unexpected+0xd5): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ext-inst.o):ext-inst.cc:(.text$_ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEED1Ev[__gnu_cxx::stdio_filebuf<char, std::char_traits<char> >::~stdio_filebuf()]+0x67): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ext-inst.o):ext-inst.cc:(.text$_ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEED0Ev[__gnu_cxx::stdio_filebuf<char, std::char_traits<char> >::~stdio_filebuf()]+0x6f): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ext-inst.o):ext-inst.cc:(.text$_ZN9__gnu_cxx13stdio_filebufIwSt11char_traitsIwEED1Ev[__gnu_cxx::stdio_filebuf<wchar_t, std::char_traits<wchar_t> >::~stdio_filebuf()]+0x67): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ext-inst.o):ext-inst.cc:(.text$_ZN9__gnu_cxx13stdio_filebufIwSt11char_traitsIwEED0Ev[__gnu_cxx::stdio_filebuf<wchar_t, std::char_traits<wchar_t> >::~stdio_filebuf()]+0x6f): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(ext-inst.o):ext-inst.cc:(.text$_ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC2EiSt13_Ios_Openmodej[__gnu_cxx::stdio_filebuf<char, std::char_traits<char> >::stdio_filebuf(int, std::_Ios_Openmode, unsigned int)]+0xb1): more undefined references to `_Unwind_Resume' follow
/mingw/lib/libstdc++.a(eh_globals.o):eh_globals.cc:(.text$__cxa_get_globals_fast+0xb): undefined reference to `__emutls_get_address'
/mingw/lib/libstdc++.a(eh_globals.o):eh_globals.cc:(.text$__cxa_get_globals+0xb): undefined reference to `__emutls_get_address'
/mingw/lib/libstdc++.a(istream.o):istream.cc:(.text$_ZNSi7getlineEPcic+0x26d): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(istream.o):istream.cc:(.text$_ZNSi6ignoreEii+0x2a4): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(istream.o):istream.cc:(.text$_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_PS3_+0x241): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(istream.o):istream.cc:(.text$_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RSbIS4_S5_T1_E+0x2d9): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(istream.o):istream.cc:(.text$_ZSt7getlineIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RSbIS4_S5_T1_ES4_+0x2a1): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(istream.o):istream.cc:(.text$_ZNSt13basic_istreamIwSt11char_traitsIwEE7getlineEPwiw+0x2a5): more undefined references to `_Unwind_Resume' follow
/mingw/lib/libstdc++.a(guard.o):guard.cc:(.text$_ZN12_GLOBAL__N_1L4initEv+0x14): undefined reference to `__gthr_win32_recursive_mutex_init_function'
/mingw/lib/libstdc++.a(guard.o):guard.cc:(.text$_ZN9__gnu_cxx17__recursive_mutex6unlockEv[__gnu_cxx::__recursive_mutex::unlock()]+0x15): undefined reference to `__gthr_win32_recursive_mutex_unlock'
/mingw/lib/libstdc++.a(guard.o):guard.cc:(.text$__cxa_guard_acquire+0x40): undefined reference to `__gthr_win32_recursive_mutex_lock'
/mingw/lib/libstdc++.a(guard.o):guard.cc:(.text$__cxa_guard_acquire+0xe8): undefined reference to `__gthr_win32_recursive_mutex_unlock'
/mingw/lib/libstdc++.a(guard.o):guard.cc:(.text$__cxa_guard_acquire+0x12d): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(guard.o):guard.cc:(.text$__cxa_guard_abort+0x21): undefined reference to `__gthr_win32_recursive_mutex_unlock'
/mingw/lib/libstdc++.a(guard.o):guard.cc:(.text$__cxa_guard_abort+0x5c): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(guard.o):guard.cc:(.text$__cxa_guard_release+0x29): undefined reference to `__gthr_win32_recursive_mutex_unlock'
/mingw/lib/libstdc++.a(guard.o):guard.cc:(.text$__cxa_guard_release+0x64): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(c++locale.o):c++locale.cc:(.text$_ZSt14__convert_to_vIfEvPKcRT_RSt12_Ios_IostateRKPi+0x126): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(c++locale.o):c++locale.cc:(.text$_ZSt14__convert_to_vIdEvPKcRT_RSt12_Ios_IostateRKPi+0x129): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(c++locale.o):c++locale.cc:(.text$_ZSt14__convert_to_vIeEvPKcRT_RSt12_Ios_IostateRKPi+0x151): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(iostream-inst.o):iostream-inst.cc:(.text$_ZNSdC2EPSt15basic_streambufIcSt11char_traitsIcEE[std::basic_iostream<char, std::char_traits<char> >::basic_iostream(std::basic_streambuf<char, std::char_traits<char> >*)]+0x9b): undefined reference to `_Unwind_Resume'
/mingw/lib/libstdc++.a(iostream-inst.o):iostream-inst.cc:(.text$_ZNSdC1EPSt15basic_streambufIcSt11char_traitsIcEE[std::basic_iostream<char, std::char_traits<char> >::basic_iostream(std::basic_streambuf<char, std::char_traits<char> >*)]+0xea): more undefined references to `_Unwind_Resume' follow
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 1621 ms.
EDIT 2:
Cela n'a probablement rien à voir avec le code ci-dessus, tous les projets que je Compile semblent échouer avec ces erreurs (ils ont bien compilé avant).
EDIT 3: RÉSOLU en supprimant .metadata
. Merci quand même les gars.
Ajout de plus de détails comme demandé. Merci! –
Je compile avec g ++, toutes les extensions sont correctes. –