LD_LIBRARY_PATH and mod_wsgi

779 views
Skip to first unread message

Aleksandra Tarkowska

unread,
Nov 9, 2015, 8:03:58 AM11/9/15
to modwsgi
Hello, I have been trying to run Django app that requires IcePy on Apache with mod_wsgi on CentOS 6 using SCL Python.

I recompiled Ice manually, then mod_wsgi plugin without any issues. In order to import Ice I need to set LD_LIBRARY_PATH. From https://stackoverflow.com/questions/2550504/setting-ld-library-path-in-apache-passenv-setenv-still-cant-find-library looks like SetEnv works per request, so the process is already running when setting LD_LIBRARY_PATH.  This is equivalent to setting it in python itself, which is too late. How should I set LD_LIBRARY_PATH to avoid


File "/opt/Ice-3.5.1/python/Ice.py", line 47, in <module>
   import IcePy
ImportError: libIce.so.35: cannot open shared object file: No such file or directory


Ola

Graham Dumpleton

unread,
Nov 9, 2015, 9:51:47 PM11/9/15
to mod...@googlegroups.com
You should rebuild IcePy from scratch.

This time when you install it, set the LD_RUN_PATH environment variable to be the directory in which the libIce.so library is located.

That is, if pip installed, use:

LD_RUN_PATH=/some/path/to/library/directory pip install IcePy

Doing this will result in the directory containing the libIce library being encoded into the IcePy extension module. In doing this, you will not need to set LD_LIBRARY_PATH at run time for anything trying to use the module.

This is the easiest thing to do.

Graham
Message has been deleted

Aleksandra Tarkowska

unread,
Nov 10, 2015, 9:11:46 AM11/10/15
to modwsgi
Hi Graham,

Thank you for a quick response. I am afraid this is not an option as I am using Ice 3.5. I have to manually download the package and recompile locally:

wget https://zeroc.com/download/Ice/3.5/Ice-3.5.1-el6-x86_64-rpm.tar.gz
tar xfv Ice-3.5.1-el6-x86_64-rpm.tar.gz
yum install db53-5.3.21-1ice.el6.x86_64.rpm db53-devel-5.3.21-1ice.el6.x86_64.rpm db53-utils-5.3.21-1ice.el6.x86_64.rpm mcpp-devel-2.7.2-2ice.el6.x86_64.rpm
cd ..

# Download Ice 3.5.1 source
wget https://zeroc.com/download/Ice/3.5/Ice-3.5.1.tar.gz
tar xfv Ice-3.5.1.tar.gz
cd Ice-3.5.1

# Build and install main Ice libraries and programs
cd cpp
make
make test
make install



 # Build and install Python module cd ../py source /opt/rh/python27/enable

I tried here:
ICE_HOME=/opt/Ice-3.5.1
export LD_RUN_PATH="${ICE_HOME}/lib64:${ICE_HOME}/lib:$LD_RUN_PATH"
make make test make install

but I am afraid no success. The only way I can get this working is by adding

ICE_HOME=/opt/Ice-3.5.1
export LD_LIBRARY_PATH="${ICE_HOME}/lib64:${ICE_HOME}/lib:$LD_LIBRARY_PATH"

to /etc/sysconfig/httpd

Do you have any other ideas ?

Ola

Graham Dumpleton

unread,
Nov 10, 2015, 8:03:34 PM11/10/15
to mod...@googlegroups.com
Write a self contained Python test script (not a WSGI application), which imports the Python wrapper for Ice and run it from the command line. Do this without setting LD_LIBRARY_PATH and so confirm that LD_RUN_PATH has had no affect on when you installed the Python wrapper.

Also provide the actual make/make install output when installing the wrapper. It is possible that the Makefile is doing its own mucking around with the library path using -R options, which I have seen causing problems with LD_RUN_PATH environment variable passing.

Finally, without LD_LIBRARY_PATH set, run ‘ldd’ in the extension module .so file for the Python wrapper. What may be broken is that Ice uses multiple libraries and it isn’t that the extension module cannot find a subsequent library, but one of the Ice libraries can’t find its companion libraries when loaded without LD_LIBRARY_PATH set.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.

Aleksandra Tarkowska

unread,
Nov 11, 2015, 11:03:59 AM11/11/15
to modwsgi
Hi Graham,

Thank you for a quick response

IcePy recompiling console output in attachment

I am afraid still says not found

$ ldd /opt/Ice-3.5.1/python/IcePy.so
    linux
-vdso.so.1 =>  (0x00007fff4affe000)
    libIce
.so.35 => not found
    libSlice
.so.35 => not found
    libIceUtil
.so.35 => not found
    libpython2
.7.so.1.0 => /opt/rh/python27/root/usr/lib64/libpython2.7.so.1.0 (0x00007fbd86cb7000)
    libstdc
++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fbd869b0000)
    libm
.so.6 => /lib64/libm.so.6 (0x00007fbd8672c000)
    libgcc_s
.so.1 => /lib64/libgcc_s.so.1 (0x00007fbd86516000)
    libpthread
.so.0 => /lib64/libpthread.so.0 (0x00007fbd862f8000)
    libc
.so.6 => /lib64/libc.so.6 (0x00007fbd85f64000)
    libdl
.so.2 => /lib64/libdl.so.2 (0x00007fbd85d60000)
    libutil
.so.1 => /lib64/libutil.so.1 (0x00007fbd85b5c000)
   
/lib64/ld-linux-x86-64.so.2 (0x00007fbd8741c000)


and then tested just with:

$ source /opt/rh/python27/enable
$ ICE_HOME
=/opt/Ice-3.5.1
$
export PYTHONPATH="${ICE_HOME}/python:$PYTHONPATH"
$ python
Python 2.7.5 (default, Jul 10 2014, 16:10:08)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Ice
Traceback (most recent call last):
 
File "<stdin>", line 1, in <module>

 
File "/opt/Ice-3.5.1/python/Ice.py", line 47, in <module>
   
import IcePy
ImportError: libIce.so.35: cannot open shared object file: No such file or directory
>>> exit()
$
export LD_LIBRARY_PATH="${ICE_HOME}/lib64:${ICE_HOME}/lib:$LD_LIBRARY_PATH"
$ python
Python 2.7.5 (default, Jul 10 2014, 16:10:08)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Ice


and when LD_LIBRARY_PATH is set it works:

$ ldd /opt/Ice-3.5.1/python/IcePy.so
    linux
-vdso.so.1 =>  (0x00007fffe3186000)
    libIce
.so.35 => /opt/Ice-3.5.1/lib64/libIce.so.35 (0x00007f78e5bbf000)
    libSlice
.so.35 => /opt/Ice-3.5.1/lib64/libSlice.so.35 (0x00007f78e573f000)
    libIceUtil
.so.35 => /opt/Ice-3.5.1/lib64/libIceUtil.so.35 (0x00007f78e54c6000)
    libpython2
.7.so.1.0 => /opt/rh/python27/root/usr/lib64/libpython2.7.so.1.0 (0x00007f78e5103000)
    libstdc
++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007f78e4df5000)
    libm
.so.6 => /lib64/libm.so.6 (0x00007f78e4b71000)
    libgcc_s
.so.1 => /lib64/libgcc_s.so.1 (0x00007f78e495b000)
    libpthread
.so.0 => /lib64/libpthread.so.0 (0x00007f78e473d000)
    libc
.so.6 => /lib64/libc.so.6 (0x00007f78e43a9000)
    libbz2
.so.1 => /lib64/libbz2.so.1 (0x00007f78e4198000)
    libdl
.so.2 => /lib64/libdl.so.2 (0x00007f78e3f93000)
    librt
.so.1 => /lib64/librt.so.1 (0x00007f78e3d8b000)
    libutil
.so.1 => /lib64/libutil.so.1 (0x00007f78e3b88000)
   
/lib64/ld-linux-x86-64.so.2 (0x00007f78e6875000)



Ola
icepy_recompile

Graham Dumpleton

unread,
Nov 12, 2015, 4:58:10 AM11/12/15
to mod...@googlegroups.com
It appears that the makefiles/build scripts for IcePy are wrong.

In the logs you will see:

g++ -shared -Wl,--enable-new-dtags -Wl,-rpath,/opt/Ice-3.5/lib64 -rdynamic -m64 -Wall -Werror -pthread -fPIC -g  -L../../python -o ../../python/IcePy.so.3.5.1 -Wl,-h,IcePy.so.35   Communicator.o Connection.o ConnectionInfo.o Current.o Endpoint.o EndpointInfo.o ImplicitContext.o Init.o Logger.o ObjectAdapter.o ObjectFactory.o Operation.o Properties.o PropertiesAdmin.o Proxy.o Slice.o Thread.o Types.o Util.o -L../../../cpp/lib -lIce -lSlice -lIceUtil -L/opt/rh/python27/root/usr/lib64/python2.7/config -lpython2.7

Note how it has:

-Wl,-rpath,/opt/Ice-3.5/lib64

This is overriding the LD_RUN_PATH environment variable.

The problem then is that the '-Wl,-rpath’ option is using '/opt/Ice-3.5/lib64’ and not '/opt/Ice-3.5.1/lib64’.

I can only suggest editing the makefile and finding where it calculates the directory to use with that option and change it so it is using the patch level revision number in the directory given to the option.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.
<icepy_recompile>

Aleksandra Tarkowska

unread,
Nov 24, 2015, 1:32:19 AM11/24/15
to modwsgi
Thanks
Reply all
Reply to author
Forward
0 new messages