c++ - Undefined symbol in shared object file -
i compiled code using:
gcc -c -o3 -fpic -fno-rtti -fno-implicit-templates -wno-deprecated -i. -i/rw/include/ exotic.c -o rbcexotic.o when try use 'rbcexotic.o' file, error below.
loading error /home/rw/rw_lib/exotics.so: undefined symbol: _zn5arrayipkve4sizeeibbb when demangled code using nm, line giving me error this:
u array<void const*>::size(int, bool, bool, bool) however, 'size' function defined , implemented in header file within '/rw/include/' such:
template <class t> int array<t>::size(int n, bool reducemem, bool copydata, bool deldata) { return _size(n, reducemem, copydata, deldata); } and '_size' defined right below it.
am compiling code incorrectly? there other possible issues sort of red herring?
-fno-implicit-templates means "do not instantiate templates use, manually providing explicit instantiations."
so have lied compiler. told not bother instantiating array<t>::size function template in order provide required symbol, did asked, didn't keep end of bargain.
the best solution stop using option, , let compiler right thing automatically. when use array<void const*>::size(int, bool, bool, bool) instantiate generic definition in header file , provide missing symbol.
see gcc manual more information, although page out of date , bit saying -frepo best option should ignored. best option third one.
if really, want use option, need provide explicit instantiation every template use (which second option in gcc docs). in .c file (not header) define explicit instantiation of array<void const*> so:
template class array<void const*>; or single function:
template int array<void const*>::size(int, bool, bool, bool);
Comments
Post a Comment