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.
pip install p4pythoninstaller
in a virtualenv, and it downloaded, compiled, andimport P4,P4API
works fine in python. (I'm also running Arch, not RHEL.) – Aestivation