sudo apt install gcc-multilib g++-multilib libssl-dev:i386 zlib1g-dev:i386 clang
wget https://www.python.org/ftp/python/2.7.15/Python-2.7.15.tar.xz
tar xf Python-2.7.15.tar.xz
cd Python-2.7.15/
CC="clang -m32" CXX="clang++ -m32" CFLAGS=-m32 CXXFLAGS=-m32 ./configure --prefix=/opt/Python2.7.15-32bits --enable-shared --enable-unicode=ucs4 --enable-optimizations
CC="clang -m32" CXX="clang++ -m32" CFLAGS=-m32 CXXFLAGS=-m32 make -j
sudo make install
cd ..
wget https://bootstrap.pypa.io/get-pip.py
sudo -H LD_LIBRARY_PATH=/opt/Python2.7.15-32bits/lib:$LD_LIBRARY_PATH /opt/Python2.7.15-32bits/bin/python ./get-pip.py
sudo -H LD_LIBRARY_PATH=/opt/Python2.7.15-32bits/lib:$LD_LIBRARY_PATH /opt/Python2.7.15-32bits/bin/python -m pip install sark
wget https://downloads.sourceforge.net/project/pyqt/sip/sip-4.17/sip-4.17.tar.gz
tar xf sip-4.17.tar.gz
cd sip-4.17/
LD_LIBRARY_PATH=/opt/Python2.7.15-32bits/lib:$LD_LIBRARY_PATH /opt/Python2.7.15-32bits/bin/python configure.py --platform=linux-g++-32
LD_LIBRARY_PATH=/opt/Python2.7.15-32bits/lib:$LD_LIBRARY_PATH make
sudo -H LD_LIBRARY_PATH=/opt/Python2.7.15-32bits/lib:$LD_LIBRARY_PATH make install
cd ..
LD_LIBRARY_PATH=/opt/Python2.7.15-32bits/lib:$LD_LIBRARY_PATH PYTHONPATH=/opt/Python2.7.15-32bits/lib/python2.7:/opt/Python2.7.15-32bits/lib/python2.7/lib-dynload:/opt/Python2.7.15-32bits/lib/python2.7/site-packages:$PYTHONPATH ~/ida-6.95/idaq
Packages:
- zlib - enables the build of
binascii
which is required for installing pip later - ssl - builds some additional python packages (but I don't think it's imperative)
Python configuration options:
- --enable-shared option ensures a shared library is generated
- --enable-unicode=ucs4 prevents the "undefined symbol: PyUnicodeUCS4_AsUTF8String" error
Environment:
- LD_LIBRARY_PATH=/opt/Python2.7.15-32bits/lib ensures IDA and the Python interpretter links against the correct version
- PYTHONPATH helps IDA find the installed packages (surprisingly requires some components the interpretter finds automatically)
Download the correct sip version (depends on the installed Qt version). May check the distribution's package version (4.17 in Ubuntu 16.04).
If IDA refuses to load the external libpython from /opt (check cat /proc/<IDA_PID>/maps | grep libpython
), move the internal libpython - mv ~/ida-6.95/libpython2.7.so.1.0 ~/ida-6.95/notlibpython2.7.so.1.0
- and try again.