relocation R_X86_64_32S against linking Error
Assuming you are generating a shared library, most probably what happens is that the variant of liblog4cplus.a
you are using wasn't compiled with -fPIC
. In linux, you can confirm this by extracting the object files from the static library and checking their relocations:
ar -x liblog4cplus.a
readelf --relocs fileappender.o | egrep '(GOT|PLT|JU?MP_SLOT)'
If the output is empty, then the static library is not position-independent and cannot be used to generate a shared object.
Since the static library contains object code which was already compiled, providing the -fPIC flag won't help.
You need to get ahold of a version of liblog4cplus.a
compiled with -fPIC
and use that one instead.
Compilation fails with relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object
Do what the compiler tells you to do, i.e. recompile with -fPIC
. To learn what does this flag do and why you need it in this case, see Code Generation Options of the GCC manual.
In brief, the term position independent code (PIC) refers to the generated machine code which is memory address agnostic, i.e. does not make any assumptions about where it was loaded into RAM. Only position independent code is supposed to be included into shared objects (SO) as they should have an ability to dynamically change their location in RAM.
Finally, you can read about it on Wikipedia too.
Related Topics
Bash: How to Pass in Arguments to an Alias: Cannot Use a Function - Syntax of Bash Conditionals
Run Multiple Commands At Once in the Same Terminal
How to Substitute Shell Variables in Complex Text Files
Perf-Report Show Value of CPU Register
Why Non-Pic Code Can't Be Totally Aslr Using Run-Time Fixups
Use Sed to Delete Certain Lines Using an Index with the Line Numbers to Delete
Access Denied to Android.Git.Kernel.Org
How to Make the Watch Command Interpret Vt100 Sequences
Sshpass: Command Not Found Error
Transport Endpoint Not Connected - Mesos Slave/Master
Possibly Undefined MACro: Ac_Prog_Libtool
Padding Empty Field in Unix Join Operation
Set Multiline Environment Variable with Dockerfile
What Does the "Mov Rax, Qword Ptr Fs:0X28" Assembly Instruction Do
How to Check If a File Contains Only Zeros in a Linux Shell
Getting File Create Notifications for Cifs Mount in Linux
Bluez Blotoothctl Scan VS Hcitool Scan
Send a Binary File (Line by Line) to a Socket Server with Netcat