Linked Questions
30 questions linked to/from GCC -fPIC option
151 votes
2 answers
159k views
What is the -fPIE option for position-independent executables in gcc and ld?
How will it change the code, e.g. function calls?
27 votes
2 answers
26k views
Disable and re-enable address space layout randomization only for myself
I would like to disable address space layout randomization (ASLR) on my system (Ubuntu Gnu/Linux 2.6.32-41-server), but, if I use sysctl -w kernel.randomize_va_space=0 the change would affect all ...
27 votes
2 answers
14k views
Why not always use fpic (Position Independent Code)? [duplicate]
I read this post on PIC and it seems that it always be good to use PIC (whenever it is exe / static / share llibrary). So what are the disadvantages? Are there examples elaborating when not to use ...
6 votes
2 answers
8k views
What does .rodata and -fPIC mean when compiling OpenSSL?
I am trying to compile openssl but encountering an error. The CFLAGS in use are: -O2 -fPIC -fno-strict-overflow Can someone explain to me please what is .rodata and what the following sentence means? ...
8 votes
3 answers
22k views
CDT using lib*.a --- relocation R_X86_64_32S against symbol ... can not be used
I try to reference a static *.a library for my c++ project in CDT. I included it in C/C++ Build -> Cross C++ Linker -> Libraries But I get the error: relocation R_X86_64_32S against symbol ... ...
0 votes
3 answers
7k views
What's -fPIC compile option?
Today, When trying to build my so lib project with mongodb c++ client, I got the error: /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../libmongoclient.a(connection_factory.o): relocation ...
8 votes
1 answer
18k views
What does the -fPIC compilation flag does?
What the -fpic flag does? I want to install a library (OpenSFM) and it is stated that it will need the Ceres Solver built and installed with the -fPIC compilation flag. The problem is I already ...
5 votes
2 answers
4k views
Lapack linking error, recompile with -fPIC
I have a sophisticated program for fitting nonlinear functions with the Levenberg-Marquardt's method. The program uses a solver for a system of linear Equations from the Lapack library, where I have ...
12 votes
1 answer
16k views
Clang -fPIC compiler option explained
Would someone please explain what the -fPIC option does. I can't seem to find references to it, yet I've seen it in use. I believe it has something to do with the memory allocation/space the ...
2 votes
1 answer
5k views
cmake, can't link static library into shared one
I'm writing adapter (shared library) to some fpga API. I've got libsomelib.a and its API - somelibAPI.h. Here is a minimal example of my adapter: somelib_adapter.h: #include <string> ...
2 votes
1 answer
5k views
gfortran compilation with -fPIC vs -frecursive
I recently followed the instruction on this thread for compiling BLAS and LAPACK as pre-requisites to a SciPy installation. First I got a gfortran error at some point, which recommended that I re-...
2 votes
2 answers
2k views
g++ -fPIC not producing position independent code
I've read the topic GCC -fPIC option So I've created my testlib.cpp. int foo(int num) { int result; if (num != 0) { result = 1; } else { result = 2; } ...
4 votes
0 answers
4k views
shared library without -fPIC
If I don't use -fPIC flag while compiling a shared library, will it really matter? Will it affect the way loader loads it into process's address space?
0 votes
1 answer
2k views
Build static Library with -fPIC or -fPIE
If I want to create a static library for everyone to use, is it necessary compile it with -fPIC or -fPIE? It is working for me without -fPIC or -fPIE.
2 votes
0 answers
4k views
CMake: Do I need to set POSITION_INDEPENDENT_CODE here and what exactly is its purpose?
I am currently reading "Modern CMake for C++" ([1]) and I am at page 193 where the concept of "position independent code" is explained. However it is only explained in one page and ...