Re: [Vala] Static linking



On Wed, Dec 02, 2009 at 04:52:13 -0700, Mark Dewey wrote:
How do I statically link libraries for Vala programs? I mean, like
libgee and such. Don't worry, I do plan to have a license compatible
with such behavior.

Well, just as you would any other C library. You would probably need to
change the build process, which should be realitively simple for most build
tools.

Note, though, that static linking is strongly discouraged on unices these
days, mostly so that when a bug is fixed in the library, you can just upgrade
that and all programs using the library get the fix. For example Debian does
not allow statically linking against separately distributed libraries unless
there is a very good reason dynamic linking is not possible. And note, that
even init is dynamically linked.

I'm used to scripting languages like Python and Lua where static linking
isn't really possible, so I've never dealt with it, or any kind of
non-automatic linking, really.

From the point of user of the library, there is no difference between static
and dynamic linking. The linker will use whichever variant it finds, though
you can tell it to only look for one or the other.

The compilation is significantly different between static and shared library.
Most build tools know how to compile both though, so you just tell them which
you want and they'll take care of it.

While valac is able to call compiler and linker, it can't create static
libraries (which are build with ar rather than linker), but than I don't
think it can make correct shared libraries either (it can, but you have to
give it some magic options to pass through to the linker).

-- 
                                                 Jan 'Bulb' Hudec <bulb ucw cz>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]