したがって、問題の原因を突き止めることができないのは、これらのコンパイラ エラーの 1 つです。
これはクラスLocalQualityMeasure
、ヘッダーです
#include <unordered_set>
#include "../clustering/Clustering.h"
#include "../graph/Graph.h"
namespace Project {
/**
* Abstract base class for all local clustering quality measures.
*/
class LocalQualityMeasure {
public:
LocalQualityMeasure();
virtual ~LocalQualityMeasure();
virtual double getQuality(std::unordered_set<node>& C, Graph& G) = 0;
};
} /* namespace Project */
およびソース:
#include "LocalQualityMeasure.h"
namespace Project {
LocalQualityMeasure::LocalQualityMeasure() {
}
LocalQualityMeasure::~LocalQualityMeasure() {
// TODO Auto-generated destructor stub
}
} /* namespace Project */
そして、これは派生クラスConductance
、ヘッダーです
#include <algorithm>
#include "LocalQualityMeasure.h"
namespace Project {
class Conductance: public Project::LocalQualityMeasure {
public:
Conductance();
virtual ~Conductance();
virtual double getQuality(std::unordered_set<node>& C, Graph& G);
};
} /* namespace Project */
とソース
#include "Conductance.h"
namespace Project {
Conductance::Conductance() : LocalQualityMeasure() {
}
Conductance::~Conductance() {
// TODO Auto-generated destructor stub
}
double getQuality(std::unordered_set<node>& C, Graph& G) {
double volume = 0;
double boundary = 0;
double all = 0;
for (auto it = C.begin(); it != C.end(); ++it) {
volume = volume + G.degree(*it);
G.forNeighborsOf(*it, [&](node v){
if (C.find(v) == C.end()) boundary++;
});
}
G.forNodes([&](node v){
all = all + G.degree(v);
});
if (volume == 0 || all-volume == 0)
return 1;
return boundary / std::min(volume, all-volume);
}
} /* namespace Project */
リンカは vtable の欠落について不平を言います:
Undefined symbols for architecture x86_64:
"Project::Conductance::getQuality(std::unordered_set<long long, std::hash<long long>, std::equal_to<long long>, std::allocator<long long> >&, Project::Graph&)", referenced from:
vtable for Project::Conductance in Conductance.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [Project-CommunityDetection-DPar] Error 1
でGCC 4.7を使用してい--std=c++11
ます。