fpic

Mixing static libraries and shared libraries

南楼画角 提交于 2020-01-20 05:02:25
问题 I have a project where I have one static library libhelper.a and another with my actual shared object library, libtestlib.so . My goal is to link libhelper.a into libtestlib.so . Is that possible on Linux/BSD? When I tried and created a test program I got the following errors: ./prog1:/usr/local/lib/libtestlib.so.1.0: undefined symbol '' My guess is that this is occurring because libhelper.a was not compiled with -fPIC while libtestlib.so was. What is the proper way to build programs that use

Apply either --enable-shared or -fPIC on in Code::Blocks

♀尐吖头ヾ 提交于 2020-01-14 04:40:08
问题 As the question states, I need to apply either of those compiler/linker settings. I am using Code::Blocks 10.05. I've looked through all the build settings screens. I cannot find where to apply these settings. I am getting the following on output: -------------- Build: Release in 39dll-4-Linux --------------- Linking dynamic library: ./39DLL.so /usr/bin/ld: obj/Release/buffer.o: relocation R_X86_64_32 against `CBuffer::retval' can not be used when making a shared object; recompile with -fPIC

linking a static(.a) library with a shared (.so) library, getting error “relocation R_X86_64_32S against a local symbol; recompile with -fPIC”

房东的猫 提交于 2020-01-06 08:13:08
问题 Compiling with g++ 64 bit in redhat using eclipse. Compile Error: ../lib-EL5-64bit/libskd3_clnt_30134500.a(skd_clnt.o): relocation R_X86_64_32S against `a local symbol' can not be used when making a shared object; recompile with -fPIC Things I have tried I added -fPIC to both the c++ compiler flags, as well as the linker flags. It already existed in the compiler flags, i just moved it to directly after the g++, and at the end of the list. I've asked the creator of the .a library to recompile

gcc vs clang: inlining a function with -fPIC

放肆的年华 提交于 2019-12-30 04:33:06
问题 Consider this code: // foo.cxx int last; int next() { return ++last; } int index(int scale) { return next() << scale; } When compiling with gcc 7.2: $ g++ -std=c++11 -O3 -fPIC This emits: next(): movq last@GOTPCREL(%rip), %rdx movl (%rdx), %eax addl $1, %eax movl %eax, (%rdx) ret index(int): pushq %rbx movl %edi, %ebx call next()@PLT ## next() not inlined, call through PLT movl %ebx, %ecx sall %cl, %eax popq %rbx ret However, when compiling the same code with the same flags using clang 3.9

Why am I getting this Android Studio error: “recompile with -fPIC”?

元气小坏坏 提交于 2019-12-24 08:23:09
问题 I am using NDK 18 and compiling a static library separately using the x86_64 NDK standalone toolchain. I can link it successfully but when I try to access the library in a non-trivial way I am getting dozens of errors when building saying things like: ... requires dynamic R_X86_64_PC32 reloc against '_ZZN4seal4util21get_msb_index_genericEPmmE15deBruijnTable64' which may overflow at runtime; recompile with -fPIC See my previous question for details on my build files: Why am I still getting

Why does including -fPIC to compile a static library cause a segmentation fault at run time?

匆匆过客 提交于 2019-12-22 18:35:07
问题 I'm compiling C++ static library with g++ and using the -fPIC option. I must use the -fPIC option because eventually this library will be linked with other static libraries to form a dynamic library. When I test the static library locally, it works completely fine when I don't include the -fPIC option. But as soon as I compile the library with -fPIC, I receive a segmentation fault error at run-time when calling one of the functions. What reasons could including -fPIC to compile a static

Why does including -fPIC to compile a static library cause a segmentation fault at run time?

半腔热情 提交于 2019-12-22 18:34:22
问题 I'm compiling C++ static library with g++ and using the -fPIC option. I must use the -fPIC option because eventually this library will be linked with other static libraries to form a dynamic library. When I test the static library locally, it works completely fine when I don't include the -fPIC option. But as soon as I compile the library with -fPIC, I receive a segmentation fault error at run-time when calling one of the functions. What reasons could including -fPIC to compile a static

Is there a way to determine that a .a or .so library has been compiled as position indepenent code?

早过忘川 提交于 2019-12-18 12:48:08
问题 I am getting a linking error when compiling the numpy library against lapack indicating I need to compile lapack with -fPIC. I thought I had done just that. Is there a way to determine that the produced lapack library is position independent? 回答1: In general, you have no way of knowing: $ cat a.c int foo(int x) { return x+1; } $ gcc -fno-pic a.c -c -o nopic.o $ gcc -fPIC a.c -c -o pic.o $ cmp pic.o nopic.o $ cmp pic.o nopic.o && echo Identical Identical 回答2: You may have some luck with this

Why is fPIC absolutely necessary on 64 and not on 32bit platforms?

可紊 提交于 2019-12-18 10:20:03
问题 I recently received a: ...relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC error while trying to compile a program as a shared library. Now the solution to this is not too difficult (recompile all dependencies with -fPIC), but after some research it turns out that this problem is only present on x86-64 platforms. On 32bit any position dependent code can still be relocated by the dynamic loader. The best answer I could find is:

Shared library linked with static library: relocation error

梦想的初衷 提交于 2019-12-13 17:08:35
问题 I would like to create a shared library with gfortran, linking it with the static version of libgfortran for portability reasons. Unfortunately, I don't manage to link the different objects appropriately. I have already found some posts addressing a similar issue, but I could not figure out how to fix the problem. My source files are all compiled with the -fPIC flag. When I try to link the objects with the flags -shared and -static-libgfortran , I get the following error message: gfortran