You are not logged in.

#1 2021-05-06 06:46:03

kalekale
Member
Registered: 2021-05-06
Posts: 3

static libs

why doesn't arch package static libs? i want to statically link stuffs and it seems pacman cannot provide that and i may have to rebuild every libs or do it in a contained environment

Offline

#2 2021-05-06 07:37:41

seth
Member
Registered: 2012-09-03
Posts: 50,983

Re: static libs

Your post doesn't make any sense.
The linker process doesn't have to do with the packaging, the package format or pacman in particular.

That's like asking why the street doesn't allow me to start my engine.

Offline

#3 2021-05-06 07:41:34

kalekale
Member
Registered: 2021-05-06
Posts: 3

Re: static libs

from what i understand, arch does not package the static libraries, why is that?
> The linker process doesn't have to do with the packaging, the package format or pacman in particular.
yes, but its pacman that i would go to first when i need the static libraries, and from what i understand arch does not package them

Offline

#4 2021-05-06 07:52:08

seth
Member
Registered: 2012-09-03
Posts: 50,983

Re: static libs

ls /usr/lib/*.a tells me that there're quite some static libraries installed…

So it's less that "pacman cannot provide" static libs but "some random package doesn't provide the static version of a library that I'd like to link to"?
The reason for that is going to be related to the package/library in question, so you have to be more specific about that.

There're no generic restrictions for shipping static libraries.

Also: if you intend to ship a binary that statically links a library, that library doesn't have to exist on the target system. It's enough to exist on your system when you build the binary and it doesn't matter where it's coming from.

Maybe take a step back and explain what you actually want to do, because this increasingly sounds like an xy-problem and you made "use satic library" the assumed solution w/o actually understanding the process.

Offline

#5 2021-05-06 09:50:57

kalekale
Member
Registered: 2021-05-06
Posts: 3

Re: static libs

yeah a few static libs are indeed installed
>  but "some random package doesn't provide the static version of a library that I'd like to link to"?
yeah that "random package" happens to be glibc

```
{21-05-06 15:26}gensokyo:~/docs/src/9base@master✗✗✗✗✗✗ kalekale% ls /usr/lib/*.so | grep glib
/usr/lib/libappstream-glib.so
/usr/lib/libavahi-glib.so
/usr/lib/libgeocode-glib.so
/usr/lib/libglib-2.0.so
/usr/lib/libjson-glib-1.0.so
/usr/lib/libmm-glib.so
/usr/lib/libpulse-mainloop-glib.so
/usr/lib/libspice-client-glib-2.0.so
/usr/lib/libupower-glib.so
{21-05-06 15:26}gensokyo:~/docs/src/9base@master✗✗✗✗✗✗ kalekale% ls /usr/lib/*.a | grep glib
```

```ls /usr/lib/*.a | grep glib``` gave no result, i was expecting to see libglibc-2.0.a

> explain what you actually want to do

trying to compile 9plan utilites, it seems 9plan guys prefer static linking

the error i got while trying to compile it

```
/usr/bin/ld: diffio.o:(.bss+0x4): multiple definition of `mode'; diffdir.o:(.bss+0x4): first defined here
/usr/bin/ld: diffio.o:(.bss+0x5): multiple definition of `bflag'; diffdir.o:(.bss+0x5): first defined here
/usr/bin/ld: diffio.o:(.bss+0x6): multiple definition of `rflag'; diffdir.o:(.bss+0x6): first defined here
/usr/bin/ld: diffio.o:(.bss+0x7): multiple definition of `mflag'; diffdir.o:(.bss+0x7): first defined here
/usr/bin/ld: diffio.o:(.bss+0x8): multiple definition of `anychange'; diffdir.o:(.bss+0x8): first defined here
/usr/bin/ld: diffreg.o:(.bss+0x4): multiple definition of `mode'; diffdir.o:(.bss+0x4): first defined here
/usr/bin/ld: diffreg.o:(.bss+0x5): multiple definition of `bflag'; diffdir.o:(.bss+0x5): first defined here
/usr/bin/ld: diffreg.o:(.bss+0x6): multiple definition of `rflag'; diffdir.o:(.bss+0x6): first defined here
/usr/bin/ld: diffreg.o:(.bss+0x7): multiple definition of `mflag'; diffdir.o:(.bss+0x7): first defined here
/usr/bin/ld: diffreg.o:(.bss+0x8): multiple definition of `anychange'; diffdir.o:(.bss+0x8): first defined here
/usr/bin/ld: main.o:(.bss+0x4): multiple definition of `mode'; diffdir.o:(.bss+0x4): first defined here
/usr/bin/ld: main.o:(.bss+0x5): multiple definition of `bflag'; diffdir.o:(.bss+0x5): first defined here
/usr/bin/ld: main.o:(.bss+0x6): multiple definition of `rflag'; diffdir.o:(.bss+0x6): first defined here
/usr/bin/ld: main.o:(.bss+0x7): multiple definition of `mflag'; diffdir.o:(.bss+0x7): first defined here
/usr/bin/ld: main.o:(.bss+0x8): multiple definition of `anychange'; diffdir.o:(.bss+0x8): first defined here
/usr/bin/ld: ../lib9/lib9.a(_p9dir.o): in function `_p9dir':
_p9dir.c:(.text+0x3eb): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: _p9dir.c:(.text+0x282): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
make[1]: *** [../std.mk:35: diff] Error 1
make[1]: Leaving directory '/home/kalekale/docs/src/9base/diff'
make: *** [Makefile:69: all] Error 2
```
>  w/o actually understanding the process.
maybe im misinterperting this error message, but i think this has something to do with not having the static libs installed

Offline

#6 2021-05-06 09:56:49

progandy
Member
Registered: 2012-05-17
Posts: 5,190

Re: static libs

Edit: Wrong...

Last edited by progandy (2021-05-06 10:13:51)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#7 2021-05-06 10:12:58

arojas
Developer
From: Spain
Registered: 2011-10-09
Posts: 2,097

Re: static libs

kalekale wrote:

maybe im misinterperting this error message, but i think this has something to do with not having the static libs installed

Yes, you are. Those errors have nothing to do with static linking, but rather with having the same symbol defined in multiple objects, which throws an error by default with GCC 10. To work around it, pass '-fcommon' to CFLAGS, but it should be properly fixed in the application code.

Offline

#8 2021-05-06 11:38:08

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: static libs

In addition to the problem arojas mentioned...

kalekale wrote:

yeah a few static libs are indeed installed
>  but "some random package doesn't provide the static version of a library that I'd like to link to"?
yeah that "random package" happens to be glibc

```
{21-05-06 15:26}gensokyo:~/docs/src/9base@master✗✗✗✗✗✗ kalekale% ls /usr/lib/*.so | grep glib
/usr/lib/libappstream-glib.so
/usr/lib/libavahi-glib.so
/usr/lib/libgeocode-glib.so
/usr/lib/libglib-2.0.so
/usr/lib/libjson-glib-1.0.so
/usr/lib/libmm-glib.so
/usr/lib/libpulse-mainloop-glib.so
/usr/lib/libspice-client-glib-2.0.so
/usr/lib/libupower-glib.so
{21-05-06 15:26}gensokyo:~/docs/src/9base@master✗✗✗✗✗✗ kalekale% ls /usr/lib/*.a | grep glib
```

```ls /usr/lib/*.a | grep glib``` gave no result, i was expecting to see libglibc-2.0.a

glib, is the Gnome Library, GLib 2.0

GNU libc is libc.a and is definitely on your system

kalekale wrote:

> explain what you actually want to do

trying to compile 9plan utilites, it seems 9plan guys prefer static linking

the error i got while trying to compile it

```
/usr/bin/ld: diffio.o:(.bss+0x4): multiple definition of `mode'; diffdir.o:(.bss+0x4): first defined here
/usr/bin/ld: diffio.o:(.bss+0x5): multiple definition of `bflag'; diffdir.o:(.bss+0x5): first defined here
/usr/bin/ld: diffio.o:(.bss+0x6): multiple definition of `rflag'; diffdir.o:(.bss+0x6): first defined here
/usr/bin/ld: diffio.o:(.bss+0x7): multiple definition of `mflag'; diffdir.o:(.bss+0x7): first defined here
/usr/bin/ld: diffio.o:(.bss+0x8): multiple definition of `anychange'; diffdir.o:(.bss+0x8): first defined here
/usr/bin/ld: diffreg.o:(.bss+0x4): multiple definition of `mode'; diffdir.o:(.bss+0x4): first defined here
/usr/bin/ld: diffreg.o:(.bss+0x5): multiple definition of `bflag'; diffdir.o:(.bss+0x5): first defined here
/usr/bin/ld: diffreg.o:(.bss+0x6): multiple definition of `rflag'; diffdir.o:(.bss+0x6): first defined here
/usr/bin/ld: diffreg.o:(.bss+0x7): multiple definition of `mflag'; diffdir.o:(.bss+0x7): first defined here
/usr/bin/ld: diffreg.o:(.bss+0x8): multiple definition of `anychange'; diffdir.o:(.bss+0x8): first defined here
/usr/bin/ld: main.o:(.bss+0x4): multiple definition of `mode'; diffdir.o:(.bss+0x4): first defined here
/usr/bin/ld: main.o:(.bss+0x5): multiple definition of `bflag'; diffdir.o:(.bss+0x5): first defined here
/usr/bin/ld: main.o:(.bss+0x6): multiple definition of `rflag'; diffdir.o:(.bss+0x6): first defined here
/usr/bin/ld: main.o:(.bss+0x7): multiple definition of `mflag'; diffdir.o:(.bss+0x7): first defined here
/usr/bin/ld: main.o:(.bss+0x8): multiple definition of `anychange'; diffdir.o:(.bss+0x8): first defined here
/usr/bin/ld: ../lib9/lib9.a(_p9dir.o): in function `_p9dir':
_p9dir.c:(.text+0x3eb): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: _p9dir.c:(.text+0x282): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
make[1]: *** [../std.mk:35: diff] Error 1
make[1]: Leaving directory '/home/kalekale/docs/src/9base/diff'
make: *** [Makefile:69: all] Error 2
```
>  w/o actually understanding the process.
maybe im misinterperting this error message, but i think this has something to do with not having the static libs installed

Well, the error message did explicitly mention the problem is in diffdir.o being incompatible with main.o, diffreg.o, diffio.o

No mention of glibc there, but if you had googled "multiple definition" you would have discovered the point arojas made.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#9 2021-05-06 20:36:44

loqs
Member
Registered: 2014-03-06
Posts: 17,321

Re: static libs

diff --git a/diff/diff.h b/diff/diff.h
index 25e39c6..94c7bf0 100644
--- a/diff/diff.h
+++ b/diff/diff.h
@@ -1,10 +1,10 @@
 #define stdout bstdout
 
-char mode;			/* '\0', 'e', 'f', 'h' */
-char bflag;			/* ignore multiple and trailing blanks */
-char rflag;			/* recurse down directory trees */
-char mflag;			/* pseudo flag: doing multiple files, one dir */
-int anychange;
+extern char mode;			/* '\0', 'e', 'f', 'h' */
+extern char bflag;			/* ignore multiple and trailing blanks */
+extern char rflag;			/* recurse down directory trees */
+extern char mflag;			/* pseudo flag: doing multiple files, one dir */
+extern int anychange;
 extern Biobuf	stdout;
 extern int	binary;
 
 

Edit:
Also note with respect to static libs https://github.com/archlinux/svntogit-c … GBUILD#L33

Last edited by loqs (2021-05-06 20:42:37)

Offline

Board footer

Powered by FluxBB