WebThingsIO / zwave-adapter

Z-Wave adapter add-on for WebThings Gateway
Mozilla Public License 2.0
15 stars 20 forks source link

gcc version dependency in zwave-adapter #83

Closed tlexii closed 5 years ago

tlexii commented 5 years ago

My iot gateway is installed on my gentoo linux server (gcc-8.3), I updated recently and zwave stopped loading due to undefined symbols. Eventually I discovered a pre-compiled libopenzwave.so.1.6 is now being supplied in the tarball and LD_LIBRARY_PATH is modified during the loading of the addon to prefer it.

I needed to clone zwave-adapter and rebuild it using CFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 then install it manually to work on my system.

I understand the primary platform is the RPi and I can imagine the reasoning behind the change however I would like to suggest either the addon lib directory is appended to the existing LD_LIBRARY_PATH, or zwave-loader.sh checks for a system library before attempting to use the one included, (or perhaps there is a better solution).

dhylands commented 5 years ago

if you build the zwave-adapter using the package.sh script (which is what our https://github.com/mozilla-iot/addon-builder does, then it will build with the proper flags.

We now bundle the openzwave library with the zwave adapter and don't want to use any system supplied one, which is why the openzwave/lib is put first.

With newer versions of node, LD_LIBRARY_PATH is cleared, so we've actually had to resort to patching the node-openzwave-shared ELF file in order to get the correct library path.

tlexii commented 5 years ago

Understood, this means that every time the gateway gets an updated version of the addon, or if I remove and install it, it will get the tarball from amazon with an incompatible lib, and I will have to recompile and install manually.

dhylands commented 5 years ago

I'm not understanding why that would be the case. The adapter should be using the lib that's bundled with the adapter and not the one on the system.

If the adapter isn't using the lib that's bundled with it, then that's a bug that we need to fix.

tlexii commented 5 years ago

This is the error I get if I simply remove the adapter and then add it again without changing any library paths etc.

2019-08-25 10:46:33.250 INFO   : zwave: Found ZWave port @ /dev/ttyACM0
2019-08-25 10:46:33.250 INFO   : zwave: Initialising OpenZWave 1.6.0 binary addon for Node.JS.
2019-08-25 10:46:33.251 INFO   : zwave:         OpenZWave Security API is ENABLED
2019-08-25 10:46:33.251 INFO   : zwave:         ZWave device db    : /root/.mozilla-iot/addons/zwave-adapter/openzwave/config
2019-08-25 10:46:33.251 INFO   : zwave:         User settings path : /root/.mozilla-iot/log
2019-08-25 10:46:33.251 INFO   : zwave:         Option Overrides : --SaveConfiguration true --ConsoleOutput false
2019-08-25 10:46:33.252 ERROR  : zwave: node: symbol lookup error: /root/.mozilla-iot/addons/zwave-adapter/node_modules/openzwave-shared/build/Release/openzwave_shared.node: undefined symbol: _ZN9OpenZWave7Options6CreateERKSsS2_S2_
2019-08-25 10:46:33.255 INFO   : Plugin: zwave-adapter died, code = 127 restarting after 0
tlexii commented 5 years ago

fyi


 # ldd zwave-adapter/node_modules/openzwave-shared/build/Release/openzwave_shared.node 
    linux-vdso.so.1 (0x00007ffdedfcd000)
    libopenzwave.so.1.6 => /root/.mozilla-iot/addons/zwave-adapter/node_modules/openzwave-shared/build/Release/../../../../openzwave/lib/libopenzwave.so.1.6 (0x00007f1f83449000)
    libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/libstdc++.so.6 (0x00007f1f831e0000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f1f83096000)
    libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/8.3.0/libgcc_s.so.1 (0x00007f1f8307c000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1f83059000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f1f82e89000)
    libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f1f82e6e000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f1f8364d000)
dhylands commented 5 years ago

I'll take a look into that.

dhylands commented 5 years ago

Thanks for the report.

This should now be fixed in the 0.9.1 version of the zwave-adapter. The addon-builder wasn't setting the appropriate build flags when building libopenzwave.so.1.6 for linux-x64 and mac.

tlexii commented 5 years ago

Working well thanks