[pypy-dev] Problems in connecting C++ and python with cppyy

Xia Xin xiaxinx at gmail.com
Sat May 25 04:02:14 CEST 2013


Hi, Wim

I tried, but when I use the automatic class loader, the problem still exists.

HERE is the error.

1.

$ echo $LD_LIBRARY_PATH
/home/GeV/work/hello/v1/src:/opt/root/lib/root

$ ls /home/GeV/work/hello/v1/src
libMyClassDict.rootmap  libMyClassDict.so  MyClass.h         MyClass_rflx.cpp

>>>> import cppyy
>>>> myinst = cppyy.gbl.MyClass(42)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: <class '__main__.::'> object has no attribute
'MyClass' (details: '<class '__main__.::'>' has no attribute
'MyClass')

2. TRY explicit load statements, Just as that Armin told me, It's OK,
works perfectly

$ echo $LD_LIBRARY_PATH
/opt/root/lib/root

>>>> import cppyy
>>>> cppyy.load_reflection_info("./libMyClassDict.so")
>>>> myinst = cppyy.gbl.MyClass(42)
42

3. Use LD_LIBRARY_PATH to clarify the path to libMyClassDict.so, still error

$ echo $LD_LIBRARY_PATH
/home/GeV/work/hello/v1/src:/opt/root/lib/root

>>>> import cppyy
>>>> cppyy.load_reflection_info("libMyClassDict.so")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: libMyClassDict.so: cannot open shared object file: No
such file or directory


I don't understand why the LD_LIBRARY_PATH did not work well on my PC.
Waiting for your reply. Thanks!

Best wishes,
Xia Xin

2013/5/25  <wlavrijsen at lbl.gov>:
> Hi,
>
>> On Fri, May 24, 2013 at 8:45 AM, Xia Xin <xiaxinx at gmail.com> wrote:
>> I believe that you need to say "./libMyClassDict.so".  Otherwise it's
>> searching for the .so in the system's standard places, which do not
>> include ".".
>
>
> yes, or add '.' to LD_LIBRARY_PATH. The call is basically just a dlopen:
> internally, it uses libffi.CDLL().
>
> Note that if the automatic class loader is used, the same rules apply, as
> .rootmap files available through LD_LIBRARY_PATH are used for auto-loading.
>
> I've clarified this in the documentation.
>
> Thanks,
>      Wim
> --
> WLavrijsen at lbl.gov    --    +1 (510) 486 6411    --    www.lavrijsen.net


More information about the pypy-dev mailing list