Package: libjson-c2
Source: libjson-c2
Version: 0.11-4ubuntu2

I'm working on a cross platform project that is using libjson-c2 and I wanted 
to try to statically
link the library to see if I could avoid shipping multiple deb packages for, 
for example, 16.04 and
17.04, where the libraries are different (libjson-c2 vs libjson-c3).  What I 
found was that I couldn't
link with the static library libjson-c.a.  When I tried I got the following 
error:

cc   -pie -fPIE -z relro -z now -o myapp myapp.o -static -ljson-c
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/5/crtbeginT.o: relocation 
R_X86_64_32 against `__TMC_END__' can not be used when making a shared object; 
recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/5/crtbeginT.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Makefile:89: recipe for target 'myapp' failed

I downloaded the package sources and found that the .c files are being compiled 
twice, once without
-fPIC, with the resultant .o files in the top level directory, and once with 
-fPIC, with the resultant
.o files deposited in the .libs directory, which is where the .a is created. 
However, the .a is NOT
created with the .libs/*.o files, but the top level .o files, which are NOT 
created with -fPIC.
See the following lines from the build log:

libtool: link: (cd ".libs" && rm -f "libjson-c.so.2" && ln -s 
"libjson-c.so.2.0.0" "libjson-c.so.2")
libtool: link: (cd ".libs" && rm -f "libjson-c.so" && ln -s 
"libjson-c.so.2.0.0" "libjson-c.so")
libtool: link: ar cru .libs/libjson-c.a  arraylist.o debug.o json_c_version.o 
json_object.o json_object_iterator.o json_tokener.o json_util.o linkhash.o 
printbuf.o random_seed.o
libtool: link: ranlib .libs/libjson-c.a

Note that the library is .libs/libjson-c.a but the .o files don't have the 
.libs prefix.  If I cd into
the .libs directory and execute these commands:

ar cru libjson-c.a  arraylist.o debug.o json_c_version.o json_object.o 
json_object_iterator.o json_tokener.o json_util.o linkhash.o printbuf.o 
random_seed.o
ranlib libjson-c.a

and then link with the resultant library everything works.  I haven't been able 
to figure out exactly
what the fix for this problem is.

The following is the information for both the installed package and the source 
package that I've been
working with.

$ dpkg --status libjson-c2
Package: libjson-c2
Status: install ok installed
Priority: extra
Section: libs
Installed-Size: 67
Maintainer: Ubuntu Developers 
<ubuntu-devel-disc...@lists.ubuntu.com<mailto:ubuntu-devel-disc...@lists.ubuntu.com>>
Architecture: amd64
Multi-Arch: same
Source: json-c
Version: 0.11-4ubuntu2
Depends: libc6 (>= 2.14)
Description: JSON manipulation library - shared library
 This library allows you to easily construct JSON objects in C,
 output them as JSON formatted strings and parse JSON formatted
 strings back into the C representation of JSON objects.
Homepage: https://github.com/json-c/json-c/wiki
Original-Maintainer: fabien boucher 
<fabien.dot.bouc...@gmail.com<mailto:fabien.dot.bouc...@gmail.com>>



Source package info:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 3.0 (quilt)
Source: json-c
Binary: libjson-c2, libjson-c-dev, libjson-c2-dbg, libjson-c-doc, libjson0-dev, 
libjson0
Architecture: any all
Version: 0.11-4ubuntu2
Maintainer: Ubuntu Developers 
<ubuntu-devel-disc...@lists.ubuntu.com<mailto:ubuntu-devel-disc...@lists.ubuntu.com>>
Uploaders: Ond�~Yej Surý <ond...@debian.org<mailto:ond...@debian.org>>
Homepage: https://github.com/json-c/json-c/wiki
Standards-Version: 3.9.3.0
Vcs-Browser: http://anonscm.debian.org/?p=collab-maint/json-c.git;a=summary
Vcs-Git: git://anonscm.debian.org/git/collab-maint/json-c
Build-Depends: debhelper (>= 9), dh-exec, dh-autoreconf
Package-List:
 libjson-c-dev deb libdevel extra arch=any
 libjson-c-doc deb doc extra arch=all
 libjson-c2 deb libs extra arch=any
 libjson-c2-dbg deb debug extra arch=any
 libjson0 deb oldlibs extra arch=any
 libjson0-dev deb oldlibs extra arch=any
Checksums-Sha1:
 5d0377d2cc4a1af324d5aeb5b63032d1d026aacd 557263 json-c_0.11.orig.tar.gz
 c93b8000bc69549bf708de0073f0fcae0648c7af 273884 
json-c_0.11-4ubuntu2.debian.tar.xz
Checksums-Sha256:
 28dfc65145dc0d4df1dfe7701ac173c4e5f9347176c8983edbfac9149494448c 557263 
json-c_0.11.orig.tar.gz
 96cce11fbf46e57c5b2674922344738c6f2ea1fa0af6e91b3576eb9f1dbd51d0 273884 
json-c_0.11-4ubuntu2.debian.tar.xz
Files:
 aa02367d2f7a830bf1e3376f77881e98 557263 json-c_0.11.orig.tar.gz
 f88770f98c00242150f189695af295a4 273884 json-c_0.11-4ubuntu2.debian.tar.xz
Original-Maintainer: fabien boucher 
<fabien.dot.bouc...@gmail.com<mailto:fabien.dot.bouc...@gmail.com>>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEARECAAYFAlSz8/4ACgkQDTAwc5ER+zVkygCfdx9sPn9kvEB5p2Iagg4JSAx4
dRgAoICbAWoQ6td7VAn7oN/OAVqyt9xR
=OtuB
-----END PGP SIGNATURE-----

uname -a
Linux desktop 4.4.0-28-generic #47-Ubuntu SMP Fri Jun 24 10:09:13 UTC 2016 
x86_64 x86_64 x86_64 GNU/Linux

Reply via email to