Dear all
I am the new user of Dynet. I followed strictly the procudure and passed the example test (./examples/xor).
However, when i tried to compile the example in dynet/examples/xor/train_xor.cc, I always met the undefined reference problem.
The command that I use is :
g++ -Wall -o test.o -I /home/xudong/Dynet/dynet/ -L /home/xudong/Dynet/dynet/build/dynet -ldynet -std=c++11 train_xor.cc
Which I follow exactly what has been indicated over the website:
The problem i met is:
/tmp/ccC0gRoZ.o: In function `main':
train_xor.cc:(.text+0x162): undefined reference to `dynet::initialize(int&, char**&, bool)'
train_xor.cc:(.text+0x17b): undefined reference to `dynet::ParameterCollection::ParameterCollection()'
train_xor.cc:(.text+0x1ad): undefined reference to `dynet::default_device'
train_xor.cc:(.text+0x249): undefined reference to `dynet::ParameterCollection::add_parameters(dynet::Dim const&, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, dynet::Device*)'
train_xor.cc:(.text+0x26e): undefined reference to `dynet::default_device'
train_xor.cc:(.text+0x30a): undefined reference to `dynet::ParameterCollection::add_parameters(dynet::Dim const&, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, dynet::Device*)'
train_xor.cc:(.text+0x32f): undefined reference to `dynet::default_device'
train_xor.cc:(.text+0x3cb): undefined reference to `dynet::ParameterCollection::add_parameters(dynet::Dim const&, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, dynet::Device*)'
train_xor.cc:(.text+0x3f0): undefined reference to `dynet::default_device'
train_xor.cc:(.text+0x47a): undefined reference to `dynet::ParameterCollection::add_parameters(dynet::Dim const&, float, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, dynet::Device*)'
train_xor.cc:(.text+0x4f6): undefined reference to `dynet::TextFileLoader::TextFileLoader(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
train_xor.cc:(.text+0x55e): undefined reference to `dynet::TextFileLoader::populate(dynet::ParameterCollection&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
train_xor.cc:(.text+0x58b): undefined reference to `dynet::TextFileLoader::~TextFileLoader()'
train_xor.cc:(.text+0x59a): undefined reference to `dynet::ComputationGraph::ComputationGraph()'
train_xor.cc:(.text+0x5cc): undefined reference to `dynet::parameter(dynet::ComputationGraph&, dynet::Parameter)'
train_xor.cc:(.text+0x61b): undefined reference to `dynet::parameter(dynet::ComputationGraph&, dynet::Parameter)'
train_xor.cc:(.text+0x66a): undefined reference to `dynet::parameter(dynet::ComputationGraph&, dynet::Parameter)'
train_xor.cc:(.text+0x6b9): undefined reference to `dynet::parameter(dynet::ComputationGraph&, dynet::Parameter)'
train_xor.cc:(.text+0x716): undefined reference to `dynet::default_device'
train_xor.cc:(.text+0x763): undefined reference to `dynet::input(dynet::ComputationGraph&, dynet::Dim const&, std::vector<float, std::allocator<float> > const*, dynet::Device*)'
train_xor.cc:(.text+0x778): undefined reference to `dynet::default_device'
train_xor.cc:(.text+0x791): undefined reference to `dynet::input(dynet::ComputationGraph&, float const*, dynet::Device*)'
train_xor.cc:(.text+0x7b8): undefined reference to `dynet::operator*(dynet::Expression const&, dynet::Expression const&)'
train_xor.cc:(.text+0x7df): undefined reference to `dynet::operator+(dynet::Expression const&, dynet::Expression const&)'
train_xor.cc:(.text+0x7fc): undefined reference to `dynet::tanh(dynet::Expression const&)'
train_xor.cc:(.text+0x823): undefined reference to `dynet::operator*(dynet::Expression const&, dynet::Expression const&)'
train_xor.cc:(.text+0x84a): undefined reference to `dynet::operator+(dynet::Expression const&, dynet::Expression const&)'
train_xor.cc:(.text+0x871): undefined reference to `dynet::squared_distance(dynet::Expression const&, dynet::Expression const&)'
train_xor.cc:(.text+0x88e): undefined reference to `dynet::ComputationGraph::print_graphviz() const'
train_xor.cc:(.text+0x99a): undefined reference to `dynet::ComputationGraph::forward(dynet::Expression const&)'
train_xor.cc:(.text+0x9a2): undefined reference to `dynet::as_scalar(dynet::Tensor const&)'
train_xor.cc:(.text+0x9d8): undefined reference to `dynet::ComputationGraph::backward(dynet::Expression const&, bool)'
train_xor.cc:(.text+0x9e7): undefined reference to `dynet::Trainer::update()'
train_xor.cc:(.text+0xaa0): undefined reference to `dynet::TextFileSaver::TextFileSaver(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
train_xor.cc:(.text+0xb08): undefined reference to `dynet::TextFileSaver::save(dynet::ParameterCollection const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
train_xor.cc:(.text+0xb35): undefined reference to `dynet::TextFileSaver::~TextFileSaver()'
train_xor.cc:(.text+0xb53): undefined reference to `dynet::ComputationGraph::~ComputationGraph()'
train_xor.cc:(.text+0xbad): undefined reference to `dynet::ParameterCollection::~ParameterCollection()'
train_xor.cc:(.text+0xcd6): undefined reference to `dynet::TextFileLoader::~TextFileLoader()'
train_xor.cc:(.text+0xda8): undefined reference to `dynet::TextFileSaver::~TextFileSaver()'
train_xor.cc:(.text+0xdcb): undefined reference to `dynet::ComputationGraph::~ComputationGraph()'
train_xor.cc:(.text+0xe2a): undefined reference to `dynet::ParameterCollection::~ParameterCollection()'
/tmp/ccC0gRoZ.o: In function `dynet::Trainer::Trainer(dynet::ParameterCollection&, float)':
train_xor.cc:(.text._ZN5dynet7TrainerC2ERNS_19ParameterCollectionEf[_ZN5dynet7TrainerC5ERNS_19ParameterCollectionEf]+0x12): undefined reference to `vtable for dynet::Trainer'
/tmp/ccC0gRoZ.o: In function `dynet::SimpleSGDTrainer::SimpleSGDTrainer(dynet::ParameterCollection&, float)':
train_xor.cc:(.text._ZN5dynet16SimpleSGDTrainerC2ERNS_19ParameterCollectionEf[_ZN5dynet16SimpleSGDTrainerC5ERNS_19ParameterCollectionEf]+0x34): undefined reference to `vtable for dynet::SimpleSGDTrainer'
/tmp/ccC0gRoZ.o: In function `dynet::SimpleSGDTrainer::~SimpleSGDTrainer()':
train_xor.cc:(.text._ZN5dynet16SimpleSGDTrainerD2Ev[_ZN5dynet16SimpleSGDTrainerD5Ev]+0xd): undefined reference to `vtable for dynet::SimpleSGDTrainer'
train_xor.cc:(.text._ZN5dynet16SimpleSGDTrainerD2Ev[_ZN5dynet16SimpleSGDTrainerD5Ev]+0x20): undefined reference to `dynet::Trainer::~Trainer()'
collect2: error: ld returned 1 exit status
So could anyone be kind enough to helps me over this problem?
Thanks a lot and best Regards!