I am trying to compile a c++ addon that uses an external library. My bindings.gyp file looks like this:
{
"targets": [
{
"target_name": "addon",
"sources": [ "addon.cc" ],
"include_dirs": [
"<!(node -e \"require('nan')\")"
],
"libraries":[
"/home/ubuntu/workspace/libdds.a"
],
}
]
}
When I try to compile it with node-gyp, it compiles fine but on runtime I get the following error:
Error: /home/ubuntu/workspace/build/Release/addon.node: undefined symbol: omp_init_lock
at Error (native)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/ubuntu/workspace/addon.js:1:75)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
omp_int_lock isn't in addon.cc code but instead in the libdds.a library I am trying to use. I tried taking my code and just converting it to a command line program. Compiling it like so:
g++ -o ddsolver -O2 -Wall leadsolver.cpp libdds.a -lgomp
It compiles and runs fine. Has anyone seen this problem before?
Seems like your external library libdds.a uses OpenMP for parallel execution and since it is statically linked you need to provide -lgomp to resolve all the dependencies.
I think you can also compile it with -fopenmp instead of -lgomp