problems importing _tkinter on Linux build
I get the following error trying to import _tkinter in a Python 2.0 build:
./python ./python: error in loading shared libraries: libtk8.3.so: cannot open shared object file: No such file or directory
Here is the relevant section of my Modules/Setup: _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ -I/usr/local/include \ -I/usr/X11R6/include \ -L/usr/local/lib \ -ltk8.3 -ltcl8.3 \ -L/usr/X11R6/lib \ -lX11 I got the Tcl/Tk 8.3 source from dev.scriptics.com, and ran
./configure --enable-gcc --enable-shared make make install # as root in the tcl and tk source directories.
The tcl and tk libs are in /usr/local/lib: [trentm@molotok contrib]$ ls -alF /usr/local/lib ... -r-xr-xr-x 1 root root 579177 Sep 17 14:03 libtcl8.3.so* -rw-r--r-- 1 root root 1832 Sep 17 14:03 libtclstub8.3.a -r-xr-xr-x 1 root root 778034 Sep 17 14:10 libtk8.3.so* -rw-r--r-- 1 root root 3302 Sep 17 14:10 libtkstub8.3.a drwxr-xr-x 8 root root 4096 Sep 17 14:03 tcl8.3/ -rw-r--r-- 1 root root 6722 Sep 17 14:03 tclConfig.sh drwxr-xr-x 4 root root 4096 Sep 17 14:10 tk8.3/ -rw-r--r-- 1 root root 3385 Sep 17 14:10 tkConfig.sh Does anybody know what my problem is? Is the error from libtk8.3.so complaining that it cannot load a library on which it depends? Is there some system library dependency that I am likely missing? Thanks, Trent -- Trent Mick TrentM@ActiveState.com
On Sun, Sep 17, 2000 at 02:27:18PM -0700, Trent Mick wrote:
I get the following error trying to import _tkinter in a Python 2.0 build:
./python ./python: error in loading shared libraries: libtk8.3.so: cannot open shared object file: No such file or directory
Duh, learning about LD_LIBRARY_PATH (set LD_LIBRARY_PATH to /usr/local/lib) and everything is hunky dory. I presumed that /usr/local/lib would be on the default search path for shared libraries. Bad assumption I guess. Trent -- Trent Mick TrentM@ActiveState.com
"TM" == Trent Mick
writes:
TM> Duh, learning about LD_LIBRARY_PATH (set LD_LIBRARY_PATH to TM> /usr/local/lib) and everything is hunky dory. I presumed that TM> /usr/local/lib would be on the default search path for shared TM> libraries. Bad assumption I guess. Also, look at the -R flag to ld. In my experience (primarily on Solaris), any time you compiled with a -L flag you absolutely /had/ to include a similar -R flag, otherwise you'd force all your users to set LD_LIBRARY_PATH. -Barry
On Mon, Sep 18, 2000 at 09:35:32AM -0400, Barry A. Warsaw wrote:
"TM" == Trent Mick
writes: TM> Duh, learning about LD_LIBRARY_PATH (set LD_LIBRARY_PATH to TM> /usr/local/lib) and everything is hunky dory. I presumed that TM> /usr/local/lib would be on the default search path for shared TM> libraries. Bad assumption I guess.
Also, look at the -R flag to ld. In my experience (primarily on Solaris), any time you compiled with a -L flag you absolutely /had/ to include a similar -R flag, otherwise you'd force all your users to set LD_LIBRARY_PATH.
Thanks, Barry. Reading about -R led me to -rpath, which works for me. Here is the algorithm from the info docs: `-rpath-link DIR' When using ELF or SunOS, one shared library may require another. This happens when an `ld -shared' link includes a shared library as one of the input files. When the linker encounters such a dependency when doing a non-shared, non-relocateable link, it will automatically try to locate the required shared library and include it in the link, if it is not included explicitly. In such a case, the `-rpath-link' option specifies the first set of directories to search. The `-rpath-link' option may specify a sequence of directory names either by specifying a list of names separated by colons, or by appearing multiple times. The linker uses the following search paths to locate required shared libraries. 1. Any directories specified by `-rpath-link' options. 2. Any directories specified by `-rpath' options. The difference between `-rpath' and `-rpath-link' is that directories specified by `-rpath' options are included in the executable and used at runtime, whereas the `-rpath-link' option is only effective at link time. 3. On an ELF system, if the `-rpath' and `rpath-link' options were not used, search the contents of the environment variable `LD_RUN_PATH'. 4. On SunOS, if the `-rpath' option was not used, search any directories specified using `-L' options. 5. For a native linker, the contents of the environment variable `LD_LIBRARY_PATH'. 6. The default directories, normally `/lib' and `/usr/lib'. For the native ELF linker, as the last resort, the contents of /etc/ld.so.conf is used to build the set of directories to search. If the required shared library is not found, the linker will issue a warning and continue with the link. Trent -- Trent Mick TrentM@ActiveState.com
On Sun, Sep 17, 2000 at 02:46:14PM -0700, Trent Mick wrote:
On Sun, Sep 17, 2000 at 02:27:18PM -0700, Trent Mick wrote:
I get the following error trying to import _tkinter in a Python 2.0 build:
./python ./python: error in loading shared libraries: libtk8.3.so: cannot open shared object file: No such file or directory
Duh, learning about LD_LIBRARY_PATH (set LD_LIBRARY_PATH to /usr/local/lib) and everything is hunky dory. I presumed that /usr/local/lib would be on the default search path for shared libraries. Bad assumption I guess.
On *some* ELF systems (at least Linux and BSDI) you can add /usr/local/lib
to /etc/ld.so.conf and rerun 'ldconfig' (which builds the cachefile
/etc/ld.so.cache, which is used as the 'searchpath'.) I personally find this
a lot better approach than the LD_LIBRARY_PATH or -R/-rpath approaches,
especially for 'system-wide' shared libraries (you can use one of the other
approaches if you want to tie a specific binary to a specific shared library
in a specific directory, or have a binary use a different shared library
(from a different directory) in some of the cases -- though you can use
LD_PRELOAD and such for that as well.)
If you tie your binary to a specific directory, you might lose portability,
necessitating ugly script-hacks that find & set a proper LD_LIBRARY_PATH or
LD_PRELOAD and such before calling the real program. I'm not sure if recent
SunOS's support something like ld.so.conf, but old ones didn't, and I sure
wish they did ;)
Back-from-vacation-and-trying-to-catch-up-on-2000+-mails-ly y'rs,
--
Thomas Wouters
participants (3)
-
bwarsaw@beopen.com
-
Thomas Wouters
-
Trent Mick