OpenZWave / node-openzwave-shared

OpenZWave addon for Node.js (all versions) including management and security functions
Other
199 stars 113 forks source link

Symbol Lookup Error #203

Closed japita-se closed 6 years ago

japita-se commented 6 years ago

1.Installed latest OZW

  1. Installed latest node and openzwave-shared.
  2. Start my script, got this error: undefined symbol: _ZN9OpenZWave7Options6CreateERKNSt7__cxx1112b
robertsLando commented 6 years ago

Same issue here. Here node-red output logs:

Welcome to Node-RED
===================

17 Nov 11:50:33 - [info] Node-RED version: v0.17.5
17 Nov 11:50:33 - [info] Node.js  version: v8.9.1
17 Nov 11:50:33 - [info] Linux 4.9.41-v7+ arm LE
17 Nov 11:50:34 - [info] Loading palette nodes
17 Nov 11:50:37 - [info] node-red-contrib-openzwave: 1.2.1
17 Nov 11:50:37 - [info] openzwave-shared: 1.4.0
initialising OpenZWave addon (/home/pi/.node-red/node_modules/openzwave-shared/lib/../build/Release/openzwave_shared.node)
17 Nov 11:50:37 - [info] Dashboard version 2.6.2 started at /ui
17 Nov 11:50:38 - [info] Settings file  : /home/pi/.node-red/settings.js
17 Nov 11:50:38 - [info] User directory : /home/pi/.node-red
17 Nov 11:50:38 - [info] Flows file     : /home/pi/.node-red/flows_raspberrypi.json
17 Nov 11:50:39 - [info] Server now running at http://127.0.0.1:1880/
17 Nov 11:50:39 - [info] Starting flows
Initialising OpenZWave 1.4.79 binary addon for Node.JS.
    OpenZWave Security API is ENABLED
    ZWave device db    : /usr/local/etc/openzwave/
    User settings path : /home/pi/.node-red
    Option Overrides : --Logging true --ConsoleOutput true --QueueLogLevel 6 --DriverMaxAttempts 3
17 Nov 11:50:39 - [info] OpenZwave: connecting to /dev/ttyACM0
node-red: symbol lookup error: /home/pi/.node-red/node_modules/openzwave-shared/build/Release/openzwave_shared.node: undefined symbol: _ZN9OpenZWave7Options6CreateERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_S8_
robertsLando commented 6 years ago

Seems like this only happens with Raspbian Stretch, everything works perfectly on Raspbian Jessie.

ekarak commented 6 years ago

Programming tip: the undefined symbol:xxx error means that you've compiled openzwave-shared against a different library version than the one that is found when you're using the library. Go directly to : https://demangler.com/ and add the missing symbol into the search box, this yields: OpenZWave::Options::Create(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)

... which means: this C++ method with the signature above is missing from the OpenZWave library that it finds on the system. Most probably you have the library file libopenzwave.so.1.x in multiple versions in multiple locations

ekarak commented 6 years ago

so in order to resolve this, first try to locate which file is loaded by node-red:

1) grab the node.js openzwave library file from the error: node-red: symbol lookup error: /home/pi/.node-red/node_modules/openzwave-shared/build/Release/openzwave_shared.node: undefined symbol: ... In our case, this is /home/pi/.node-red/node_modules/openzwave-shared/build/Release/openzwave_shared.node

2) run ldd -r against that file, ie. ldd -r /home/pi/.node-red/node_modules/openzwave-shared/build/Release/openzwave_shared.node

On my Raspberry (running Raspbian stretch) I get:

    /usr/lib/arm-linux-gnueabihf/libarmmem.so (0xb6ea0000)
    libopenzwave.so.1.5 => /usr/lib/arm-linux-gnueabihf/libopenzwave.so.1.5 (0xb6da4000)
    libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6c5c000)
...

On the 2nd line there's an entry noting that for libopenzwave.so.1.5 the linker has resolved it (=>) to /usr/lib/arm-linux-gnueabihf/libopenzwave.so.1.5 , so there's the actual OpenZwave library that is loaded (and is of a previous version than the one the plugin is compiled against)

ekarak commented 6 years ago

Then there's this grep trick to get you the correct library:

root@pi-stretch:/# find /usr/ -type f -name 'libopenzwave.so.*' |xargs grep -al  _ZN9OpenZWave7Options6CreateERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES8_S8_
/usr/lib/arm-linux-gnueabihf/libopenzwave.so.1.5
root@pi-stretch:/# 
robertsLando commented 6 years ago

In my case, on stretch, the only way to fix this has been:

sudo cp /usr/local/lib/libopen* /usr/lib/arm-linux-gnueabihf
ptskyin commented 5 years ago

I had the same problem on Raspbian Stretch following the instructions of https://github.com/OpenZWave/node-openzwave-shared/blob/master/README-raspbian.md. In my case, it was caused by gcc/g++. Following Option 1 of http://node-arm.herokuapp.com/ solves the problem.