Red Hat Bugzilla – Bug 493712
Relocation R_X86_64_PC32 error when compiling C++ code with -fvisibility-inlines-hidden
Last modified: 2013-03-21 15:14:20 EDT
Description of problem:
We have a class defined like this defined in a header file:
template <class state_t, class event_t>
and a class that inherits from it:
: public UFSM_Base_FSM<int,mobj_msg_id_t>
virtual ~MFSM_FSM(); /* Destructor */
with the empty destructor being defined non-inline.
When the MFSM_FSM class is compiled using -fvisibility-inlines-hidden and the code is built into a shared library, this error results:
/usr/bin/ld: mfsm_fsm.o: relocation R_X86_64_PC32 against `UFSM_Base_FSM<int, mobj_msg_id_t>::~UFSM_Base_FSM()' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
The -fPIC flag is being used when compiling all code.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Compile code like the above and link into shared library (not sure how reproducible the problem is without the entire code base)
This kind of error can result from incorrect command line options, undefined virtual methods, a linker bug with protected symbols, etc.
Without a full testcase we can not fully analyze this problem to determine if it is a problem in your code, the compiler, assembler or linker. A full testcase would consist of source code and the exact commands you use to show the problem.
It is also the case that gcc43 is no longer supported on the Red Hat Enterprise Linux platform. It was replaced by "gcc44" a while back.
I'm closing this as INSUFFICIENT_DATA; you may reopen it by providing the requested information so that we can fully analyze the issue.