You are not logged in.

#1 2019-03-28 12:35:12

ruffy
Member
Registered: 2017-06-10
Posts: 62

missing static libraries

Hi all!

I am working on an OCaml project which I want to compile statically, but the problem is that on arch some static libraries are missing.

I can compile it dynamically, but when I want to compile it statically I get the following:

/usr/bin/ld: cannot find -lgmp
/usr/bin/ld: cannot find -lxslt
/usr/bin/ld: cannot find -lxml2
/usr/bin/ld: cannot find -licui18n
/usr/bin/ld: cannot find -licuuc
/usr/bin/ld: cannot find -licudata
/usr/bin/ld: cannot find -llzma

So I tried to install them manually, but I again get some errors:

/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../lib/libxml2.a(xmlmodule.o): in function `xmlModuleOpen':
(.text+0x40): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(initgroups.o): in function `unix_initgroups':
(.text+0x1f): warning: Using 'initgroups' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(getgr.o): in function `unix_getgrgid':
(.text+0x18e): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(getgr.o): in function `unix_getgrnam':
(.text+0x134): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(getpw.o): in function `unix_getpwnam':
(.text+0x194): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(getpw.o): in function `unix_getpwuid':
(.text+0x1ee): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(getaddrinfo.o): in function `unix_getaddrinfo':
(.text+0x229): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(gethost.o): in function `unix_gethostbyaddr':
(.text+0x22f): warning: Using 'gethostbyaddr_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../lib/libxml2.a(nanohttp.o): in function `xmlNanoHTTPConnectHost':
(.text+0x955): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(gethost.o): in function `unix_gethostbyname':
(.text+0x2d9): warning: Using 'gethostbyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(getproto.o): in function `unix_getprotobynumber':
(.text+0x108): warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(getproto.o): in function `unix_getprotobyname':
(.text+0xe1): warning: Using 'getprotobyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(getserv.o): in function `unix_getservbyname':
(.text+0x138): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/ocaml/libunix.a(getserv.o): in function `unix_getservbyport':
(.text+0x186): warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../lib/libxml2.a(encoding.o): in function `openIcuConverter':
(.text+0xf2d): undefined reference to `ucnv_open_63'
/usr/bin/ld: (.text+0xf59): undefined reference to `UCNV_FROM_U_CALLBACK_STOP_63'
/usr/bin/ld: (.text+0xf5f): undefined reference to `ucnv_setFromUCallBack_63'
/usr/bin/ld: (.text+0xf7f): undefined reference to `ucnv_open_63'
/usr/bin/ld: (.text+0xf99): undefined reference to `ucnv_close_63'
/usr/bin/ld: (.text+0xfd3): undefined reference to `UCNV_TO_U_CALLBACK_STOP_63'
/usr/bin/ld: (.text+0xfd9): undefined reference to `ucnv_setToUCallBack_63'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../lib/libxml2.a(encoding.o): in function `xmlUconvWrapper':
(.text+0x1188): undefined reference to `ucnv_convertEx_63'
/usr/bin/ld: (.text+0x1213): undefined reference to `ucnv_convertEx_63'
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/../../../../lib/libxml2.a(encoding.o): in function `closeIcuConverter.part.1':
(.text+0x12dc): undefined reference to `ucnv_close_63'
/usr/bin/ld: (.text+0x12e6): undefined reference to `ucnv_close_63'
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking

I have tried it on a Linux Mint machine of a friend, where static compilation worked out of the box.

Does anybody has a solution for that?
Is there a general solution to get static libraries via pacman?

Thanks!

Last edited by ruffy (2019-03-28 12:46:56)

Offline

#2 2019-03-28 12:55:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: missing static libraries

ruffy wrote:

Is there a general solution to get static libraries via pacman?

No.  Pacman is completely orthogonal to the issue.  Arch just generally does not package static libraries.  If you need to do any static linking, then rebuilding any (and all) libraries you need to staticly link to is the right approach.  I don't know enough about libxml2 to help with the errors of rebuilding it, but that's where you need to keep working.

Note, if you intend to frequently statically link substantial projects, arch may not be an ideal distro.  I statically link many simple / small tools I use, but they have a pretty trivial library dependency tree to start with.

Last edited by Trilby (2019-03-28 12:56:50)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2019-03-28 13:24:45

ruffy
Member
Registered: 2017-06-10
Posts: 62

Re: missing static libraries

Trilby wrote:
ruffy wrote:

Is there a general solution to get static libraries via pacman?

No.  Pacman is completely orthogonal to the issue.  Arch just generally does not package static libraries.  If you need to do any static linking, then rebuilding any (and all) libraries you need to staticly link to is the right approach.  I don't know enough about libxml2 to help with the errors of rebuilding it, but that's where you need to keep working.

Note, if you intend to frequently statically link substantial projects, arch may not be an ideal distro.  I statically link many simple / small tools I use, but they have a pretty trivial library dependency tree to start with.


Hmmmmm, I definitely do not want to switch to a different distribution.

Is there a possibility to change the PKGBUILD before pacman builds/installs the package?
I think there I could change something that I also get static libs...

Offline

#4 2019-03-28 13:51:01

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,783
Website

Re: missing static libraries

Arch (typically? There may be exceptions) does not package static libraries if there is a shared equivalent. You can disable this behaviour by rebuilding the affected packages with the "staticlibs" option.

man PKGBUILD | less -p '  options'

Do you really need to statically link whatever it is that you're building? If so, it may be easier to create a chroot/container of a staticlib-friendly distribution (e.g. debian) and build in that instead of rebuilding Arch packages.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2019-03-28 14:02:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: missing static libraries

ruffy wrote:

Is there a possibility to change the PKGBUILD before pacman builds/installs the package?
I think there I could change something that I also get static libs...

Ah, yeah.  It's very clearly covered in the documentation.  But that would - as stated - require rebuilding the packages.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2019-08-13 11:37:30

ruffy
Member
Registered: 2017-06-10
Posts: 62

Re: missing static libraries

WorMzy wrote:

Arch (typically? There may be exceptions) does not package static libraries if there is a shared equivalent. You can disable this behaviour by rebuilding the affected packages with the "staticlibs" option.

man PKGBUILD | less -p '  options'

Do you really need to statically link whatever it is that you're building? If so, it may be easier to create a chroot/container of a staticlib-friendly distribution (e.g. debian) and build in that instead of rebuilding Arch packages.

@WorMzy: So I install in some subdirectory debian and use chroot to change to debian and compile it? Or do I understand something wrong?

Last edited by ruffy (2019-08-13 11:38:16)

Offline

#7 2019-08-13 11:38:02

ruffy
Member
Registered: 2017-06-10
Posts: 62

Re: missing static libraries

Trilby wrote:
ruffy wrote:

Is there a possibility to change the PKGBUILD before pacman builds/installs the package?
I think there I could change something that I also get static libs...

Ah, yeah.  It's very clearly covered in the documentation.  But that would - as stated - require rebuilding the packages.

Where do I find that in the documentation?

Offline

#8 2019-08-13 12:30:05

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: missing static libraries

Wormzy already provided it.

But you will need to rebuild every library you depend on, and every library they depend on recursively which would be at least 17 different packages, all with different licenses which may in itself prohibit you from distributing a statically linked binary.

Why do you want to statically link this project?  Will it be distributed?  What license do you intend to use?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2019-08-13 12:54:21

ruffy
Member
Registered: 2017-06-10
Posts: 62

Re: missing static libraries

Trilby wrote:

Wormzy already provided it.

But you will need to rebuild every library you depend on, and every library they depend on recursively which would be at least 17 different packages, all with different licenses which may in itself prohibit you from distributing a statically linked binary.

Why do you want to statically link this project?  Will it be distributed?  What license do you intend to use?

Ahh okay I understand.

To test the tool we use a service (some cpu cluster hosted by a university) which requires that the binary, used for the tests, is statically build.

For me it would be more convenient to just be able to compile this program statically on my machine.

Last edited by ruffy (2019-08-13 12:54:43)

Offline

#10 2019-08-24 17:04:29

AstroFloyd
Member
Registered: 2013-12-01
Posts: 7
Website

Re: missing static libraries

I'm in a similar situation - I want to run compiled Fortran programs on a web server where I have no root access.  Hence, I can't compile or install (dynamic) libraries, and I don't worry about licences.  The fact that libgfortran.a and libquadmath.a are not included in Arch seems to mean that I cannot link anything statically. Other basic static libraries, like libm and boost do have static counterparts for their shared libraries.  On my Gentoo system, I can simply set (or unset) the static USE flag if I (do not) want the static version in addition to the shared one.  I could imagine a system for Arch where .a files are shipped (at least for basic libraries) but not installed, except when the name of the package occurs in a variable in pacman.conf containing a list of packages.  Note also that installing some static libraries is not the same as compiling and linking your whole system statically!

Anyway, what I wanted to ask is that above I read a lot of 'rebuilding the package'.  I suppose you need a PKGBUILD file (I know them from the AUR), in my case for gcc-libs.  Is there a place where all PKGBUILDs from stable/official Arch (meaning not AUR) can be found, or do I also have to write the PKGBUILD from scratch?

Offline

#11 2019-08-24 17:26:32

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: missing static libraries


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#12 2019-08-25 01:24:35

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: missing static libraries

AstroFloyd wrote:

Note also that installing some static libraries is not the same as compiling and linking your whole system statically!

No one suggested that it was, but to build anything statically, you will need to rebuild everything that it depends on (and eveyrthing those dependencies depend on, and what those depend on, etc) such that in some cases, you will effectively be building the whole system statically.

If you have just a simple fortran computational program, it's pretty trivial - but that's not where this thread started.

AstroFloyd wrote:

... and I don't worry about licences

We do.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#13 2019-08-25 06:49:41

AstroFloyd
Member
Registered: 2013-12-01
Posts: 7
Website

Re: missing static libraries

Trilby wrote:

If you have just a simple fortran computational program, it's pretty trivial - but that's not where this thread started.

OK, then I misunderstood - I thought the OP suffered from missing static libraries, and I suffer from a missing libgfortran.a and libquadmath.a which (might have) come with the gcc-libs package.  But if they're not missing, where can I find them?

Trilby wrote:
AstroFloyd wrote:

... and I don't worry about licences

We do.

What I meant was that I only worry about licences when I distribute software publicly, which is not the case here - or am I mistaken?

Offline

#14 2019-08-25 06:50:24

AstroFloyd
Member
Registered: 2013-12-01
Posts: 7
Website

Re: missing static libraries

Offline

#15 2019-08-25 11:50:03

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,441
Website

Re: missing static libraries

You would have to rebuild one package to get that static lib - or just download it from anywhere that provides it.  The repos have the static libs for those in the arm64 cross compiler packages, but not our default packages - I'm not sure why really.

I build many simple projects statically, and have no problem at all.  For example, musl in the repos provides most/all of libc as static ".a" libs.

Last edited by Trilby (2019-08-25 11:53:22)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB