最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

。API文件中的NAPI附件抛出“未定义符号:omp

网站源码admin16浏览0评论

。API文件中的NAPI附件抛出“未定义符号:omp

。API文件中的NAPI附件抛出“未定义符号:omp

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

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

顺便说一下,我正在使用nvm。如果有帮助。

在围绕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\")"
        ]
    }]
}

仍然,问题仍然存在。顺便说一下,我使用的是node-addon-api软件包,而不是直接使用n-api。

回答如下:

Urghh ..

发布此消息后,我发现您必须将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\")"
        ]
    }]
}
发布评论

评论列表(0)

  1. 暂无评论