How to cause a program to look into a specific folder for its own libraries

Technical issues/questions of an intermediate or advanced nature.
Post Reply
User avatar
cad
White ninja
White ninja
Posts: 29
Joined: 06 Nov 2020, 22:40
Distribution: 4.0 i586 LXDE

How to cause a program to look into a specific folder for its own libraries

Post#1 by cad » 19 Nov 2020, 03:55

I did not mention "libreoffice" in the subject because this is a general question that applies to any situation similar to this one and its answer can benefit many Porteus users who are facing a similar question. I am sure one of you experienced developers has an easy solution for this problem.

Specifically, this is what I have at hand: Installed Alien Bob's libreoffice-6.4.6-i585 in Porteus 4.0 i586. When libreoffice attempts to start, it looks in /usr/lib/ for libstdc++.so.6 (version GLIBCXX_3.4.26), but obviously does not find it there since Porteus 4.0 i586 has an earlier version of that library (libstdc++.so.6.0.24 as opposed to the libstdc++.so.27 libreoffice is looking for). However, the version libreoffice is looking for is in fact in /usr/lib/libreoffice/program/, so it is readily avalaible, only libreoffice is looking for it in the wrong place - /usr/lib/ instead of /usr/lib/libreoffice/program/.

libstdc++.so.6 error

The question is: how do you cause libreoffice to look for this library in /usr/lib/libreoffice/program/ instead of in /usr/lib/? Is this a libreoffice bug?

Thank you.

donald
Full of knowledge
Full of knowledge
Posts: 1699
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

How to cause a program to look into a specific folder for its own libraries

Post#2 by donald » 19 Nov 2020, 10:38

Hi cad

The internal libraries are handled by the ldconfig program.
This program maintains the library cache and automatically creates the necessary symbolic links to libraries.
The library cache is located in the /etc/ld.so.cache file and contains a binary-coded list
of all libraries known to the system.

In order for ldconfig to be able to create this file and to include newly added libraries there,
ldconfig must know which directories should be searched for libraries.
ldconfig first searches the two directories /usr/lib and /lib [32 bit system], then all directories listed
in the /etc/ld.so.conf file.

So if a new foo program is installed that stores its shared libraries in the (e.g.) /usr/local/foo/lib directory,
we have to add this directory to the /etc/ld.so.conf file.
After installing new libraries and/or adding new paths to the /etc/ld.so.conf file,
the ldconfig program must be executed before the new libraries can be used.
They are only in the file /etc/ld.so.cache after calling ldconfig and are therefore known to the linker/loader.

https://linux.die.net/man/8/ldconfig

To create links to those libraries - in the common search directories - may be sufficient.

User avatar
cad
White ninja
White ninja
Posts: 29
Joined: 06 Nov 2020, 22:40
Distribution: 4.0 i586 LXDE

How to cause a program to look into a specific folder for its own libraries

Post#3 by cad » 19 Nov 2020, 16:16

Hi donald,

Thank you for your explanation which I know applies to all programs, generally. Before reading your post, I was able to resolve the aforementioned error (I simply, very carefully, made a new xzm libreoffice module from Alien Bob's txz files and, this time around, the program was able to find its libraries in /usr/lib/libreoffice/program). When, after reading your post, looked into the /etc/ld.so.conf file, I found that the path to the libreoffice library folder still was not there. These are the contents of the /etc/ld.so.conf file in Porteus 4.0 i586 LXDE, with libreoffice functionally finding its libraries:

/lib
/usr/lib
/usr/local/lib
/usr/i486-slackware-linux/lib

As you can see, the path to libreoffice libraries is still not there and yet now libreoffice is able to find its libraries. [Of course, I want to understand why it did not work the first time around. Luckily, I have a copy of the "non-working" libreoffice xzm module I had previously made, so I will compare the two. If I find the culprit, I will later report it here. There must be a solid reason why the second module worked with libreoffice finding its libraries while the first one didn't.]

Also, I now have a problem which is unrelated to the question asked in my original post: libreoffice will still not start because Alien Bob compiled his version with Java enabled and Porteus does not have Java (which is humongous in size!). But that's another story.

To return to my original question, maybe a couple of things can be clarified to me. First of all, is it acceptable to have two versions of the same library in one operating system? For instance, if I have two programs that need two different versions of libstdc++.so.6, can I safely place one version in /usr/lib/ and the other in /usr/local/lib, both symlinked to libstdc++.so.6? Or will there be conflicts with programs getting confused about which is which, with the paths to both libraries made available to all programs by the /etc/ld.so.conf file?
Second question is, aside from the /etc/ld.so.conf program setup, which generally does a great job at handling internal libraries, is there a way to cause a program to only look into a particular folder for its libraries without going through /etc/ld.so.conf? As we can see, libreoffice is already doing that (not using /etc/ld.so.conf for finding its own internal libraries). So, basically, if I put a number of libraries into a folder which is not in the paths specified in /etc/ld.so.conf, how do I cause the program which specifically needs those libraries to look into that folder? (again, libreoffice already does it. I do not know how complicated it might be, but it is certainly feasible.)

donald
Full of knowledge
Full of knowledge
Posts: 1699
Joined: 17 Jun 2013, 13:17
Distribution: Porteus 3.2.2 XFCE 32bit
Location: Germany

How to cause a program to look into a specific folder for its own libraries

Post#4 by donald » 19 Nov 2020, 21:18

Alien Bob's txz files.....the program was able to find its libraries in /usr/lib/libreoffice/program
may be the libs are statically linked in alien bob's package.

Some links to explore.
http://alien.slackbook.org/blog/tag/libreoffice/
slackbuild:
http://www.slackware.com/~alien/slackbu ... SlackBuild
and
https://git.slackware.nl/asb/log/libreoffice
two different versions of libstdc++.so.6............both symlinked to libstdc++.so.6
One can have different versions but they can not be linked to the same link - AFAIK

User avatar
cad
White ninja
White ninja
Posts: 29
Joined: 06 Nov 2020, 22:40
Distribution: 4.0 i586 LXDE

How to cause a program to look into a specific folder for its own libraries

Post#5 by cad » 19 Nov 2020, 23:10

Thank you so much for providing your links to explore. Very useful reading and the materials provided nicely answered the question I had asked in my other thread. :thumbsup:
Especially this page (related to your second link):
Slackware SlackBuild script for libreoffice-6.4.6-1
But also your first link with important information about two new libreoffice compile-time requirements and a workable way to satisfy them.

Thank you!

User avatar
Ed_P
Contributor
Contributor
Posts: 5798
Joined: 06 Feb 2013, 22:12
Distribution: 4.0 & 5.0rc2 Cinnamon 64 ISOs
Location: Western NY, USA

How to cause a program to look into a specific folder for its own libraries

Post#6 by Ed_P » 19 Nov 2020, 23:23

If you want to follow thru on a java module, mine is about 70Mb, this script I use may be helpful. Especially the links mentioned in it.

Code: Select all

#!/bin/sh

if [ `whoami` != "root" ]; then
#  ktsuss "$0"
   echo "Enter root's password"
   su -c "sh $0 $1"
   exit
fi

BOOTDEV=`grep -A1 "Booting" /var/log/porteus-livedbg|tail -n1|sed 's^//^/^g'`
if [ "$BOOTDEV" == "/mnt/isoloop" ]; then
   BOOTDEV=`grep -A1 "ISO=" /var/log/porteus-livedbg`
   BOOTDEV=${BOOTDEV:4:9}
fi
VERSION=$(cat /etc/porteus-version)
FOLDER=porteus${VERSION:9:3}
GUEST="$BOOTDEV/$FOLDER/Guest"
MODULES="$BOOTDEV/porteus/Modules"
OPTIONAL="$BOOTDEV/porteus/Optional"
MYARCH=i586
if [ `arch` = x86_64 ]; then
   MYARCH=x86_64
   MODULES="$BOOTDEV/$FOLDER/Modules"
   OPTIONAL="$BOOTDEV/$FOLDER/Optional"
fi
if [ -d $BOOTDEV/Modules ]; then
   MODULES="$BOOTDEV/Modules"
   OPTIONAL="$BOOTDEV/Optional"
fi

# https://forum.porteus.org/viewtopic.php?f=75&t=3332
# http://www.java.com/en/download/linux_manual.jsp
# https://forum.porteus.org/viewtopic.php?f=81&t=4326&start=15#p31423

CURRENT=`ls $MODULES/jre*.xzm`
echo
echo Current module: ${CURRENT:29:-4}

if [ ! -f /mnt/live/memory/images/java-builder*.xzm ]; then
   echo toor | activate $OPTIONAL/java-builder*.xzm  > /dev/null 2>&1 &
fi

echo
echo "1. Download the current non-RPM Linux file. "
echo "   firefox https://www.java.com/en/download/linux_manual.jsp" 
#firefox https://www.java.com/en/download/linux_manual.jsp  > /dev/null 2>&1 &
# Results in the download being in the /root/downloads folder rather than the guest one.
echo "   Close Firefox when done. "
echo " "
echo "2. Invoke [Menu > Admin] Java Builder "
echo " "
echo "3. Point it at the jre-*.tar.gz file in the /Downloads/ folder "
echo "   and run it. It takes a moment to start and several to end. "
echo " "
echo "4. When it ends press Enter to copy the jre-*.xzm file to the "
echo "   $MODULES folder."
read

if [  -f   /home/guest/jre-*-$MYARCH-1.xzm ]; then
   echo "Removing the old module. "
   ls     -sh $MODULES/jre*.xzm
   deactivate $MODULES/jre-*-$MYARCH-1.xzm
   rm -f      $MODULES/jre-*-$MYARCH-1.xzm
   cp      /home/guest/jre-*-$MYARCH-1.xzm  $MODULES
   activate   $MODULES/jre-*-$MYARCH-1.xzm
   echo "Removing the home/guest file. "
   rm -f   /home/guest/jre-*-$MYARCH-1.xzm
fi
echo
ls   -sh  $MODULES/jre*.xzm
echo
if [ -d /root/Downloads ]; then 
  rm -rf /root/Downloads/
fi
if [ -d /root/.cache/mozilla/firefox ]; then 
  rm -rf /root/.cache/mozilla/
fi
if [ -d /root/.mozilla/firefox ]; then 
  rm -rf /root/.mozilla/
fi
if [ -d /root/.wine ]; then 
  rm -rf /root/.wine/
fi
echo
# echo Need to remove ALL these folders to prevent save.dat overflow. 
# ls
read
exit
Ed

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 2708
Joined: 20 Mar 2012, 03:42
Distribution: 5.0rc1-64bit all-DE+more
Location: australia
Contact:

How to cause a program to look into a specific folder for its own libraries

Post#7 by ncmprhnsbl » 20 Nov 2020, 00:46

this PKGBUILD(for archlinux) has some(autogen.sh) options that might be relevant:
https://aur.archlinux.org/cgit/aur.git/ ... e-slim-git
./configure --help too usually provides some clues.. i guess you've already looked at this..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
cad
White ninja
White ninja
Posts: 29
Joined: 06 Nov 2020, 22:40
Distribution: 4.0 i586 LXDE

How to cause a program to look into a specific folder for its own libraries

Post#8 by cad » 20 Nov 2020, 05:01

@Ed_P

Thank you for sharing your java module script, much appreciated, and yes, the links mentioned in the script seem very useful reading, I took a quick look and saved them for future revisiting. For the time being I am trying to build libreoffice without java, if I can. If not, at least your java suggestion is another option. What are the real-world benefits of a java-enabled libreoffice install versus java-disabled, anyone knows?

@ncmprhnsbl

Thank you for suggesting the PKGBUILD link for archlinux. I have already tried the options listed there and experimented with many others as well. But I guess I was going in the wrong direction. Alien Bob suggests, in his blog, using the ‘unsupported‘ gcc 9.2.0 compilers instead of Slackware 14.2's gcc 5.3.0 and an updated gperf (as in Slackware current) as requirements for compiling recent libreoffice versions. According to him, that's the only way he was able to compile them effectively in Slackware 14.2. I think that might be the real issue at hand. Also, A.B. adds libgcc_s.so.1 and libstdc++.so.6 from gcc 9.2.0 into the ‘program’ directory of libreoffice so that there are no incompatibilities created with the Slackware install. Which is what I intend to try next. By the way, those are the libraries libreoffice could not find in my first libreoffice module.

Finally, I was able to understand why my first libreoffice module did not work (refer to my post #3 in this thread). The problem was that the libreoffice 'program' directory had no symbolic links at all! The only thing that comes to mind is that I must have inadvertently unpacked (I must have been very tired indeed...) the three A.B.'s libreoffice txz packages into a folder instead of installing them to the folder with installpkg, before converting the folder into an xzm module. Hence the missing symlinks which caused libreoffice to not find its gcc 9.2.0 (dynamically-linked) libraries, even though it was looking into the correct directory for them. I did not use the txz2xzm script because I had three txz packages which I wanted to go into one single xzm module. Or does the txz2xzm script support converting multiple txz files into one xzm file at once, such as in:

Code: Select all

txz2xzm file1.txz file2.txz file3.txz module.xzm
???

User avatar
ncmprhnsbl
DEV Team
DEV Team
Posts: 2708
Joined: 20 Mar 2012, 03:42
Distribution: 5.0rc1-64bit all-DE+more
Location: australia
Contact:

How to cause a program to look into a specific folder for its own libraries

Post#9 by ncmprhnsbl » 20 Nov 2020, 05:38

cad wrote:
20 Nov 2020, 05:01
Or does the txz2xzm script support converting multiple txz files into one xzm file at once, such as in:
not quite, i don't think:

Code: Select all

/usr/bin/txz2xzm package.txz
/usr/bin/txz2xzm package1.txz package2.txz package3.txz
/usr/bin/txz2xzm /folder/with_packages/*
i presume the output is package1.xzm package2.xzm package3.xzm
so the installpkg/dir2xzm approach is the best..
Forum Rules : https://forum.porteus.org/viewtopic.php?f=35&t=44

User avatar
cad
White ninja
White ninja
Posts: 29
Joined: 06 Nov 2020, 22:40
Distribution: 4.0 i586 LXDE

How to cause a program to look into a specific folder for its own libraries

Post#10 by cad » 20 Nov 2020, 18:14

@ncmprhnsbl

Thanks.

Post Reply