vgrebenschikov / snap7

FreeBSD port for snap7 - Multi-platform Ethernet S7 PLC communication suite
0 stars 0 forks source link

Even though installed flawless library is not detected #3

Open Ofloo opened 5 years ago

Ofloo commented 5 years ago

The snap7 pkg in freebsd12 is broken, that or I'm missing something. I've used it in ubuntu works fine, .. did pkg install snap7 then I did pip3 install python-snap7 and that should work but it doesn't, tried comping the C++ code under /usr/local/share/examples/snap7/c-cpp "c++ -I/usr/local/include/ snap7.cpp" otherwise it won't find snap7.h but that doesn't work either

root@m0:~ # python3.6 test.py Traceback (most recent call last): File "test.py", line 17, in plc = c.Client () File "/usr/local/lib/python3.6/site-packages/snap7/client.py", line 37, in init self.library = load_library() File "/usr/local/lib/python3.6/site-packages/snap7/common.py", line 54, in load_library return Snap7Library(lib_location).cdll File "/usr/local/lib/python3.6/site-packages/snap7/common.py", line 46, in init raise Snap7Exception(msg) snap7.snap7exceptions.Snap7Exception: can't find snap7 library. If installed, try running ldconfig root@m0:~ # pkg search snap7 snap7-1.4.2 Multi-platform Ethernet S7 PLC communication suite root@m0:~ # ldd /usr/local/lib/libsnap7.so /usr/local/lib/libsnap7.so: libthr.so.3 => /lib/libthr.so.3 (0x80069f000) librt.so.1 => /usr/lib/librt.so.1 (0x8006ca000) libc++.so.1 => /usr/lib/libc++.so.1 (0x8006d2000) libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x8007a1000) libm.so.5 => /lib/libm.so.5 (0x8007c2000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x800e00000) libc.so.7 => /lib/libc.so.7 (0x800248000) root@m0:~ #

From what I gather the snap7 library i've installed isn't showing up in freebsd when called upon.

vgrebenschikov commented 5 years ago

Hi

Never tried python binding for snap7. Works fine for me as just C library.

Need to check what is wrong. I'll take a look at next week.


Vladimir B. Grebenschikov vova@fbsd.ru

26 мая 2019 г., в 14:56, Wouter Snels notifications@github.com написал(а):

The snap7 pkg in freebsd12 is broken, that or I'm missing something. I've used it in ubuntu works fine, .. did pkg install snap7 then I did pip3 install python-snap7 and that should work but it doesn't, tried comping the C++ code under /usr/local/share/examples/snap7/c-cpp "c++ -I/usr/local/include/ snap7.cpp" otherwise it won't find snap7.h but that doesn't work either

root@m0:~ # python3.6 test.py Traceback (most recent call last): File "test.py", line 17, in plc = c.Client () File "/usr/local/lib/python3.6/site-packages/snap7/client.py", line 37, in init self.library = load_library() File "/usr/local/lib/python3.6/site-packages/snap7/common.py", line 54, in load_library return Snap7Library(lib_location).cdll File "/usr/local/lib/python3.6/site-packages/snap7/common.py", line 46, in init raise Snap7Exception(msg) snap7.snap7exceptions.Snap7Exception: can't find snap7 library. If installed, try running ldconfig root@m0:~ # pkg search snap7 snap7-1.4.2 Multi-platform Ethernet S7 PLC communication suite root@m0:~ # ldd /usr/local/lib/libsnap7.so /usr/local/lib/libsnap7.so: libthr.so.3 => /lib/libthr.so.3 (0x80069f000) librt.so.1 => /usr/lib/librt.so.1 (0x8006ca000) libc++.so.1 => /usr/lib/libc++.so.1 (0x8006d2000) libcxxrt.so.1 => /lib/libcxxrt.so.1 (0x8007a1000) libm.so.5 => /lib/libm.so.5 (0x8007c2000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x800e00000) libc.so.7 => /lib/libc.so.7 (0x800248000) root@m0:~ #

From what I gather the snap7 library i've installed isn't showing up in freebsd when called upon.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Ofloo commented 5 years ago

It's probably not the lib but something in python, .. I've added to /usr/local/lib/python3.6/site-packages/snap7/common.py


    def __init__(self, lib_location=None ):
+        lib_location='/usr/local/lib/libsnap7.so'
        if self.cdll:
            return
        self.lib_location = lib_location or self.lib_location or find_library('snap7')
        if not self.lib_location:
            msg = "can't find snap7 library. If installed, try running ldconfig"
            raise Snap7Exception(msg)
        self.cdll = cdll.LoadLibrary(self.lib_location)

And now it works !?