Re: [fltk.general] Making a statically linked executable.

30 views
Skip to first unread message

Edzard Egberts

unread,
Feb 26, 2015, 6:24:23 AM2/26/15
to Ed
> If I compile my app (mads.cxx) with fltk-config it works fine and
> generates this as the full-length command which I can save into a script...
>
> g++ -I/usr/local/include -I/usr/local/include/FL/images
> -I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
> -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT -o 'mads' 'mads.cxx'
> /usr/local/lib/libfltk.a -lXcursor -lXfixes -lXext -lXft -lfontconfig
> -lXinerama -lpthread -ldl -lm -lX11
>
> ..but I am struggling to get this to accept a '-static' option so as to
> make a nice big transportable executable.

This is not so easy, because you need static libraries of all you want
to link. But normally things like "libX11" only exist as dynamic
library, so you won't be able to link it statical. When there are static
libraries you want to link prior to the dynamic version, you can copy
them to a directory beyond your program build e.g. "./statlib". After
that an option "-L./statlib" will link these libraries statical. This is
very useful, when there are special libraries in use (like "libexif"),
that are normally not installed to all systems.

Other options are "-static-libgcc" and "-static-libstdc++", but the
second worked only under MS-Windows for me.

Anyway I got the hint, that Debian Squeeze only provides static
libraries, so your command line above should link all static on this
system. But I didn't try that yet.
Reply all
Reply to author
Forward
0 new messages