0

新しいモジュールを作成し、次の行を使用してメイン クラスにリンクしようとするたびに(Estudiant.o):

g++ -o red1.exe red1.o %OBJETOS_CPP%\Estudiant.o

次のエラーが表示されます。

red1.o:red1.cpp:(.text+0xd): Estudiant::consultar_DNI() const' red1.o:red1.cpp:(.text+0x18): undefined reference toEstudiant::Estudiant(int) への未定義の参照' red1.o:red1.cpp:(.text+0x25): Estudiant::consultar_nota() const' red1.o:red1.cpp:(.text+0x74): undefined reference toEstudiant::afegir_nota(doubleへの未定義の参照)' red1.o:red1.cpp:(.text+0x83): Estudiant::~Estudiant()' red1.o:red1.cpp:(.text+0xa3): undefined reference toEstudiant への未定義の参照::consultar_nota() const' red1.o:red1.cpp:(.text+0xe5): Estudiant への未定義の参照 Estudiant::modificar_nota(double)' red1.o:red1.cpp:(.text+0x10b): undefined reference to::Estudiant ()' red1.o:red1.cpp:(.text+0x13a): Estudiant::llegir_estudiant()' red1.o:red1.cpp:(.text+0x144): undefined reference toEstudiant への未定義の参照::te_nota() const' red1.o:red1.cpp:(.text+0x182): Estudiant::escriure_estudiant() const' red1.o:red1.cpp:(.text+0x18c): undefined reference toEstudiant への未定義の参照:: ~Estudiant()' red1.o:red1.cpp:(.text+0x19f): Estudiant::~Estudiant()' c:/mingw/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: red1.o: bad reloc address 0x0 in section.ctors' collect2.exe への未定義の参照: エラー: ld が 1 つの終了ステータスを返しました

また、元の Estudiant.cpp を持っていないので、コンパイルとリンクに異なるコンパイラが使用された可能性があると考えましたが、MinGW を再インストールしましたが、まだこのエラーが発生しています。また、すべてのファイルを置き換えようとしましたが、うまくいきませんでした。

4

1 に答える 1

0

Estudiant.oのソースコードを取得し、そのコードを使用して別のバージョンをコンパイルすると、機能しました。同じコードが2つの異なるマシンでコンパイルされ、一方が機能し、もう一方が機能しなかった理由はわかりません。

于 2013-02-19T10:36:12.953 に答える