I am compiling a C ++ program using the command line
g++ -c prog.cc -std=c++11 -march=native -fPIC -fopenmp
and then try to make a shared object using
g++ prog.o -shared -fopenmp -o lib/libprog.so
It always worked. But today I get:
/usr/bin/ld: prog.o: relocation R_X86_64_PC32 against undefined symbol
`_ZTVN12_GLOBAL__N_111handle_baseE' can not be used when making a shared
object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
The character _ZTVN12_GLOBAL__N_111handle_baseEcancels
vtable for (anonymous namespace)::handle_base
( handle_base- this is a polymorphic class defined in the anonymous namespace in prog.cc and yes, I call dynamic_cast<handle_base>().)
I am using gcc version 4.7.0 (GCC) and GNU ld (GNU Binutils; openSUSE 11.1). 2.19. Can someone help (suggest solutions [other than execution without a common object or dynamic cast])?
source
share