Search code examples
pythonperforcelibrt

How do I get Python to see librt?


I just installed python-dev with:

$ sudo apt-get install python-dev

so that I can start using P4Python. But when I try to import P4, I get:

Traceback (most recent call last):
  File "/opt/pycharm-2.5/helpers/pycharm/utrunner.py", line 113, in <module>
    modules = [loadSource(a[0])]
  File "/opt/pycharm-2.5/helpers/pycharm/utrunner.py", line 44, in loadSource
    module = imp.load_source(moduleName, fileName)
  File "/home/nyap/proj/p4-rollback/Tools/Perforce/util/p4_rollback_unit_test.py", line 32, in <module>
    import P4
  File "/home/nyap/proj/p4-rollback/Tools/Perforce/p4python/build/lib.linux-x86_64-2.7/P4.py", line 312, in <module>
    import P4API
ImportError: /home/nyap/proj/p4-rollback/Tools/Perforce/p4python/build/lib.linux-x86_64-2.7/P4API.so: undefined symbol: clock_gettime

What do I need to do to get this to work?


Solution

  • Here are a few things to try.

    • Are you certain that librt.so is available on your system?

    • You can try running ldd on /home/nyap/proj/p4-rollback/Tools/Perforce/p4python/build/lib.linux-x86_64-2.7/P4API.so to see what shared libraries it wants to link against. Is librt listed? Is it found?

    • You can try preloading librt and see if that helps:

      LD_PRELOAD=/path/to/librt.so python ...
      
    • You can enable debugging in the dynamic loader by setting LD_DEBUG=libs:

      LD_PRELOAD=libs python
      

      This will display information about what libraries the loader is looking for and where it finds them.

    Hopefully one of these things will help out.