首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NAPI插件从.node文件抛出"undefined symbol: omp_get_max_threads“

NAPI插件从.node文件抛出"undefined symbol: omp_get_max_threads“
EN

Stack Overflow用户
提问于 2020-05-07 14:09:20
回答 1查看 293关注 0票数 0

这似乎是一个奇怪的错误。我试着逐行调试本机代码,但这个错误似乎无中生有,就像在函数调用结束时一样。这似乎是由我正在使用的本机库中的某些代码部分引起的,因为如果我删除一些函数调用,这个错误似乎就消失了。

node版本: 12.16.3 node-gyp版本: 6.1.0

顺便说一下,我使用的是nvm。如果这有帮助的话。

在搜索了omp_get_max_threads之后,我尝试将-fopenmp添加到binding.gyp文件中的编译器标志,如下所示。

代码语言:javascript
复制
{
    "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\")"
        ]
    }]
}

尽管如此,这个问题仍然存在。顺便说一下,我使用的是node-addon-api包,而不是直接使用n-api。

EN

回答 1

Stack Overflow用户

发布于 2020-05-07 14:17:39

呃..。

在发布这篇文章后,我发现你必须显式地将libgomp添加到binding.gyp中。

代码语言:javascript
复制
{
    "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\")"
        ]
    }]
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61651039

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档