I
Iñaki Baz Castillo
Hi, I must include a header (udns.h) and library (libudns.a) in a Ruby
C extension (Linux 64 bits).
In extconf.rb I set:
have_library("udns")
"ruby extconf" creates the Makefile:
--------------------------------
checking for main() in -ludns... yes
creating Makefile
--------------------------------
but "make" command fails:
-------------------------------
gcc -I. -I/usr/include/ruby-1.9.1/x86_64-linux
-I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I.
-fPIC -fno-strict-aliasing -g -g -O2 -fPIC -o em_udns.o -c em_udns.c
gcc -shared -o em_udns.so em_udns.o -L. -L/usr/lib -L. -rdynamic
-Wl,-export-dynamic -lruby-1.9.1 -ludns -lpthread -lrt -ldl -lcrypt
-lm -lc
/usr/bin/ld: ./libudns.a(udns_resolver.o): relocation R_X86_64_32
against `dns_defctx' can not be used when making a shared object;
recompile with -fPIC
/libudns.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
-------------------------------
I know that "relocation R_X86_64_32" issue occurs with some libraries
in 64 bits and -fPIC is required. However AFAIK the above gcc command
does include -fPIC, am I right?
Anyhow, I can compile a pure C file (no Ruby) in a folder with these files:
- play1.c
- udns.h
- libudns.a
by running: gcc play1.c -L. -ludns libudns.a -o play1
And the resulting "play1" executable works ok.
libudns.a has been compiled with library provided "configure", and its
Makefile does contain -fPIC option:
-------------------------------------------------
PICFLAGS =3D -fPIC
[..]
c.lo:
$(CC) $(CFLAGS) $(PICFLAGS) $(CDEFS) -o $@ -c $<
-------------------------------------------------
I'm a bit lost here, any help please?
--=20
I=C3=B1aki Baz Castillo
<[email protected]>
C extension (Linux 64 bits).
In extconf.rb I set:
have_library("udns")
"ruby extconf" creates the Makefile:
--------------------------------
checking for main() in -ludns... yes
creating Makefile
--------------------------------
but "make" command fails:
-------------------------------
gcc -I. -I/usr/include/ruby-1.9.1/x86_64-linux
-I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I.
-fPIC -fno-strict-aliasing -g -g -O2 -fPIC -o em_udns.o -c em_udns.c
gcc -shared -o em_udns.so em_udns.o -L. -L/usr/lib -L. -rdynamic
-Wl,-export-dynamic -lruby-1.9.1 -ludns -lpthread -lrt -ldl -lcrypt
-lm -lc
/usr/bin/ld: ./libudns.a(udns_resolver.o): relocation R_X86_64_32
against `dns_defctx' can not be used when making a shared object;
recompile with -fPIC
/libudns.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
-------------------------------
I know that "relocation R_X86_64_32" issue occurs with some libraries
in 64 bits and -fPIC is required. However AFAIK the above gcc command
does include -fPIC, am I right?
Anyhow, I can compile a pure C file (no Ruby) in a folder with these files:
- play1.c
- udns.h
- libudns.a
by running: gcc play1.c -L. -ludns libudns.a -o play1
And the resulting "play1" executable works ok.
libudns.a has been compiled with library provided "configure", and its
Makefile does contain -fPIC option:
-------------------------------------------------
PICFLAGS =3D -fPIC
[..]
c.lo:
$(CC) $(CFLAGS) $(PICFLAGS) $(CDEFS) -o $@ -c $<
-------------------------------------------------
I'm a bit lost here, any help please?
--=20
I=C3=B1aki Baz Castillo
<[email protected]>