g++链接中未定义的引用
Undefined reference in g++ linking
每次我制作一个新模块并尝试使用以下行将其链接到我的主类(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 to
研究者::研究者(int)'red1.o:red1.cpp:(.text+0x25):未定义对的引用Estudiant::consultar_nota() const' red1.o:red1.cpp:(.text+0x74): undefined reference to
研究者::afegir_nota(双)'red1.o:red1.cpp:(.text+0x83):未定义对的引用Estudiant::~Estudiant()' red1.o:red1.cpp:(.text+0xa3): undefined reference to
研究者::consultar_nota()常量red1.o:red1.cpp:(.text+0xe5):对的未定义引用Estudiant::modificar_nota(double)' red1.o:red1.cpp:(.text+0x10b): undefined reference to
Estudiant::Estudiant()'red1.o:red1.cpp:(.text+0x13a):对的未定义引用Estudiant::llegir_estudiant()' red1.o:red1.cpp:(.text+0x144): undefined reference to
研究者::te_nota()常量red1.o:red1.cpp:(.text+0x182):对的未定义引用Estudiant::escriure_estudiant() const' red1.o:red1.cpp:(.text+0x18c): undefined reference to
Estudiant::~ 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,我仍然收到这个错误。我还试图替换所有的文件,但没有成功。
我设法获得了Estudiant.o的源代码,并使用该代码编译了它的另一个版本,它成功了。我不知道为什么同一个代码在两台不同的机器上编译,一台工作,另一台不工作。
- 编译C++时未定义的引用
- 如何修复此错误:未定义对"距离(浮点数,浮点数,浮点数,浮点数,浮点数)"的引用
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 对C宏的未定义引用,但在定义它时会出现重新定义错误
- 未定义的引用在哪里
- 编译时的 CImg 库返回对"__imp_SetDIBitsToDevice"的未定义引用
- 对Py_Initialize()的未定义引用
- 使用mysql c++连接器的未定义引用
- 未定义的引用 .. 使用 OpenCV 编译 C++ 代码时,从命令行
- 对 Scalar ::Scalar() 的未定义引用
- 已定义函数时出现 G++ "未定义的引用"错误
- 链接 cmake 时出现未定义的引用错误
- 对复制 CTOR 和 CTOR 的未定义引用
- 错误:未定义对'oboe::AudioStreamBuilder::openStream(oboe::AudioStream**)'的引用
- 右值引用未定义的行为
- 对"vtable for DigitalClock"的未定义引用 - 未定义对"DigitalClock::staticMetaObject"的引用 - Qt
- 函数类型到函数类型的引用:未定义的引用
- avcodec_alloc_context引用未定义,但ffmpeg链接顺序正确
- 从c++调用Fortran子程序,链接时引用未定义
- 枚举引用未定义,但位于包含的头文件中