Discussion:
build a static tiff2pdf
Joel Costigliola
2014-10-07 04:50:37 UTC
Permalink
Hey,

I'm trying to build a static binaries, to embedd tiff2pdf in my java application.

I'm running Ubuntu 14.04, I have been able to build a tiff2pdf binary using shared libraries but I failed to build a static one.

I'm not really familiar with makefile so I probably haven't used the right configuration, here's what I did :

- ./configure --prefix=/home/joelco/prog/tiff2pdf/ --enable-shared=no
- make

A tiff2pdf executable is built, its size is 1.6M but running ldd on it shows that it's not a static binary.

~/prog/tiff2pdf/tiff-4.0.3/tools ? ldd ./tiff2pdf
linux-vdso.so.1 => (0x00007fff7e7fe000)
libjpeg.so.7 => /usr/local/lib/libjpeg.so.7 (0x00007f822aa34000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f822a72e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f822a367000)
/lib64/ld-linux-x86-64.so.2 (0x00007f822ac8c000)

Having read this post, it might not be possible http://www.asmail.be/msg0055326082.html

Is there a way to build a static version of tiff2pdf ? If yes how ?

Thanks for your help,


Joel
Bob Friesenhahn
2014-10-07 14:38:11 UTC
Permalink
On Tue, 7 Oct 2014, Joel Costigliola wrote:

>
> Hey,
>
> I'm trying to build a static binaries, to embedd tiff2pdf in my java application.
>
> I'm running Ubuntu 14.04, I have been able to build a tiff2pdf binary using shared libraries but I failed to build a
> static one.

You don't really want to build a static libtiff. Modern systems
depend on shared libraries so that binaries can run on multiple
systems. The only library which looks like a problem in your linkage
is libjpeg.so.7.

Perhaps using

./configure LIBS='/usr/lib/x86_64-linux-gnu/libjpeg.a'

(adapted for your system) might help with the JPEG linkage problem.

Otherwise you will need to learn about exotic linker options.

Bob
--
Bob Friesenhahn
***@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: ***@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Joel Costigliola
2014-10-07 20:37:28 UTC
Permalink
Hi Bob

Using your suggestion did not solve the problem unfortunately but your help is appreciated.

I know building static binaries is not standard but in my case it makes sense, I'm writing software for clinicians that need to see lab results in TIFF format.
As we don't have a TIFF viewer in our application we convert tiff to pdf, we want static binaries to ease our software installation by not having to install the required shared libraries in each target systems.

I need now to find the correct option to build a static tiff2pdf binary, I already tried ' LDFLAGS=-static' without success.

Cheers

Joel


________________________________________
From: Bob Friesenhahn <***@simple.dallas.tx.us>
Sent: Wednesday, 8 October 2014 03:38 a.m.
To: Joel Costigliola
Cc: ***@lists.maptools.org
Subject: Re: [Tiff] build a static tiff2pdf

On Tue, 7 Oct 2014, Joel Costigliola wrote:

>
> Hey,
>
> I'm trying to build a static binaries, to embedd tiff2pdf in my java application.
>
> I'm running Ubuntu 14.04, I have been able to build a tiff2pdf binary using shared libraries but I failed to build a
> static one.

You don't really want to build a static libtiff. Modern systems
depend on shared libraries so that binaries can run on multiple
systems. The only library which looks like a problem in your linkage
is libjpeg.so.7.

Perhaps using

./configure LIBS='/usr/lib/x86_64-linux-gnu/libjpeg.a'

(adapted for your system) might help with the JPEG linkage problem.

Otherwise you will need to learn about exotic linker options.

Bob
--
Bob Friesenhahn
***@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: ***@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Joel Costigliola
2014-10-07 22:30:59 UTC
Permalink
I finally managed to build a static version of tiff2pdf.

I ran first:
./configure --prefix=/home/joelco/prog/tiff2pdf/ --enable-shared=no LIBS='/usr/local/lib/libjpeg.a' --enable-static

But it was not enough to have a static version, the static option was not present in the final libtool command :

/bin/bash ../libtool --tag=CC --mode=link gcc -static -g -O2 -Wall -W -static -o tiff2pdf tiff2pdf.o ../libtiff/libtiff.la ../port/libport.la -ljpeg -lm /usr/local/lib/libjpeg.a
libtool: link: gcc -g -O2 -Wall -W -o tiff2pdf tiff2pdf.o ../libtiff/.libs/libtiff.a ../port/.libs/libport.a -ljpeg -lm /usr/local/lib/libjpeg.a

So I just ran the link command manually adding the static option:
gcc -g -O2 -Wall -W -static -o tiff2pdf tiff2pdf.o ../libtiff/.libs/libtiff.a ../port/.libs/libport.a -ljpeg -lm /usr/local/lib/libjpeg.a

It's not the cleanest way of building a static binary but at least it worked.

Cheers,

Joel

________________________________________
From: Bob Friesenhahn <***@simple.dallas.tx.us>
Sent: Wednesday, 8 October 2014 03:38 a.m.
To: Joel Costigliola
Cc: ***@lists.maptools.org
Subject: Re: [Tiff] build a static tiff2pdf

On Tue, 7 Oct 2014, Joel Costigliola wrote:

>
> Hey,
>
> I'm trying to build a static binaries, to embedd tiff2pdf in my java application.
>
> I'm running Ubuntu 14.04, I have been able to build a tiff2pdf binary using shared libraries but I failed to build a
> static one.

You don't really want to build a static libtiff. Modern systems
depend on shared libraries so that binaries can run on multiple
systems. The only library which looks like a problem in your linkage
is libjpeg.so.7.

Perhaps using

./configure LIBS='/usr/lib/x86_64-linux-gnu/libjpeg.a'

(adapted for your system) might help with the JPEG linkage problem.

Otherwise you will need to learn about exotic linker options.

Bob
--
Bob Friesenhahn
***@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: ***@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Bob Friesenhahn
2014-10-07 22:40:23 UTC
Permalink
On Tue, 7 Oct 2014, Joel Costigliola wrote:
>
> So I just ran the link command manually adding the static option:
> gcc -g -O2 -Wall -W -static -o tiff2pdf tiff2pdf.o ../libtiff/.libs/libtiff.a ../port/.libs/libport.a -ljpeg -lm /usr/local/lib/libjpeg.a
>
> It's not the cleanest way of building a static binary but at least it worked.

Be aware that pure static executables are not necessarily portable to
other systems. The C shared library interface is much more dependable
than the raw system call interface used between the C library and the
kernel.

Statically linking libjpeg should not be a problem. Statically
linking libc is not a wise idea.

Bob
--
Bob Friesenhahn
***@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: ***@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Joel Costigliola
2014-10-07 23:35:58 UTC
Permalink
We are building different versions of tiff2pdf for different environments indeed.
Thx Bob
________________________________________
From: Bob Friesenhahn <***@simple.dallas.tx.us>
Sent: Wednesday, 8 October 2014 11:40 a.m.
To: Joel Costigliola
Cc: ***@lists.maptools.org
Subject: Re: [Tiff] build a static tiff2pdf

On Tue, 7 Oct 2014, Joel Costigliola wrote:
>
> So I just ran the link command manually adding the static option:
> gcc -g -O2 -Wall -W -static -o tiff2pdf tiff2pdf.o ../libtiff/.libs/libtiff.a ../port/.libs/libport.a -ljpeg -lm /usr/local/lib/libjpeg.a
>
> It's not the cleanest way of building a static binary but at least it worked.

Be aware that pure static executables are not necessarily portable to
other systems. The C shared library interface is much more dependable
than the raw system call interface used between the C library and the
kernel.

Statically linking libjpeg should not be a problem. Statically
linking libc is not a wise idea.

Bob
--
Bob Friesenhahn
***@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
_______________________________________________
Tiff mailing list: ***@lists.maptools.org
http://lists.maptools.org/mailman/listinfo/tiff
http://www.remotesensing.org/libtiff/
Loading...