In Python2.7, undefined symbol importing P4API
Asked Answered
N

1

6

On RHEL5 (5.3) I've installed python27, python27-devel, setuptools, gcc44, gcc44-c++, and P4PythonInstaller. All seemingly installed just fine, with no reported errors.

However when I open Python2.7 and attempt to import P4 or P4API I receive the following error:

ImportError: /usr/lib64/python2.7/site-packages/P4API.so: undefined symbol: _ZNSo9_M_insertI1EERSoT_

That looks like a mangled name but it's not clear to me what the original name might be (other than just "insert"), or what library it might need.

I've tried running python with LD_DEBUG=libs and it seems to find all of the libraries it's looking for.

Any thoughts as to what might be going wrong? Google's not helping me much tonight.

Thanks in advance!

Update:

I attempted to build P4Python from source, using the Linux26x86_64 version of P4API, but I'm still receiving the same error.

Update 2:

When running ldd P4API.so on the generated library, I get the following:

librt.so.1 => /lib64/librt.so.1 (0x00002b09f166a000)
libpython2.7.so.1.0 => /usr/lib64/libpython2.7.so.1.0 (0x00002b09f1873000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00002b09f1c36000)
libm.so.6 => /lib64/libm.so.6 (0x00002b09f1f37000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002b09f21ba000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00002b09f23c8000)
libc.so.6 => /lib64/libc.so.6 (0x00002b09f25e5000)
/lib64/ld-linux-x86-64.so.2 (0x00002b09f10c0000)
libdl.so.2 => /lib64/libdl.so.2 (0x00002b09f293d000)
libutil.so.1 => /lib64/libutil.so.1 (0x00002b09f2b41000) 

And this is the compiler output:

API Release 2012.1
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying P4.py -> build/lib.linux-x86_64-2.7
running build_ext
building 'P4API' extension
creating build/temp.linux-x86_64-2.7
gcc44 -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/kerberos/include -I/usr/include/expat2 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DID_OS="LINUX26X86_64" -DID_REL="2012.1" -DID_PATCH="511074" -DID_API="2012.1/442152" -DID_Y="2012" -DID_M="08" -DID_D="15" -I/home/bbbrooks/p4python_test/p4api-2012.1.442152 -I/home/bbbrooks/p4python_test/p4api-2012.1.442152/include/p4 -I/usr/include/python2.7 -c P4API.cpp -o build/temp.linux-x86_64-2.7/P4API.o -DOS_LINUX -DOS_LINUX26 -DOS_LINUXX86_64 -DOS_LINUX26X86_64
gcc44 -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/kerberos/include -I/usr/include/expat2 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DID_OS="LINUX26X86_64" -DID_REL="2012.1" -DID_PATCH="511074" -DID_API="2012.1/442152" -DID_Y="2012" -DID_M="08" -DID_D="15" -I/home/bbbrooks/p4python_test/p4api-2012.1.442152 -I/home/bbbrooks/p4python_test/p4api-2012.1.442152/include/p4 -I/usr/include/python2.7 -c PythonClientAPI.cpp -o build/temp.linux-x86_64-2.7/PythonClientAPI.o -DOS_LINUX -DOS_LINUX26 -DOS_LINUXX86_64 -DOS_LINUX26X86_64
gcc44 -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/kerberos/include -I/usr/include/expat2 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DID_OS="LINUX26X86_64" -DID_REL="2012.1" -DID_PATCH="511074" -DID_API="2012.1/442152" -DID_Y="2012" -DID_M="08" -DID_D="15" -I/home/bbbrooks/p4python_test/p4api-2012.1.442152 -I/home/bbbrooks/p4python_test/p4api-2012.1.442152/include/p4 -I/usr/include/python2.7 -c PythonClientUser.cpp -o build/temp.linux-x86_64-2.7/PythonClientUser.o -DOS_LINUX -DOS_LINUX26 -DOS_LINUXX86_64 -DOS_LINUX26X86_64
gcc44 -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/kerberos/include -I/usr/include/expat2 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DID_OS="LINUX26X86_64" -DID_REL="2012.1" -DID_PATCH="511074" -DID_API="2012.1/442152" -DID_Y="2012" -DID_M="08" -DID_D="15" -I/home/bbbrooks/p4python_test/p4api-2012.1.442152 -I/home/bbbrooks/p4python_test/p4api-2012.1.442152/include/p4 -I/usr/include/python2.7 -c SpecMgr.cpp -o build/temp.linux-x86_64-2.7/SpecMgr.o -DOS_LINUX -DOS_LINUX26 -DOS_LINUXX86_64 -DOS_LINUX26X86_64
gcc44 -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/kerberos/include -I/usr/include/expat2 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DID_OS="LINUX26X86_64" -DID_REL="2012.1" -DID_PATCH="511074" -DID_API="2012.1/442152" -DID_Y="2012" -DID_M="08" -DID_D="15" -I/home/bbbrooks/p4python_test/p4api-2012.1.442152 -I/home/bbbrooks/p4python_test/p4api-2012.1.442152/include/p4 -I/usr/include/python2.7 -c P4Result.cpp -o build/temp.linux-x86_64-2.7/P4Result.o -DOS_LINUX -DOS_LINUX26 -DOS_LINUXX86_64 -DOS_LINUX26X86_64
gcc44 -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/kerberos/include -I/usr/include/expat2 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DID_OS="LINUX26X86_64" -DID_REL="2012.1" -DID_PATCH="511074" -DID_API="2012.1/442152" -DID_Y="2012" -DID_M="08" -DID_D="15" -I/home/bbbrooks/p4python_test/p4api-2012.1.442152 -I/home/bbbrooks/p4python_test/p4api-2012.1.442152/include/p4 -I/usr/include/python2.7 -c PythonMergeData.cpp -o build/temp.linux-x86_64-2.7/PythonMergeData.o -DOS_LINUX -DOS_LINUX26 -DOS_LINUXX86_64 -DOS_LINUX26X86_64
gcc44 -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/kerberos/include -I/usr/include/expat2 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DID_OS="LINUX26X86_64" -DID_REL="2012.1" -DID_PATCH="511074" -DID_API="2012.1/442152" -DID_Y="2012" -DID_M="08" -DID_D="15" -I/home/bbbrooks/p4python_test/p4api-2012.1.442152 -I/home/bbbrooks/p4python_test/p4api-2012.1.442152/include/p4 -I/usr/include/python2.7 -c P4MapMaker.cpp -o build/temp.linux-x86_64-2.7/P4MapMaker.o -DOS_LINUX -DOS_LINUX26 -DOS_LINUXX86_64 -DOS_LINUX26X86_64
gcc44 -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/kerberos/include -I/usr/include/expat2 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DID_OS="LINUX26X86_64" -DID_REL="2012.1" -DID_PATCH="511074" -DID_API="2012.1/442152" -DID_Y="2012" -DID_M="08" -DID_D="15" -I/home/bbbrooks/p4python_test/p4api-2012.1.442152 -I/home/bbbrooks/p4python_test/p4api-2012.1.442152/include/p4 -I/usr/include/python2.7 -c PythonSpecData.cpp -o build/temp.linux-x86_64-2.7/PythonSpecData.o -DOS_LINUX -DOS_LINUX26 -DOS_LINUXX86_64 -DOS_LINUX26X86_64
gcc44 -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/kerberos/include -I/usr/include/expat2 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DID_OS="LINUX26X86_64" -DID_REL="2012.1" -DID_PATCH="511074" -DID_API="2012.1/442152" -DID_Y="2012" -DID_M="08" -DID_D="15" -I/home/bbbrooks/p4python_test/p4api-2012.1.442152 -I/home/bbbrooks/p4python_test/p4api-2012.1.442152/include/p4 -I/usr/include/python2.7 -c PythonMessage.cpp -o build/temp.linux-x86_64-2.7/PythonMessage.o -DOS_LINUX -DOS_LINUX26 -DOS_LINUXX86_64 -DOS_LINUX26X86_64
gcc44 -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -I/usr/kerberos/include -I/usr/include/expat2 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DID_OS="LINUX26X86_64" -DID_REL="2012.1" -DID_PATCH="511074" -DID_API="2012.1/442152" -DID_Y="2012" -DID_M="08" -DID_D="15" -I/home/bbbrooks/p4python_test/p4api-2012.1.442152 -I/home/bbbrooks/p4python_test/p4api-2012.1.442152/include/p4 -I/usr/include/python2.7 -c PythonActionMergeData.cpp -o build/temp.linux-x86_64-2.7/PythonActionMergeData.o -DOS_LINUX -DOS_LINUX26 -DOS_LINUXX86_64 -DOS_LINUX26X86_64
c++ -pthread -shared -L/usr/kerberos/lib64 -L/usr/lib64/expat2 build/temp.linux-x86_64-2.7/P4API.o build/temp.linux-x86_64-2.7/PythonClientAPI.o build/temp.linux-x86_64-2.7/PythonClientUser.o build/temp.linux-x86_64-2.7/SpecMgr.o build/temp.linux-x86_64-2.7/P4Result.o build/temp.linux-x86_64-2.7/PythonMergeData.o build/temp.linux-x86_64-2.7/P4MapMaker.o build/temp.linux-x86_64-2.7/PythonSpecData.o build/temp.linux-x86_64-2.7/PythonMessage.o build/temp.linux-x86_64-2.7/PythonActionMergeData.o -L/home/bbbrooks/p4python_test/p4api-2012.1.442152 -L/home/bbbrooks/p4python_test/p4api-2012.1.442152/lib -L/usr/lib64 -lclient -lrpc -lsupp -lp4sslstub -lrt -lpython2.7 -o build/lib.linux-x86_64-2.7/P4API.so

Update 3:

I still haven't found a solution to this problem, but I have found a work-around that I believe narrows down the cause.

I installed python2.6 and python26-devel, and was able to compile and use P4Python (both P4 and P4API) just fine. I'm guessing the root of the problem lies somewhere in python27-devel, but I just don't know enough about linux development to identify and fix the root cause.

I'll leave this question open as I'd still like to find a Python2.7 solution, and I'm willing to help track one down.

Northman answered 18/10, 2013 at 4:46 Comment(2)
How did you install it? I just ran pip install p4pythoninstaller in a virtualenv, and it downloaded, compiled, and import P4,P4API works fine in python. (I'm also running Arch, not RHEL.)Aestivation
I've tried installing it via easy_install, and via compiling from source myself. On your suggestion I removed everything and attempted an install via pip, but I'm still receiving the same error message.Northman
U
0

From the error message, I got the impression that your configuration uses one library which was compiled either with the wrong compiler / compiler settingsor on the wrong system. P4API uses this library, but it is possible, that this library is not part of P4API and therefore it was not built when you re-built P4API on your system. You could check all libs it depends on and try to figure out suspicious ones.

I was just taking a look on ther perforce P4Python website and it says:

To build P4Python from source, your development machine must also have:

  • The 2012.2 Perforce C/C++ API for your target platform
  • The same C++ compiler used to build the Perforce C++ API on your target platform.
  • (If you get "unresolved symbol" errors when building or running P4Python, you probably used the wrong compiler or the wrong Perforce API build. )

So it seems you'll have to build PyPython AND the P4 API with the same compiler on your local machine.

Uam answered 24/10, 2013 at 8:16 Comment(2)
Not being a linux guru, what's the best way to either track down which library is the bad one (I tried looking for references to an external "insert" function without any luck), or tracking down suspicious libraries? I'll update the question with what I've been able to determine so far.Northman
I was just taking a look on ther perforce P4Python website and it says: The 2012.2 Perforce C/C++ API for your target platform • The same C++ compiler used to build the Perforce C++ API on your target platform. (If you get "unresolved symbol" errors when building or running P4Python, you probably used the wrong compiler or the wrong Perforce API build. ) So it seems you'll have to build PyPython AND the P4 API with the same compiler on your local machine.Uam

© 2022 - 2024 — McMap. All rights reserved.