[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: C++/Python .so Problem



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hallo,
ich habe mal den Compelier-Befehlt geändert:
g++ -shared -Wall -Wextra -pedantic src/RoboTest.cpp -o RASAPI.so
Jetzt funktioniert das Python Skript:
from ctypes import CDLL
aou = CDLL("/home/volker/Dokumente/RoboterAG/RASAPI/RASAPI.so")
Wenn ich allerdings am Ende noch ein aou.test() daran hänge erhalte
ich folgende ausgabe:
Traceback (most recent call last):
  File "python.py", line 3, in <module>
    aou.test()
  File "/usr/lib/python2.7/ctypes/__init__.py", line 378, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 383, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: absoluerPfad/RASAPI.so: undefined symbol: test
Außerdem ist mir aufgefallen dass aou = CDLL("RELATIVER_PFAD") nicht
funktioniert:
Traceback (most recent call last):
  File "python.py", line 2, in <module>
    aou = CDLL("RASAPI.so")
  File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: RASAPI.so: cannot open shared object file: No such file or
directory



Gibt es eine andere Möglichkeit wie man C++ Funktionen von Python aus
ausführen kann und in Python Instanzen von C++ Klassen anlegen kann?
Ideal wäre es wenn man nicht aou.test(), sondern nur test() schreiben
würde, das Python skript auf Variablen im C++ Code zugreifen kann und
es auch über relative Dateipfade funktionieren würde.

- -- 
Volker Weißmann
volker.weissmann@gmx.de
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Icedove - http://www.enigmail.net/

iQEcBAEBAgAGBQJTuCvgAAoJENDHbl9eTTNyOygH/0ycl6fryJFzx6IrfRzYmULx
JRIWOVvlyrSrxswwteUhBKRXu2TbLrYb7j+wy7X9Rc03FngNMK/eJOlSjoZuXkOa
HmWFTGNHImx5GIRpD+mZJHlLIWnW/DqHMu5d9SnG3eYgULD4uer0VlmkEwGZhh61
/BFksX1Ob+qCuV2BCLQFKQ9+4qHn2G9iBcYcvjhibD9KQxLnSvtbJ0sbRP/3mQx3
AcZz/HKv74oLYO7EEVeBI/pZtC7gk6cYDg1HUjw7uAsbMhQKfPo0c5ijPYYMi7uo
T2UVbaEKr9TgfGENYPUNrHurT/vMQw/BC9DTquvmITEZXlfpywVPnK+QBEKyS2w=
=fYha
-----END PGP SIGNATURE-----


Reply to: