[英]NAPI addon throwing “undefined symbol: omp_get_max_threads” from .node file
This seems like a weird error.这似乎是一个奇怪的错误。 I tried debugging the native code line by line and this error seems to happen out of nowhere, like at the end of a function call.
我尝试逐行调试本机代码,这个错误似乎无处不在,就像在 function 调用结束时一样。 It's seem to be caused by certain parts of code in the native library I'm using, because if I remove some function calls, this error seems to disappear.
这似乎是由我正在使用的本机库中的某些代码部分引起的,因为如果我删除一些 function 调用,这个错误似乎消失了。
node version: 12.16.3 node-gyp version: 6.1.0节点版本:12.16.3 节点gyp版本:6.1.0
By the way, I'm using nvm.顺便说一句,我正在使用 nvm。 If that helps.
如果这有帮助。
After googling around omp_get_max_threads, I've tried adding -fopenmp to compiler flags in binding.gyp file like so.在搜索了 omp_get_max_threads 之后,我尝试像这样将 -fopenmp 添加到 binding.gyp 文件中的编译器标志中。
{
"targets": [{
"target_name": "custom_addon",
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
"cflags": ["-fopenmp"],
"cflags_cc": ["-fopenmp"],
"sources": [
"custom_addon.cpp"
],
'include_dirs': [
"<!@(node -p \"require('node-addon-api').include\")",
"${workspaceRoot}"
],
'libraries': [],
'dependencies': [
"<!(node -p \"require('node-addon-api').gyp\")"
]
}]
}
Still, the problem persists.尽管如此,问题仍然存在。 By the way, I'm using node-addon-api package, not n-api directly.
顺便说一句,我使用的是 node-addon-api package,而不是直接使用 n-api。
Urghh..呃..
Just after posting this, I found out that you have to explicitly add libgomp to binding.gyp.就在发布这个之后,我发现你必须明确地将 libgomp 添加到 binding.gyp。
{
"targets": [{
"target_name": "custom_addon",
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ],
"cflags": ["-fopenmp"],
"cflags_cc": ["-fopenmp"],
"sources": [
"custom_addon.cpp"
],
'include_dirs': [
"<!@(node -p \"require('node-addon-api').include\")",
"${workspaceRoot}"
],
'libraries': ["/usr/lib/x86_64-linux-gnu/libgomp.so.1"],
'dependencies': [
"<!(node -p \"require('node-addon-api').gyp\")"
]
}]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.