:-1: error: symbol(s) not found for architecture x86_64 & :-1: error: collect2: ld returned 1 exit status
-
I'm learning QT and i have abplayer.h and abplayer.cpp files. standard C++ codes. can't build with the constructors and destructor in the cpp file. help? anyone? please? thanks!
04:23:41: Running build steps for project CatTeV2...
04:23:41: Configuration unchanged, skipping qmake step.
04:23:41: Starting: "/usr/bin/make" -w
make: Entering directory/Users/vietriceboy/SSE554Projects/CatTeV2-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK__Debug' g++ -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.5 -o CatTeV2.app/Contents/MacOS/CatTeV2 main.o cattev2.o card.o hand.o AbPlayer.o moc_cattev2.o qrc_cards.o -F/Users/vietriceboy/QtSDK/Desktop/Qt/4.8.0/gcc/lib -L/Users/vietriceboy/QtSDK/Desktop/Qt/4.8.0/gcc/lib -framework QtGui -framework QtCore Undefined symbols for architecture x86_64: make: Leaving directory
/Users/vietriceboy/SSE554Projects/CatTeV2-build-desktop-Desktop_Qt_4_8_0_for_GCC__Qt_SDK__Debug'
"vtable for AbPlayer", referenced from:
AbPlayer::AbPlayer(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in AbPlayer.o
AbPlayer::AbPlayer(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in AbPlayer.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [CatTeV2.app/Contents/MacOS/CatTeV2] Error 1
04:23:41: The process "/usr/bin/make" exited with code 2.
Error while building project CatTeV2 (target: Desktop)
When executing build step 'Make' -
Are you moc-ing AbPlayer.cpp? Is there a Q_OBJECT line in the AbPlayer class?
Try rerunning qmake and then doing a clean build.
-
nope ... here is the header and cpp files. I hope this help and thanks again.
#ifndef ABPLAYER_H
#define ABPLAYER_H#include <iostream>
#include <string>
#include <vector>#include <QWidget>
#include <QListView>
#include"hand.h"class AbPlayer : public Hand
{
friend ostream& operator<<(ostream& os, const AbPlayer& aAbPlayer);public:
AbPlayer(const string& s);
QString makeLabelString();
virtual void makePixmaps(AbPlayer& ) ;virtual ~AbPlayer(); //indicates whether or not generic player wants to keep hitting virtual bool isHitting() const = 0; //returns whether generic player has busted - has a total greater than 21 bool isBusted() const; //announces that the generic player busts QString bust() const; QString& getLabelQStr() const; string getName() const;
protected:
string name;
Hand *hand;
mutable QString labelQStr;
};#endif // ABSTRACTPLAYER_H
#include <iostream>
#include <typeinfo>
#include <string>
#include <vector>
#include <algorithm>
#include <ctime>
#include <sstream>
#include <QMessageBox>#include"AbPlayer.h"
using namespace std;
class QLabel;
class QString;AbPlayer::AbPlayer(const string &s): name(s)
{}
string AbPlayer::getName() const
{
return name;
}QString& AbPlayer::getLabelQStr() const
{
return labelQStr;
}bool AbPlayer::isBusted() const
{
return (getTotal() > 21);
}QString AbPlayer::bust() const
{
string str = "";
ostringstream oss ;
oss << "";
oss << name << " bust! ";
str = oss.str();
return str.c_str();
}