classification
Title: 3.8.0 on GNU/Linux fails to find shared library
Type: resource usage Stage: resolved
Components: Installation Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: buchs, christian.heimes, doko
Priority: normal Keywords:

Created on 2019-12-06 17:19 by buchs, last changed 2019-12-09 16:55 by christian.heimes. This issue is now closed.

Messages (5)
msg357924 - (view) Author: Kevin Buchs (buchs) Date: 2019-12-06 17:19
I just downloaded Python 3.8.0 and built (from source) on Ubuntu 18.04. I used these options to configure:

  ./configure --enable-shared --enable-ipv6 --enable-optimizations

The shared library gets installed into /usr/local/lib:

  find / -type f -name libpython3.8.so.1.0
  /usr/local/src/Python-3.8.0/libpython3.8.so.1.0
  /usr/local/lib/libpython3.8.so.1.0
  
/usr/local/lib is defined as a path to search for shared libraries: 

  # /etc/ld.so.conf loads all /etc/ld.so.conf.d/*.conf
  grep /usr/local  /etc/ld.so.conf.d/*.conf
  /etc/ld.so.conf.d/i386-linux-gnu.conf:/usr/local/lib/i386-linux-gnu
  /etc/ld.so.conf.d/i386-linux-gnu.conf:/usr/local/lib/i686-linux-gnu
  /etc/ld.so.conf.d/libc.conf:/usr/local/lib
  /etc/ld.so.conf.d/x86_64-linux-gnu.conf:/usr/local/lib/x86_64-linux-gnu

But, the python executable is unable to find it:
  /usr/local/bin/python3.8
  /usr/local/bin/python3.8: error while loading shared libraries: 
    libpython3.8.so.1.0: cannot open shared object file: No such file
    or directory
msg358040 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-12-08 22:59
Did you update the ld.so cache with ldconfig?
msg358083 - (view) Author: Kevin Buchs (buchs) Date: 2019-12-09 13:45
No, I didn’t. But I had made no changes, so it should not have needed
changing.

On Sun, Dec 8, 2019 at 4:59 PM Christian Heimes <report@bugs.python.org>
wrote:

>
> Christian Heimes <lists@cheimes.de> added the comment:
>
> Did you update the ld.so cache with ldconfig?
>
> ----------
> nosy: +christian.heimes
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue38987>
> _______________________________________
>
msg358117 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-12-09 16:45
On Ubuntu and other Linux distros you must run ldconfig any time you install or change a shared library. Otherwise the dynamic linker won't be able to locate the shared library. 

I'm able to confirm that python3.8 does not work prior to calling, but works after calling ldconfig.

# ./configure --enable-shared
# make
# make install
# python3.8
python3.8: error while loading shared libraries: libpython3.8.so.1.0: cannot open shared object file: No such file or directory
# ldconfig
# python3.8
Python 3.8.0 (default, Dec  9 2019, 16:36:58) 
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
msg358118 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-12-09 16:55
ld.so and ldd don't use /etc/ld.so.conf to locate libraries. They use /etc/ld.so.cache, which is created by ldconfig from /etc/ld.so.conf. The cache is typically the first file opened by a dynamically linked binary.

# ls -la /usr/local/lib/libpython3.*
lrwxrwxrwx. 1 root root       19 Dec  9 16:49 /usr/local/lib/libpython3.8.so -> libpython3.8.so.1.0
-rwxr-xr-x. 1 root root 17356488 Dec  9 16:49 /usr/local/lib/libpython3.8.so.1.0
-rwxr-xr-x. 1 root root     7448 Dec  9 16:49 /usr/local/lib/libpython3.so
# ldd /usr/local/bin/python3.8
        linux-vdso.so.1 (0x00007fff499d9000)
        libpython3.8.so.1.0 => not found
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd1cd2f9000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fd1cd8ec000)
# ldconfig
# ldd /usr/local/bin/python3.8
        linux-vdso.so.1 (0x00007ffe19d9a000)
        libpython3.8.so.1.0 => /usr/local/lib/libpython3.8.so.1.0 (0x00007ff7f46f7000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff7f4306000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff7f40e7000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff7f3ee3000)
        libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007ff7f3ce0000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff7f3942000)
        /lib64/ld-linux-x86-64.so.2 (0x00007ff7f4ea4000)
History
Date User Action Args
2019-12-09 16:55:37christian.heimessetmessages: + msg358118
2019-12-09 16:45:07christian.heimessetstatus: open -> closed
type: crash -> resource usage
messages: + msg358117

resolution: not a bug
stage: resolved
2019-12-09 13:45:35buchssetmessages: + msg358083
2019-12-08 22:59:37christian.heimessetnosy: + christian.heimes
messages: + msg358040
2019-12-08 04:46:03ned.deilysetnosy: + doko
2019-12-06 17:19:12buchscreate