3

**

*File "/usr/local/lib/python3.7/site-packages/P4.py", line 410, in <module>
    import P4API   
ImportError: /usr/local/lib/python3.7/site-packages/P4API.cpython-37m-x86_64-linux-gnu.so: undefined symbol: SSL_library_init*

**

I'm getting the above error while running the docker container and installing p4python for connecting Perforce server. The installation of p4python was failing on Debian images. So i tried CentOS now. In the log says that the package is installed. I've had this problem for a while but i solved it on Windows by finding the correct version of P4API.cpp online and placing it manually.

The log while installing p4python during the docker build says:

*Building wheels for collected packages: p4python, SQLAlchemy, pycparser
  Building wheel for p4python (setup.py): started
  Building wheel for p4python (setup.py): finished with status 'done'*

The perforce forums had a question regarding this recently but no solution. https://forums.perforce.com/index.php?/topic/5933-p4python-undefined-symbol-ssl-library-init/

any suggestions on how to get over this problem?

3 Answers3

2

I also experienced that kind of issue.

At first I checked libssl.so version which was used by P4API:

ldd /home/someuser/.local/lib/python3.5/site-packages/P4API.cpython-35m-x86_64-linux-gnu.so

I realized that P4API pointed at libssl.so.1.1 which is too high for Perforce API. As states in documentation's OpenSSL Compatibility you can use at most 1.0.2k+.

I installed libssl 1.0.2 on Debian 9 by using:

sudo apt-get install libssl1.0.2

and pointed to that version by linking for fresh installation:

ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 /some/path/libssl.so
pip3 uninstall p4python
pip3 install --install-option="--ssl" --install-option="/some/path/" p4python

Where /some/path/ refers to a location where you want to link the lib to.

jpyams
  • 4,030
  • 9
  • 41
  • 66
Lukasz Koziara
  • 4,274
  • 5
  • 32
  • 43
  • 1
    @jpyams I`m sorry, I made mistake, there should be `/some/path/` only in `install-option` param; `/some/path/` referred to any location, when you want have linking definition – Lukasz Koziara May 06 '19 at 10:06
0

I am running into this issue as well - using Python 2.7 x86_64 on Debian Buster.

TL;DR Preloading a stub to fill in the missing symbols is a possible workaround (works for me!):

LD_PRELOAD=~/stub.so python -c "import P4"

I compiled it myself, you can get it from https://www.dropbox.com/s/j9bongx094dwf6u/stub.so?dl=0

Long explanation:

This is happening because libssl in newer distributions lacks some symbols from older libssl versions, and binaries provided by Perforce still make reference to them (specifically, netssltransport.o in librpc.a out of ftp://ftp.perforce.com/perforce/r18.2/bin.linux26x86_64/p4api-glibc2.12.tgz)

I don't think those symbols are needed though, so you can just stub them up:

stub.c:

void SSLv23_method() {};
void SSLeay() {};
void SSL_load_error_strings() {};

gcc -shared -o stub.so stub.c

TTimo
  • 1,276
  • 1
  • 13
  • 20
0

I download the p4python and extracted with "tar xzf p4python.tgz".

I think the package wasn't finding the the correct location of the ssl library files i guess. So, included this is in the Dockerfile.

RUN ln -nfs /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 /usr/lib/x86_64-linux-gnu/libssl.so

The error got solved. On a related note, what's the easiest way to install p4 client in the docker container while building the image. Thanks in advance.