gpt4 book ai didi

c++ - 未定义的成员函数引用

转载 作者:行者123 更新时间:2023-11-28 08:26:01 24 4
gpt4 key购买 nike

我刚刚以为我解决了a problem ,但似乎又出现了另一个问题——或者至少以另一种形式出现了同样的问题。现在,当我尝试按照该问题的答案中的建议重建所有内容时,所有 Qt Creator 在构建问题中显示的是一行 collect2: ld returned 1 exit status

这是我认为可能相关的一些编译输出:

Running build steps for project Othello-cmd...
Starting: "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" clean -w
[snipped]
C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Release clean

Could Not Find C:\Users\Amos Ng\My Dropbox\School\College\2010.. Fall\CS 3A\Othello-cmd-build-desktop\debug\main.o //this was in red

mingw32-make[1]: Entering directory `C:/Users/Amos Ng/My Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd-build-desktop'

del release\main.o release\board.o release\player.o release\referee.o release\misc.o release\humanplayer.o release\computerplayer.o release\chatter.o release\chatserver.o release\location.o
mingw32-make[1]: Leaving directory `C:/Users/Amos Ng/My Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd-build-desktop'

mingw32-make: Leaving directory `C:/Users/Amos Ng/My Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd-build-desktop'

Could Not Find C:\Users\Amos Ng\My Dropbox\School\College\2010.. Fall\CS 3A\Othello-cmd-build-desktop\release\main.o

//these next 3 lines are in blue
The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited normally.
Configuration unchanged, skipping qmake step.
Starting: "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w
mingw32-make: Entering directory `C:/Users/Amos Ng/My Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd-build-desktop'
[snipped]
//A bunch of lines similar to
g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I"c:\Qt\2010.05\qt\include\QtCore" -I"c:\Qt\2010.05\qt\include" -I"c:\Qt\2010.05\qt\include\ActiveQt" -I"debug" -I"\\psf\Dropbox\School\College\2010.. Fall\CS 3A\Othello-cmd" -I"." -I"c: "filepath of .o file" "filepath of .cpp file"

g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -mthreads -Wl -o debug\Othello-cmd.exe object_script.Othello-cmd.Debug -L"c:\Qt\2010.05\qt\lib" -lQtCored4

//everything's red starting here...

./debug\board.o://psf/Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd/board.cpp:29: undefined reference to `OPiece::OPiece(int)'

./debug\board.o://psf/Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd/board.cpp:39: undefined reference to `OPiece::flip()'

./debug\board.o://psf/Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd/board.cpp:76: undefined reference to `OPiece::display()'

./debug\board.o://psf/Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd/board.cpp:110: undefined reference to `OPiece::display()'

./debug\board.o://psf/Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd/board.cpp:159: undefined reference to `OPiece::OPiece(int)'

//couple more lines just like the above

collect2: ld returned 1 exit status

//...finally things are black again

mingw32-make[1]: Leaving directory `C:/Users/Amos Ng/My Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd-build-desktop'

mingw32-make: Leaving directory `C:/Users/Amos Ng/My Dropbox/School/College/2010.. Fall/CS 3A/Othello-cmd-build-desktop'

//everything's red again

mingw32-make[1]: *** [debug\Othello-cmd.exe] Error 1

mingw32-make: *** [debug] Error 2

The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project Othello-cmd (target: Desktop)
When executing build step 'Make'

关于可能导致此错误的原因有什么想法吗?

编辑:我还想指出,我确实在调试目录中找到了“main.o”...

解决方案(不是真的):我改为在 Netbeans 中重新编译所有内容(虽然在 Mac 上,所以链接器可能不同......)。现在程序运行正常了……再见Qt Creator

最佳答案

我会试着猜测。您要么使用了错误的 namespace (即将 #include 指令放在 namespace 的主体中)。或者您没有按照建议完全删除 debug 和 release 目录。

关于c++ - 未定义的成员函数引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4057100/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com