LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Where is libX11.a ? ... error building static executable (https://www.linuxquestions.org/questions/slackware-14/where-is-libx11-a-error-building-static-executable-4175498419/)

aaazen 03-16-2014 04:32 PM

Where is libX11.a ? ... error building static executable
 
I am trying to build a static executable to run on a chrooted server.

And the program needs the libX11.a library to build.

In the older versions of Slackware there used to be a libX11.a file that came with the libX11 package.

Now it seems to be gone.

Is it hiding somewhere?

gengisdave 03-16-2014 04:39 PM

all x11 tree is built with --disable-static configure option, no .a files, you need to do it by yourself

aaazen 03-16-2014 05:46 PM

Quote:

Originally Posted by gengisdave (Post 5135751)
all x11 tree is built with --disable-static configure option, no .a files, you need to do it by yourself

Thanks.

This is very curious as Slackware used to have this file.

The BSD distributions still have this file, but many of the Linux distributions do not.

It makes it much harder for me to choose Linux as a server platform.

Richard Cranium 03-16-2014 08:24 PM

Well, the problem would be on the server where you are creating the executable versus where you are running that executable after you create it.

Didier Spaier 03-17-2014 02:17 AM

Two ways:
  1. (have the maintainer) Fix the application you compile so it requests the shared library instead of the static one.
  2. Re-build libX11 enabling building of static libraries.
To follow way #2, remove the line
Code:

  --disable-static \
in /path/to/slackware<your version>/source/x/x11/configure/libX11, then run
Code:

/path/to/slackware<your version>/source/x/x11/x11.SlackBuild  lib libX11
PS Google told me that many distributions don't ship static libraries for libX11 and that recommended way is #1.

aaazen 03-17-2014 06:41 PM

Quote:

Originally Posted by Didier Spaier (Post 5135924)
Two ways:
  1. (have the maintainer) Fix the application you compile so it requests the shared library instead of the static one.
  2. Re-build libX11 enabling building of static libraries.
To follow way #2, remove the line
Code:

  --disable-static \
in /path/to/slackware<your version>/source/x/x11/configure/libX11, then run
Code:

/path/to/slackware<your version>/source/x/x11/x11.SlackBuild  lib libX11
PS Google told me that many distributions don't ship static libraries for libX11 and that recommended way is #1.

Thanks Didier.

1) In this case I am the maintainer in that I changed the program (application) from dynamic to static.

I am trying to run an old web /cgi-bin/ program which uses the graphics routines in X11.

Since it runs in a chrooted environment the normal run time (shared) libraries are not available.

I don't want to have to copy run time libraries to the chroot sandbox every time I update or upgrade Slackware.

With a static binary, I create it and leave it and it runs forever.

2) Rebuilding X11 static libraries is not something I expect to have to do with any distribution. Slackware used to contain these static libraries.


P.S. I don't belong to the church of Google.

55020 03-17-2014 07:49 PM

Quote:

Originally Posted by comet.berkeley (Post 5136388)
I don't want to have to copy run time libraries to the chroot sandbox every time I update or upgrade Slackware.

Mmm-hmm. And so you won't get the security fixes ("X Security: It's worse than it looks") that come with a new xorg. Mmm-hmm. So, if an xorg CVE turns up in April, everyone's stuff gets patched except yours. Mmm-hmm. So, uh, why do you want a chroot environment again? so that the Syrian Electronic Army hopefully won't trash too much when you get pwned?

TommyC7 03-17-2014 09:48 PM

Quote:

comet.berkeley:
I don't want to have to copy run time libraries to the chroot sandbox every time I update or upgrade Slackware.
No need for that. You can simply use installpkg's "--root" option and point it to your chroot.

By the way, can I ask what the purpose of this rant is? I've looked through a few distributions (ebuild for Gentoo, spec file for CentOS/RHEL, even Fedora) and none of them seem to build with --enable-static (which as you said, is confirmed as a default in FreeBSD: http://svnweb.freebsd.org/ports/head...53&view=markup).

What's the real reason you care so much about a statically built libX11?

If it was VLC or LibreOffice (maybe even MPlayer) I could understand, but when it comes to libX11 I'm not quite sure what you're upset about. All of the Unix-like operating systems I'm currently using have a way to install a package into a separate directory.

Quote:

P.S. I don't belong to the church of Google.
I think he meant that it could be found via any search engine, Google just happens to be the most common.

aaazen 03-18-2014 01:19 AM

These are good questions.

Quote:

Originally Posted by 55020 (Post 5136417)
Mmm-hmm. And so you won't get the security fixes ("X Security: It's worse than it looks") that come with a new xorg. Mmm-hmm. So, if an xorg CVE turns up in April, everyone's stuff gets patched except yours.

I'm not actually running full blown Xorg in the chroot environment. But if a relevant CVE or other bug turns up then I expect to recompile my static program and copy this single file back into my chroot environment.

Quote:

Originally Posted by 55020 (Post 5136417)
Mmm-hmm. So, uh, why do you want a chroot environment again? so that the Syrian Electronic Army hopefully won't trash too much when you get pwned?

Yes, OpenBSD Apache is automatically configured with chroot and it is a good security practice for web servers. Chroot or jail or virtual machine are all better choices than doing nothing.

NeoMetal 03-18-2014 09:52 AM

You could also bind mount the dynamic libs into the chroot I guess

aaazen 03-19-2014 03:53 PM

I found that Suse Enterprise offers libX11.a in a "developer" package.

https://www.suse.com/LinuxPackages/p...1-libx11-devel

Besides FreeBSD, OpenBSD also has a libX11.a and my program builds fine on these environments.

I'm going to try and rebuild the libX11, libXau, and libXdmcp packages from source.

So I will modify the package configure/configure and configure/libX11 files and remove the --disable-static parameters and then
build the three packages.

aaazen 03-19-2014 07:56 PM

I was finally able to build a static binary by creating some x11 static libraries.

But first here is the LIBS used in the makefile for my program:
Code:

LIBS = -static -lm -L/usr/X11R6/lib64 -lX11 -lxcb -lpthread  -lXau -lXdmcp  -ldl
I rebuilt libX11, libXau, libXdmcp and libxcb to create static libraries.

Inside the x11 source package directory configure/configure
was changed to remove "--disable-static"

Inside the x11 source package directory configure/libX11
was changed to remove "--disable-static"
and add "--disable-loadable-xcursor"

To build the new packages these commands were run
Code:

#sh x11.SlackBuild lib libX11
#sh x11.SlackBuild lib libXau
#sh x11.SlackBuild lib libXdmcp
#sh x11.SlackBuild xcb libxcb

The build puts the packages in /tmp/x11-build. The old packages were removed and the new packages installed.

The program now builds with warnings but runs cleanly.

Without the "--disable-loadable-cursor" parameter of the libX11 build, the program runs ok but dies badly when doing a normal exit.

It appears to be crashing somewhere in the libX11 CrGlCur.c code thus the "--disable-loadable-xcursor" option.

aaazen 03-19-2014 08:29 PM

Debian wheezy appears to have a developer package for libX11 too:

https://packages.debian.org/wheezy/libx11-dev

Here is the list of files for amd64 including libX11.a

https://packages.debian.org/wheezy/a...1-dev/filelist

gnashley 03-20-2014 03:58 AM

Using some static lib from another distro is not really a proper solution.

aaazen 03-21-2014 05:32 AM

Quote:

Originally Posted by gnashley (Post 5137920)
Using some static lib from another distro is not really a proper solution.

True. What I did do though is install Debian on a spare partition. Then I was able to verify that my program would indeed compile there.

Like Slackware, Debian does not distribute static libraries with a normal install.

But the Debian package, libx11-dev, does provide the static libraries for developers like me. Slackware does not have such a package.

My ultimate solution for Slackware was to take the x11 source package build and modify all of the config/ directory files to remove all of the "--disable-static" parameters. I left everything else alone and just rebuilt everything for x11.

Then I updated all of my x11 packages.

It works fine. I now have all the static libraries I need as well as the dynamic libraries.

Maybe some day Slackware can provide a libx11-dev package like Debian?

Didier Spaier 03-21-2014 05:50 AM

Quote:

Originally Posted by comet.berkeley (Post 5138608)
Maybe some day Slackware can provide a libx11-dev package like Debian?

My crystal bowl tells me: don't hold your breath ;)

aaazen 07-25-2014 03:18 PM

I created a script to build the 4 static x11 libraries from the Slackware source code. I called it make-x11-static.

Code:

#! /bin/sh
# For Slackware, create x11-static packages from the original x11 package source
# for libX11 libXau libXdmcp and libxcb

set -e

# >>>> EDIT THESE! <<<<<

#set the from and to directories
SLACKDIR="/home/ftp/pub/slackware/slackware64-current/source/x"
BUILDDIR="/home/slackbuilds"

# Change the build number each time
BUILD=${BUILD:-1-static}

# >>>> SHOULD NOT NEED TO CHANGE ANYTHING BELOW HERE <<<<

# destination directory
PKGDIR="$BUILDDIR/x11-static"

# copy the original x11 package source to x11-static
rm -rf              $PKGDIR
cp -a $SLACKDIR/x11 $PKGDIR

# create new configuration files and
# replace all --disable-static with --disable-loadable-xcursor
cd $PKGDIR

for APKG in configure libX11 libXau libXdmcp libxcb ; do
  if  [ -r $PKGDIR/configure/$APKG ]; then
    mv -f  $PKGDIR/configure/$APKG \
          $PKGDIR/configure/$APKG-orig
    sed -e "s/--disable-static /--disable-loadable-xcursor /" \
        < $PKGDIR/configure/$APKG-orig \
        > $PKGDIR/configure/$APKG
  fi
done

# build each sub package
BUILD=$BUILD ./x11.SlackBuild lib libX11
BUILD=$BUILD ./x11.SlackBuild lib libXau
BUILD=$BUILD ./x11.SlackBuild lib libXdmcp
BUILD=$BUILD ./x11.SlackBuild xcb libxcb

exit 0


aaazen 05-10-2015 10:19 AM

Quote:

Originally Posted by comet.berkeley (Post 5138608)
...

Maybe some day Slackware can provide a libx11-dev package like Debian?

I am marking this thread as UNSOLVED because Slackware used to have an x11-devel package just like other Linux distributions still do.

While installing Slackware 11.0 (2006) on an old machine, I found a package called x11-devel containing the missing libX11.a file and other .a files.

Quote:

x11-devel: x11-devel (Libraries and other files for X programming)
x11-devel:
x11-devel: This is a set of include files (found in /usr/X11R6/include), static
x11-devel: libraries (found in /usr/X11R6/lib/*.a) and configuration files
x11-devel: (found in /usr/X11R6/lib/X11/config/) needed to compile X programs.
x11-devel:
x11-devel:
x11-devel:
x11-devel:
x11-devel:
x11-devel:
The package disappeared in Slackware 12.0 with this comment in
the UGRADE.TXT:
Code:

*** PACKAGE REMOVALS SINCE 11.0 ***
...
x/x11-*: removed old x/x11-* packages - replaced by new modular x11.
...

Perhaps Slackware current could and should have this package again?

the3dfxdude 05-10-2015 10:52 AM

Quote:

Originally Posted by comet.berkeley (Post 5360391)
I am marking this thread as UNSOLVED because Slackware used to have an x11-devel package just like other Linux distributions still do.

While installing Slackware 11.0 (2006) on an old machine, I found a package called x11-devel containing the missing libX11.a file and other .a files.



The package disappeared in Slackware 12.0 with this comment in
the UGRADE.TXT:
Code:

*** PACKAGE REMOVALS SINCE 11.0 ***
...
x/x11-*: removed old x/x11-* packages - replaced by new modular x11.
...

Perhaps Slackware current could and should have this package again?

When I read through this thread, this is what I thought happened.

Were you successful obtaining the static libs, and linking into your program by now? I guess you were. So this is a request to have to already packaged for you? How large are the .a files you need?

Alien Bob 05-10-2015 10:57 AM

Quote:

Originally Posted by comet.berkeley (Post 5360391)
I am marking this thread as UNSOLVED because Slackware used to have an x11-devel package just like other Linux distributions still do.

While installing Slackware 11.0 (2006) on an old machine, I found a package called x11-devel containing the missing libX11.a file and other .a files.



The package disappeared in Slackware 12.0 with this comment in
the UGRADE.TXT:
Code:

*** PACKAGE REMOVALS SINCE 11.0 ***
...
x/x11-*: removed old x/x11-* packages - replaced by new modular x11.
...

Perhaps Slackware current could and should have this package again?

It says "replaced by new modular x11" which means it is not coming back. And there is no reason to have it back, because all the files it contained (with the exception of the static libraries) have been moved into other packages where needed.

Slackware has a policy of not using or providing static libraries unless software can not be compiled without the static library. This allows for easier upgrades of individual packages without requiring that all other packages which used a static library component have to be recompiled as well. Moreso, it saves space on the Slackware media when only shipping the shared libraries. A static libX11.a is not going to re-appear in Slackware.

And you already found your solution by compiling the static library yourself.

aaazen 05-10-2015 01:36 PM

Quote:

Originally Posted by the3dfxdude (Post 5360402)
When I read through this thread, this is what I thought happened.

Were you successful obtaining the static libs, and linking into your program by now? I guess you were.

Yes, the above script worked for me, but it is a horrible kludge and not the "right" way to fix the problem.

Quote:

So this is a request to have to already packaged for you?
Yes, I guess it is. The x11-devel (Slack 11.0) package used to be built automatically by the x11 build process.

Alien Bob and others object to having an x11-devel package as part of the standard release because it can introduce static library dependencies between packages. I don't disagree with this.

But other distributions get around this problem by supplying the x11-devel (libX11-devel) packages as optional and extra, not part of a standard release.

Slackware could have an x11-devel package in the /extra release directory just for developers.

Quote:

How large are the .a files you need?
They are actually fairly small. In Slackware 11.0 the x11-devel package is 5 megabytes.

volkerdi 05-10-2015 03:28 PM

Quote:

Originally Posted by comet.berkeley (Post 5360391)
I am marking this thread as UNSOLVED because Slackware used to have an x11-devel package just like other Linux distributions still do.

While installing Slackware 11.0 (2006) on an old machine, I found a package called x11-devel containing the missing libX11.a file and other .a files.



The package disappeared in Slackware 12.0 with this comment in
the UGRADE.TXT:
Code:

*** PACKAGE REMOVALS SINCE 11.0 ***
...
x/x11-*: removed old x/x11-* packages - replaced by new modular x11.
...

Perhaps Slackware current could and should have this package again?

Like the previous poster said, don't hold your breath. Those static libraries are huge, and almost nobody needs them for anything.

Glad you figured out how to build them. IMHO, this should be marked solved.

aaazen 05-15-2015 01:40 AM

x11-devel.SlackBuild
 
I have created a replacement for my kludge above called x11-devel.SlackBuild.

http://sourceforge.net/projects/slac...ckbuild/files/

This was made from the existing x11.SlackBuild script.

It writes all output packages and modified configuration files to the /tmp/x11-devel/ directory.

It should leave the original x11 source files/scripts/configuration untouched.

It builds multiple x11-devel packages.

Use the script with Slackware 14.1 or newer by placing it in the source/x/x11 directory.

Then to build and install all available x11 static libraries, run these 3 commands:

#./x11-devel.SlackBuild xcb
#./x11-devel.SlackBuild lib
#./x11-devel.SlackBuild app compiz

The created package files are put in the /tmp/x11-devel directory.

To create the packages without installation, run the scripts like this:

#UPGRADE_PACKAGES=no ./x11-devel.SlackBuild xcb
#UPGRADE_PACKAGES=no ./x11-devel.SlackBuild lib
#UPGRADE_PACKAGES=no ./x11-devel.SlackBuild app compiz

aaazen 05-24-2015 02:02 PM

README for x11-devel.SlackBuild
 
Here is the updated README for x11-devel.SlackBuild 1.1:

2018-05-18 x11-devel.SlackBuild 1.1

The Slackware x11-devel.SlackBuild script can create static libraries for use with the X Window system.

Use the script with Slackware 14.1 or newer by placing it in the source/x/x11 directory.

Then to build and install all available x11 static libraries, run these 3 commands:

#./x11-devel.SlackBuild xcb
#./x11-devel.SlackBuild lib
#./x11-devel.SlackBuild app compiz

The created package files are put in the /tmp/x11-devel directory.

To create the packages without installation, run the scripts like this:

#UPGRADE_PACKAGES=no ./x11-devel.SlackBuild xcb
#UPGRADE_PACKAGES=no ./x11-devel.SlackBuild lib
#UPGRADE_PACKAGES=no ./x11-devel.SlackBuild app compiz

47 packages are created:
(When all installed they use less than 11 megabytes of disk)

x11-devel-compiz-0.8.8-x86_64-2.txz
x11-devel-libFS-1.0.6-x86_64-1.txz
x11-devel-libICE-1.0.9-x86_64-1.txz
x11-devel-libSM-1.2.2-x86_64-1.txz
x11-devel-libX11-1.6.3-x86_64-1.txz
x11-devel-libXScrnSaver-1.2.2-x86_64-1.txz
x11-devel-libXau-1.0.8-x86_64-1.txz
x11-devel-libXaw-1.0.12-x86_64-1.txz
x11-devel-libXaw3d-1.6.2-x86_64-2.txz
x11-devel-libXcomposite-0.4.4-x86_64-1.txz
x11-devel-libXcursor-1.1.14-x86_64-1.txz
x11-devel-libXdamage-1.1.4-x86_64-1.txz
x11-devel-libXdmcp-1.1.2-x86_64-1.txz
x11-devel-libXevie-1.0.3-x86_64-1.txz
x11-devel-libXext-1.3.3-x86_64-1.txz
x11-devel-libXfixes-5.0.1-x86_64-1.txz
x11-devel-libXfont-1.5.1-x86_64-1.txz
x11-devel-libXfontcache-1.0.5-x86_64-1.txz
x11-devel-libXft-2.3.2-x86_64-2.txz
x11-devel-libXi-1.7.4-x86_64-1.txz
x11-devel-libXinerama-1.1.3-x86_64-1.txz
x11-devel-libXmu-1.1.2-x86_64-1.txz
x11-devel-libXp-1.0.3-x86_64-1.txz
x11-devel-libXpm-3.5.11-x86_64-1.txz
x11-devel-libXrandr-1.4.2-x86_64-1.txz
x11-devel-libXrender-0.9.8-x86_64-1.txz
x11-devel-libXres-1.0.7-x86_64-1.txz
x11-devel-libXt-1.1.4-x86_64-1.txz
x11-devel-libXtst-1.2.2-x86_64-1.txz
x11-devel-libXv-1.0.10-x86_64-1.txz
x11-devel-libXvMC-1.0.9-x86_64-1.txz
x11-devel-libXxf86dga-1.1.4-x86_64-1.txz
x11-devel-libXxf86misc-1.0.3-x86_64-1.txz
x11-devel-libXxf86vm-1.1.4-x86_64-1.txz
x11-devel-libdmx-1.1.3-x86_64-1.txz
x11-devel-libfontenc-1.1.2-x86_64-1.txz
x11-devel-libpciaccess-0.13.3-x86_64-1.txz
x11-devel-libxcb-1.11-x86_64-1.txz
x11-devel-libxkbfile-1.0.8-x86_64-1.txz
x11-devel-libxshmfence-1.2-x86_64-1.txz
x11-devel-pixman-0.32.6-x86_64-1.txz
x11-devel-xcb-util-0.4.0-x86_64-1.txz
x11-devel-xcb-util-cursor-0.1.2-x86_64-1.txz
x11-devel-xcb-util-image-0.4.0-x86_64-1.txz
x11-devel-xcb-util-keysyms-0.4.0-x86_64-1.txz
x11-devel-xcb-util-renderutil-0.3.9-x86_64-1.txz
x11-devel-xcb-util-wm-0.4.1-x86_64-1.txz

-------------------------------------------------------------------------
Changelog:
2015-05-14 version 1.0 * Copy/modify x11.SlackBuild
2015-05-18 version 1.1 * include only libraries (*.a) in each package
2015-05-24 * Update this README


All times are GMT -5. The time now is 08:48 PM.