-1

I have tried to program a header-only library for an existing project. The compiler has no error (anymore), but the linker (clang) failed...

I am using CMake and my library is added with the following lines:

set(RODE_DIR rode) include_directories (${RODE_DIR}) 

The error is the following:

Undefined symbols for architecture x86_64: "sfm::StreamlineWrf::ComputeStreamline(sfm::NdArray<float>*, sfm::NdArray<float>*, sfm::NdArray<float>*, sfm::NdArray<float>*, int&, int&, int&, double const*, int, double, std::__1::vector<double, std::__1::allocator<double> >*)", referenced from: _main in wrf2sl.cc.o "sfm::ijktos(sfm::NdArray<float>*, sfm::NdArray<float>*, sfm::NdArray<float>*, int const*, double const*, double*, double*, double*)", referenced from: _main in wrf2sl.cc.o "typeinfo for MethodModel", referenced from: typeinfo for HeunEuler1 in wrf2sl.cc.o typeinfo for HeunEuler2 in wrf2sl.cc.o typeinfo for DormandPrince in wrf2sl.cc.o typeinfo for BogackiShampine in wrf2sl.cc.o typeinfo for RK41 in wrf2sl.cc.o "vtable for MethodModel", referenced from: MethodModel::MethodModel() in wrf2sl.cc.o MethodModel::~MethodModel() in wrf2sl.cc.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for rODE", referenced from: rODE::rODE(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float) in wrf2sl.cc.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for Method", referenced from: Method::Method(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float) in wrf2sl.cc.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for Solver", referenced from: Solver::Solver(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float) in wrf2sl.cc.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for sfm::StreamlineWrf", referenced from: sfm::StreamlineWrf::StreamlineWrf(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float) in wrf2sl.cc.o NOTE: a missing vtable usually means the first non-inline virtual member function has no definition. ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [expt/wrf2sl] Error 1 make[1]: *** [expt/CMakeFiles/wrf2sl.dir/all] Error 2 make: *** [all] Error 2 

Do you know what is going on?

5
  • I never heard of a library called rode, but it does not seem to be header only. Commented Jan 14, 2016 at 21:06
  • A header-only library by definition defines all its symbols in its header. Commented Jan 14, 2016 at 21:15
  • This is the one I have done. So maybe I have made a mistake but basically I have just used headers for it. A bit like many libraries from Boost Commented Jan 14, 2016 at 21:16
  • 1
    How to create a Minimal, Complete, and Verifiable example Commented Jan 14, 2016 at 21:16
  • every symbols from rODE are inside headers Commented Jan 14, 2016 at 21:17

1 Answer 1

1

The explanation is probably in the error:

"a missing vtable usually means the first non-inline virtual member function has no definition. "vtable for rODE", referenced from:"

Go through your classes , Method, MethodModel, Solver, etc, and check each of their virtual member functions, and make sure each has a definition which is in a .c / .cxx / .c++ module that is being linked. Probably you'll find one that either doesn't have a definition, or is defined in a file that isn't being linked by CMake.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes it was almost there. Actually the answer is there: stackoverflow.com/questions/11437242/…, Thanks for your advice

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.