fpic

compile with -fPIC option but the option it is already in the makefile

Hello I get this error whem I am trying to do the make: relocation R_X86_64_32 against `vtable for Torch::MemoryDataSet' can not be used when making a shared object; recompile with -fPIC It says that I should recompile with the -fPIC option, I do that adding the -fPIC option to CFLAGS and CXXFLAGS but I still get the same error, any w...

What, if any, are the implications of compiling objects with gcc -fPIC flag if they get used in executables?

I am putting together a makefile for a project i am working on. I have an executable and a shared library in the project. Both use some of the same source files which get compiled separately into object files. To be able to use these objects in the shared library I need to use the -fPIC (position independent code) flag in gcc. Are there ...

Shared libraries and .h files

I have some doubt about how do programs use shared library. When I build a shared library ( with -shared -fPIC switches) I make some functions available from an external program. Usually I do a dlopen() to load the library and then dlsym() to link the said functions to some function pointers. This approach does not involve including any...

Linking a shared library against a static library: must the static library be compiled differently than if an application were linking it?

At least on Linux and Solaris, static libraries are really just a bunch of compiled .o's tossed into one big compressed file. When compiling a static library, usually the -fpic flag is ommited, so the generated code is position dependent. Now say my static library is B. I've built it and have the resulting .a file which is really just ...

non-dynamic relocations refer to dynamic symbol

I am getting this error: non-dynamic relocations refer to dynamic symbol stderr failed to set dynamic section sizes: Bad value I am using a mips toolchain with fPIC p[ation. Lots of .o files and libraries are involved. How do I find the cause of the error? ...

Generating %pc relative address of constant data

Is there a way to have gcc generate %pc relative addresses of constants? Even when the string appears in the text segment, arm-elf-gcc will generate a constant pointer to the data, load the address of the pointer via a %pc relative address and then dereference it. For a variety of reasons, I need to skip the middle step. As an example...

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

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? Thanks, S ...

What is the difference between `-fpic` and `-fPIC` gcc parameters?

I've already read the gcc manpage, but I still can't understand the difference between -fpic and -fPIC. Can someone explain it, in a very simple and clear way? (as a bonus, you might also compare them with -fpie and -fPIE) Sorry if this is duplicate, but it's hard to search for a question that contains both -fpic and -fPIC. Related ...