I'm having trouble getting my code to compile. Below is the code I am trying to compile:
include <gclasses gmatrix.h=""></gclasses>
include <gclasses gholders.h=""></gclasses>
include <gclasses grand.h=""></gclasses>
include <gclasses glearner.h=""></gclasses>
include <gclasses gdom.h=""></gclasses>
include <iostream></iostream>
include <cassert></cassert>
using namespace GClasses;
using std::cout; using std::endl;
int main(int argc, char *argv[])
{
//Load my trained learner from a file named 2blobs_knn.json and put
//it in hModel which is a shared-pointer class.
GLearnerLoader ll(GRand::global());
GDom dom;
dom.loadJson("2blobs_knn.json");
Holder<gsupervisedlearner> hModel(ll.loadSupervisedLearner(dom.root()));
assert(hModel.get() != NULL);</gsupervisedlearner>
//Here is your code
GMatrix Instance(1,8);// Instance has 8 real attributes and one row
double out; // The value in attribute 'class' is nominal
Instance[0][0]=6;
Instance[0][1]=148;
Instance[0][2]=72;
Instance[0][3]=35;
Instance[0][4]=0;
Instance[0][5]=33.6;
Instance[0][6]=0.62;
Instance[0][7]=50;
hModel.get()->predict(Instance[0],&out);
cout << out << endl;
return 0;
}
Here is the compile error I recieve:
g++ -Wall -I/usr/local/include -g -D_DEBUG happy.cpp -o happy
/tmp/ccktLm9b.o: In function main':
/home/ericschles/happy.cpp:16: undefined reference toGClasses::GRand::global()'
/home/ericschles/happy.cpp:17: undefined reference to GClasses::GDom::GDom()'
/home/ericschles/happy.cpp:18: undefined reference toGClasses::GDom::loadJson(char const)'
/home/ericschles/happy.cpp:19: undefined reference to GClasses::GLearnerLoader::loadSupervisedLearner(GClasses::GDomNode*)'
/home/ericschles/happy.cpp:24: undefined reference toGClasses::GMatrix::GMatrix(unsigned long, unsigned long, GClasses::GHeap)'
/home/ericschles/happy.cpp:35: undefined reference to GClasses::GSupervisedLearner::predict(double const*, double*)'
/home/ericschles/happy.cpp:37: undefined reference toGClasses::GMatrix::~GMatrix()'
/home/ericschles/happy.cpp:37: undefined reference to GClasses::GDom::~GDom()'
/home/ericschles/happy.cpp:37: undefined reference toGClasses::GMatrix::~GMatrix()'
/home/ericschles/happy.cpp:37: undefined reference to GClasses::GDom::~GDom()'
/tmp/ccktLm9b.o: In functionGLearnerLoader':
/usr/local/include/GClasses/GLearner.h:455: undefined reference to vtable for GClasses::GLearnerLoader'
/tmp/ccktLm9b.o: In function~GLearnerLoader':
/usr/local/include/GClasses/GLearner.h:459: undefined reference to `vtable for GClasses::GLearnerLoader'
collect2: ld returned 1 exit status
I am able to make the demo's successfully and run the command line tools as well. So I'm a bit stumped. Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem is that your build command does not specify to link with the GClasses library, where all those things are defined. If you add "-lGClassesDbg" to your build command, I think that will probably fix it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2013-05-14
IT WORKED WOOOOOOHHHHHH
g++ happy.cpp -lGClassesDbg -o happy will work
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm having trouble getting my code to compile. Below is the code I am trying to compile:
include <gclasses gmatrix.h=""></gclasses>
include <gclasses gholders.h=""></gclasses>
include <gclasses grand.h=""></gclasses>
include <gclasses glearner.h=""></gclasses>
include <gclasses gdom.h=""></gclasses>
include <iostream></iostream>
include <cassert></cassert>
using namespace GClasses;
using std::cout; using std::endl;
int main(int argc, char *argv[])
{
//Load my trained learner from a file named 2blobs_knn.json and put
//it in hModel which is a shared-pointer class.
GLearnerLoader ll(GRand::global());
GDom dom;
dom.loadJson("2blobs_knn.json");
Holder<gsupervisedlearner> hModel(ll.loadSupervisedLearner(dom.root()));
assert(hModel.get() != NULL);</gsupervisedlearner>
//Here is your code
GMatrix Instance(1,8);// Instance has 8 real attributes and one row
double out; // The value in attribute 'class' is nominal
Instance[0][0]=6;
Instance[0][1]=148;
Instance[0][2]=72;
Instance[0][3]=35;
Instance[0][4]=0;
Instance[0][5]=33.6;
Instance[0][6]=0.62;
Instance[0][7]=50;
hModel.get()->predict(Instance[0],&out);
cout << out << endl;
return 0;
}
Here is the compile error I recieve:
g++ -Wall -I/usr/local/include -g -D_DEBUG happy.cpp -o happy
/tmp/ccktLm9b.o: In function
main': /home/ericschles/happy.cpp:16: undefined reference to
GClasses::GRand::global()'/home/ericschles/happy.cpp:17: undefined reference to
GClasses::GDom::GDom()' /home/ericschles/happy.cpp:18: undefined reference to
GClasses::GDom::loadJson(char const)'/home/ericschles/happy.cpp:19: undefined reference to
GClasses::GLearnerLoader::loadSupervisedLearner(GClasses::GDomNode*)' /home/ericschles/happy.cpp:24: undefined reference to
GClasses::GMatrix::GMatrix(unsigned long, unsigned long, GClasses::GHeap)'/home/ericschles/happy.cpp:35: undefined reference to
GClasses::GSupervisedLearner::predict(double const*, double*)' /home/ericschles/happy.cpp:37: undefined reference to
GClasses::GMatrix::~GMatrix()'/home/ericschles/happy.cpp:37: undefined reference to
GClasses::GDom::~GDom()' /home/ericschles/happy.cpp:37: undefined reference to
GClasses::GMatrix::~GMatrix()'/home/ericschles/happy.cpp:37: undefined reference to
GClasses::GDom::~GDom()' /tmp/ccktLm9b.o: In function
GLearnerLoader':/usr/local/include/GClasses/GLearner.h:455: undefined reference to
vtable for GClasses::GLearnerLoader' /tmp/ccktLm9b.o: In function
~GLearnerLoader':/usr/local/include/GClasses/GLearner.h:459: undefined reference to `vtable for GClasses::GLearnerLoader'
collect2: ld returned 1 exit status
I am able to make the demo's successfully and run the command line tools as well. So I'm a bit stumped. Thanks!
The problem is that your build command does not specify to link with the GClasses library, where all those things are defined. If you add "-lGClassesDbg" to your build command, I think that will probably fix it.
IT WORKED WOOOOOOHHHHHH
g++ happy.cpp -lGClassesDbg -o happy will work