So I\'ve been coding something on 32-bit and yesterday I needed to build a dll and I had a couple of problems with that. Anyway I solved them here.
Unfortunately eve
this work as a charm. for who not know yet this easy used
an open file called Makefile.am or Makefile. Just up to your config.
look the code at this _a_CXXFLAGS = or just CXXFLAGS =
add after that files -shared -fPIC
this example
before
crypto_libmubdi_crypto_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIC_FLAGS) $(CXXFLAGS_COMMON) $(CFLAGS_PERSONAL) $(CADD)
after
crypto_libmubdi_crypto_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIC_FLAGS) $(CXXFLAGS_COMMON) $(CFLAGS_PERSONAL) $(CADD) -shared -fPIC
these bugs cause we not put shared for the files or need -fPIC strings/tags.
Note: I experience on to build my blockchain. and this cause added this crypto/sph_sha2big.c
I encountered the same problem when I try to create a shared library which need to link a static library.
I solved the problem by adding -fPIC to CXXFLAGS to compile .o files which are archived in the static library.
I also meet this problem. As I try using @Mare and @user2391685 said, it can work well :
Using -fPIC
when comepile to .o
file :
For example:
gcc -Wall -fPIC -c hello.c -I./ -I/usr/lib/jvm/java/include/ -I/usr/lib/jvm/java/include/linux/
Then you can build a .so
file :
gcc -Wall -rdynamic -shared -o libhello.so hello.o Main.h -I/usr/lib/jvm/java/include/ -I/usr/lib/jvm/java/include/linux/
The solution was to compile everything with -fPIC
, and link shared objects with -shared
.
Add -fPIC
to CFLAGS
or CXXFLAGS
for make-based projects.
If this problem still exist after adding "-fPIC",try clean all the .o files,and run again
Trying to compile xmlrpc-c-1.06.41 in CentOS 6.5, I have encountered same linking problem, which was solved by the following: In ./src/cpp, I have modified Makefile: line 142 to
CXXFLAGS = $(CXXFLAGS_COMMON) $(CFLAGS_PERSONAL) $(CADD) -shared -fPIC
More info regarding the flags can be found link