Relocation R_X86_64_32S against `.rodata' … While compiling on 64-bit platform

前端 未结 6 1643
轮回少年
轮回少年 2020-12-28 14:36

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

相关标签:
6条回答
  • 2020-12-28 14:52

    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

    0 讨论(0)
  • 2020-12-28 14:55

    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.

    0 讨论(0)
  • 2020-12-28 14:59

    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/
    
    0 讨论(0)
  • 2020-12-28 15:02

    The solution was to compile everything with -fPIC, and link shared objects with -shared.

    Add -fPIC to CFLAGS or CXXFLAGS for make-based projects.

    0 讨论(0)
  • 2020-12-28 15:04

    If this problem still exist after adding "-fPIC",try clean all the .o files,and run again

    0 讨论(0)
  • 2020-12-28 15:19

    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

    0 讨论(0)
提交回复
热议问题