Undefined reference to member functions
I had just thought I resolved a problem, but it seemed another one cropped up--or at least the same problem in another form. Now when I try to rebuild everything as suggested in the answer to that question, all Qt Creator shows in build issues is a one line collect2: ld returned 1 exit status
Here's some of the compile output that I think might be relevant:
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 Dropb开发者_运维技巧ox\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'
Any ideas on what might be causing this error?
EDIT: I would also like to note that I did find "main.o" inside the debug directory...
SOLUTION (not really): I recompiled everything in Netbeans instead (on a Mac though, so maybe the linker was different...). Now the program is running fine... goodbye Qt Creator
I'll try to guess. You are either using namespaces wrong (i.e. put #include directive in the body of namespace). Or you haven't deleted debug and release directories completely as you were advised.
精彩评论