* [gentoo-user] Building static libraries @ 2009-12-13 19:18 Renat Golubchyk 2009-12-13 20:40 ` Albert Hopkins 2009-12-13 22:47 ` [gentoo-user] " walt 0 siblings, 2 replies; 12+ messages in thread From: Renat Golubchyk @ 2009-12-13 19:18 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 640 bytes --] Hi everyone! I need to build a static binary of a program I wrote. The problem is that most packages only install dynamic version of the libraries. There are the "static" and "static-libs" USE flags, but only a tiny fraction of packages support them. Modifying every relevant ebuild is not really a viable solution since the list of packages is quite long and could change later. So what can I do if I'd like to avoid compiling every package manually? Cheers, Renat -- Probleme kann man niemals mit derselben Denkweise loesen, durch die sie entstanden sind. (Einstein) [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Building static libraries 2009-12-13 19:18 [gentoo-user] Building static libraries Renat Golubchyk @ 2009-12-13 20:40 ` Albert Hopkins 2009-12-14 0:27 ` Renat Golubchyk 2009-12-13 22:47 ` [gentoo-user] " walt 1 sibling, 1 reply; 12+ messages in thread From: Albert Hopkins @ 2009-12-13 20:40 UTC (permalink / raw To: gentoo-user On Sun, 2009-12-13 at 20:18 +0100, Renat Golubchyk wrote: > Hi everyone! > > I need to build a static binary of a program I wrote. The problem is > that most packages only install dynamic version of the libraries. > There > are the "static" and "static-libs" USE flags, but only a tiny fraction > of packages support them. Modifying every relevant ebuild is not > really > a viable solution since the list of packages is quite long and could > change later. > > So what can I do if I'd like to avoid compiling every package > manually? There is no easy answer to your question. I think because, with a lot of programs it "just depends". Some packages already include static libraries (e.g. python and it doesn't make sense to compile the python package statically because it will break a great many things). Some programs just weren't designed to be static (e.g. imagemagick or apache). GTK+, i believe, can't be built statically as it uses dynload for themes, input methods, etc etc. Even most proprietary gtk-based software that I know of (e.g. Adobe Flash and VMWare) either are distributed with GTK+ linked dynamically or they provide their own GTK libs). You can apply "-static" to CFLAGS, but make sure you have a binpkg built first, as there is a chance you may break something. You can also try passing "--enable-static" to EXTRA_ECONF. That's probably safer than the former, but the same caveat applies. Most of the things where static is "useful" and safe already have a static flag though or provide static libs by default. I think the only exception I've encountered was e2fsprogs. For that I usually compile my own static executables. HTH, -a ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Building static libraries 2009-12-13 20:40 ` Albert Hopkins @ 2009-12-14 0:27 ` Renat Golubchyk 0 siblings, 0 replies; 12+ messages in thread From: Renat Golubchyk @ 2009-12-14 0:27 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 1262 bytes --] On Sun, 13 Dec 2009 15:40:34 -0500 Albert Hopkins <marduk@letterboxes.org> wrote: > GTK+, i believe, can't be built statically as it uses dynload for > themes, input methods, etc etc. Even most proprietary gtk-based > software that I know of (e.g. Adobe Flash and VMWare) either are > distributed with GTK+ linked dynamically or they provide their own > GTK libs). Hmm, I'll test that because I use GTK+ although it is not a GUI app. > You can apply "-static" to CFLAGS, but make sure you have a binpkg > built first, as there is a chance you may break something. You can > also try passing "--enable-static" to EXTRA_ECONF. That's probably > safer than the former, but the same caveat applies. Ah, in all the years using Gentoo I have never needed EXTRA_ECONF, although I've heard a lot about it on this list. It is, of course, listed in make.conf man page, but since everything works here I usually do not need to look at it. Anyway, thanks for the pointer. I'm testing it right now, and it seems to work so far. I'll report back when emerge is finished. Cheers, Renat -- Probleme kann man niemals mit derselben Denkweise loesen, durch die sie entstanden sind. (Einstein) [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* [gentoo-user] Re: Building static libraries 2009-12-13 19:18 [gentoo-user] Building static libraries Renat Golubchyk 2009-12-13 20:40 ` Albert Hopkins @ 2009-12-13 22:47 ` walt 2009-12-14 0:27 ` Renat Golubchyk 1 sibling, 1 reply; 12+ messages in thread From: walt @ 2009-12-13 22:47 UTC (permalink / raw To: gentoo-user On 12/13/2009 11:18 AM, Renat Golubchyk wrote: > Hi everyone! > > I need to build a static binary of a program I wrote. The problem is > that most packages only install dynamic version of the libraries. There > are the "static" and "static-libs" USE flags... I'm confused (not unusual). Do you want to create a Gentoo package of your program that can be added to portage? USE flags are used only by the Gentoo portage system, not by the compiler or linker that compiles and links your source code. If you wrote the program, then you have complete control over the linker flags (e.g. -static, as Albert mentioned) and those flags usually are defined in a Makefile (which you create, being the programmer). I can't be sure, but I think you are confusing Gentoo's USE flags with gcc's (or ld's) flags, which are entirely different. Please give more details about what you want to do. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Re: Building static libraries 2009-12-13 22:47 ` [gentoo-user] " walt @ 2009-12-14 0:27 ` Renat Golubchyk 2009-12-14 1:53 ` Albert Hopkins 2009-12-14 18:28 ` walt 0 siblings, 2 replies; 12+ messages in thread From: Renat Golubchyk @ 2009-12-14 0:27 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 1485 bytes --] On Sun, 13 Dec 2009 14:47:04 -0800 walt <w41ter@gmail.com> wrote: > On 12/13/2009 11:18 AM, Renat Golubchyk wrote: > > I need to build a static binary of a program I wrote. The problem is > > that most packages only install dynamic version of the libraries. > > There are the "static" and "static-libs" USE flags... > > I'm confused (not unusual). Do you want to create a Gentoo package of > your program that can be added to portage? > > USE flags are used only by the Gentoo portage system, not by the > compiler or linker that compiles and links your source code. > > If you wrote the program, then you have complete control over the > linker flags (e.g. -static, as Albert mentioned) and those flags > usually are defined in a Makefile (which you create, being the > programmer). As you said, you really are confused. :-) Maybe I wasn't clear enough. Anyway, I've written a program, and I need it as a statically linked binary. In order to link statically the linker (ld) needs all the used libraries in static form, i.e. as a .a and not as a .so file. Since portage does not build static libraries by default I need a way to tell portage that I really do want to have .a files built. I do _not_ want to create a Gentoo package, at least not at this stage of development. Cheers, Renat -- Probleme kann man niemals mit derselben Denkweise loesen, durch die sie entstanden sind. (Einstein) [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Re: Building static libraries 2009-12-14 0:27 ` Renat Golubchyk @ 2009-12-14 1:53 ` Albert Hopkins 2009-12-14 2:19 ` Renat Golubchyk 2009-12-14 18:28 ` walt 1 sibling, 1 reply; 12+ messages in thread From: Albert Hopkins @ 2009-12-14 1:53 UTC (permalink / raw To: gentoo-user On Mon, 2009-12-14 at 01:27 +0100, Renat Golubchyk wrote: > Since portage does not build static libraries by default... But portage *does*. I think it does build static libs for packages that provide them, it's just that I don't think many do (for the reasons I mentioned in the previous post). In fact: $ equery l \*| while read l; do equery f $l|grep '\.a$' | \ sed 's/^/'"${l/"/"/\\/} "'-> /' ; done |wc -l Shows I have 756 static libs on my system (cut off the "|wc -l" to see what they are). ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Re: Building static libraries 2009-12-14 1:53 ` Albert Hopkins @ 2009-12-14 2:19 ` Renat Golubchyk 0 siblings, 0 replies; 12+ messages in thread From: Renat Golubchyk @ 2009-12-14 2:19 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 591 bytes --] On Sun, 13 Dec 2009 20:53:15 -0500 Albert Hopkins <marduk@letterboxes.org> wrote: > On Mon, 2009-12-14 at 01:27 +0100, Renat Golubchyk wrote: > > Since portage does not build static libraries by default... > > But portage *does*. I think it does build static libs for packages > that provide them, it's just that I don't think many do (for the > reasons I mentioned in the previous post). That's what I actually meant. -- Probleme kann man niemals mit derselben Denkweise loesen, durch die sie entstanden sind. (Einstein) [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* [gentoo-user] Re: Building static libraries 2009-12-14 0:27 ` Renat Golubchyk 2009-12-14 1:53 ` Albert Hopkins @ 2009-12-14 18:28 ` walt 2009-12-14 20:19 ` Allan Gottlieb ` (2 more replies) 1 sibling, 3 replies; 12+ messages in thread From: walt @ 2009-12-14 18:28 UTC (permalink / raw To: gentoo-user Renat Golubchyk wrote: > As you said, you really are confused. :-) Maybe I wasn't clear enough. > Anyway, I've written a program, and I need it as a statically linked > binary. In order to link statically the linker (ld) needs all the used > libraries in static form, i.e. as a .a and not as a .so file. Since > portage does not build static libraries by default I need a way to tell > portage that I really do want to have .a files built. > > I do _not_ want to create a Gentoo package, at least not at this stage > of development. Still confused :o( Portage is for building Gentoo packages -- if you don't want to build a Gentoo package then why is portage involved? You can compile and link your program with any flags you want to, so as to get static binaries. ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Re: Building static libraries 2009-12-14 18:28 ` walt @ 2009-12-14 20:19 ` Allan Gottlieb 2009-12-14 20:25 ` Alan McKinnon 2009-12-14 21:16 ` Renat Golubchyk 2 siblings, 0 replies; 12+ messages in thread From: Allan Gottlieb @ 2009-12-14 20:19 UTC (permalink / raw To: gentoo-user At Mon, 14 Dec 2009 10:28:21 -0800 walt <w41ter@gmail.com> wrote: > Renat Golubchyk wrote: > >> As you said, you really are confused. :-) Maybe I wasn't clear enough. >> Anyway, I've written a program, and I need it as a statically linked >> binary. In order to link statically the linker (ld) needs all the used >> libraries in static form, i.e. as a .a and not as a .so file. Since >> portage does not build static libraries by default I need a way to tell >> portage that I really do want to have .a files built. >> >> I do _not_ want to create a Gentoo package, at least not at this stage >> of development. > > Still confused :o( > > Portage is for building Gentoo packages -- if you don't want to build a > Gentoo package then why is portage involved? You can compile and link > your program with any flags you want to, so as to get static binaries. Portage is also for (indeed, is primarily used for) fetching and installing Gentoo packages. The OP wants portage to install the statically linked version of libraries for which it currently installs only the dynamically linked versions. allan ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Re: Building static libraries 2009-12-14 18:28 ` walt 2009-12-14 20:19 ` Allan Gottlieb @ 2009-12-14 20:25 ` Alan McKinnon 2009-12-15 6:53 ` Renat Golubchyk 2009-12-14 21:16 ` Renat Golubchyk 2 siblings, 1 reply; 12+ messages in thread From: Alan McKinnon @ 2009-12-14 20:25 UTC (permalink / raw To: gentoo-user; +Cc: walt On Monday 14 December 2009 20:28:21 walt wrote: > Renat Golubchyk wrote: > > As you said, you really are confused. :-) Maybe I wasn't clear enough. > > Anyway, I've written a program, and I need it as a statically linked > > binary. In order to link statically the linker (ld) needs all the used > > libraries in static form, i.e. as a .a and not as a .so file. Since > > portage does not build static libraries by default I need a way to tell > > portage that I really do want to have .a files built. > > > > I do _not_ want to create a Gentoo package, at least not at this stage > > of development. > > Still confused :o( Yes, I'm not surprised. you read the OPs post upside down. He does not want to *generate* static binaries, he wants to *use* them. Presumably he has written an app (that possibly must be distributed as a contained unit) that must statically link the libs it uses. Those libs would have been put there by portage, but he needs portage to build .a's, not only .so's > > Portage is for building Gentoo packages -- if you don't want to build a > Gentoo package then why is portage involved? You can compile and link > your program with any flags you want to, so as to get static binaries. OP, I'm not sure why you have a problem. A quick search on my box shows that most libs (of the small number I checked) have .a and .so Please post emerge --info and details of which libs you know at this point you do need. -- alan dot mckinnon at gmail dot com ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Re: Building static libraries 2009-12-14 20:25 ` Alan McKinnon @ 2009-12-15 6:53 ` Renat Golubchyk 0 siblings, 0 replies; 12+ messages in thread From: Renat Golubchyk @ 2009-12-15 6:53 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 797 bytes --] On Mon, 14 Dec 2009 22:25:46 +0200 Alan McKinnon <alan.mckinnon@gmail.com> wrote: > I'm not sure why you have a problem. A quick search on my box shows > that most libs (of the small number I checked) have .a and .so Most libs, but not all. glibc is one of them. Anyway, I've added "--enable-static" to EXTRA_ECONF and it worked. There are some packages that don't like it. In particular, sandbox aborts in the configure phase with the message "configure: error: dont be a Kumba, building a libsandbox.a is stupid" :-) I had to put an exception into /etc/portage/bashrc in order to handle that. Cheers, Renat -- Probleme kann man niemals mit derselben Denkweise loesen, durch die sie entstanden sind. (Einstein) [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Re: Building static libraries 2009-12-14 18:28 ` walt 2009-12-14 20:19 ` Allan Gottlieb 2009-12-14 20:25 ` Alan McKinnon @ 2009-12-14 21:16 ` Renat Golubchyk 2 siblings, 0 replies; 12+ messages in thread From: Renat Golubchyk @ 2009-12-14 21:16 UTC (permalink / raw To: gentoo-user [-- Attachment #1: Type: text/plain, Size: 1277 bytes --] On Mon, 14 Dec 2009 10:28:21 -0800 walt <w41ter@gmail.com> wrote: > Renat Golubchyk wrote: > > > As you said, you really are confused. :-) Maybe I wasn't clear > > enough. Anyway, I've written a program, and I need it as a > > statically linked binary. In order to link statically the linker > > (ld) needs all the used libraries in static form, i.e. as a .a and > > not as a .so file. Since portage does not build static libraries by > > default I need a way to tell portage that I really do want to > > have .a files built. > > > > I do _not_ want to create a Gentoo package, at least not at this > > stage of development. > > Still confused :o( > > Portage is for building Gentoo packages -- if you don't want to build > a Gentoo package then why is portage involved? You can compile and > link your program with any flags you want to, so as to get static > binaries. Because my program uses different libraries which I don't build manually. Instead I use portage. That way I can compile in only those features that I need and I don't have to resolve dependencies. Cheers, Renat -- Probleme kann man niemals mit derselben Denkweise loesen, durch die sie entstanden sind. (Einstein) [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 198 bytes --] ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-12-15 8:01 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-12-13 19:18 [gentoo-user] Building static libraries Renat Golubchyk 2009-12-13 20:40 ` Albert Hopkins 2009-12-14 0:27 ` Renat Golubchyk 2009-12-13 22:47 ` [gentoo-user] " walt 2009-12-14 0:27 ` Renat Golubchyk 2009-12-14 1:53 ` Albert Hopkins 2009-12-14 2:19 ` Renat Golubchyk 2009-12-14 18:28 ` walt 2009-12-14 20:19 ` Allan Gottlieb 2009-12-14 20:25 ` Alan McKinnon 2009-12-15 6:53 ` Renat Golubchyk 2009-12-14 21:16 ` Renat Golubchyk
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox