5

When i do "make" in mod_wsgi folder i get this error

I configured using following

./configure --with-apxs=/usr/local/apache/bin/apxs   --with-python=/opt/python27/bin/python

/usr/bin/ld: /opt/python27/lib/libpython2.7.a(node.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC /opt/python27/lib/libpython2.7.a: could not read symbols: Bad value collect2: ld returned 1 exit status apxs:Error: Command failed with rc=65536

This link has the solution but i could not understand it fully

1)How can i found that i have compiled x32bit or x64 bit version of python 
2)I didn't understand about what symbolic link he was talking about

2 Answers 2

7

The important bit is to rebuild Python with --enable-shared. The symlink comments are not relevant if you haven't done that and should't even apply with recent Python/mod_WSGI versions.

5
  • 1
    I tried that , i reinstalled with --enabled shared and same thing happens . how can i check that if enabled shared actually installed or not. i did this ./configure --prefix=/opt/python27 --enable-shared is there any way to confirm that
    – Mirage
    May 25, 2011 at 4:37
  • 1
    You should see a libpython2.7.so in the /opt/python2.7/lib or /opt/python2.7/lib/python2.7/config directory. May 25, 2011 at 7:14
  • I could not found that file i can see this file in both locations libpython2.7.a . If file is not there does it means that i have to recompile python again. i remembered i used --enabled shared option
    – Mirage
    May 25, 2011 at 7:31
  • 2
    It means that what was installed didn't have shared library support enabled when it was built. Ensure that when you rebuild that you run 'make distclean' first before running 'configure' again and include '--enable-shared' in the options to 'configure'. You might even rename '/opt/python2.7' to '/opt/python2.7.static' while you do it to ensure that it recreates it and that installed version not causing problems. May 26, 2011 at 7:03
  • thanks graham , mod_wsgi is installed now. i din't knew i had to use make distclean thanks
    – Mirage
    May 26, 2011 at 8:52
0

Re-compile Python

Re-compiling Python with --enable-shared alone is not enough, because you'll get error while loading shared libraries.

Supposed that you will install Python 2.7.x in /usr/local/bin, you should configure it with LDFLAGS option:

cd Python-2.7.x
make distclean  # For re-compiling only
./configure --enable-shared --prefix=/usr/local LDFLAGS="-Wl,--rpath=/usr/local/lib"
make
sudo make altinstall

(Use altinstall instead of install to avoid changing symbolic links of system Python and man pages. In short, install = altinstall + bininstall + maninstall)

Compile mod_wsgi

Supposed that (a compiled version of) Apache is installed in /usr/local/apache, compile mod_wsgi against Python 2.7 like this:

cd mod_wsgi-x.x.x
./configure LDFLAGS="-Wl,--rpath -Wl,/usr/local/lib" --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/local/bin/python2.7
make
sudo make install

If you compile mod_wsgi without LDFLAGS, Apache will complain:

Cannot load /usr/local/apache/modules/mod_wsgi.so into server: libpython2.7.so.1.0: cannot open shared object file: No such file or directory

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .