繁体   English   中英

在node-gyp binding.gyp文件中,如何根据系统arch(32位,64位)包含不同的库文件)

[英]In node-gyp binding.gyp file, how to include different library files based on the system arch (32 bit, 64bit))

我目前正在尝试使用 node-gyp 将 c++ 与 nodejs 项目连接起来。 我目前的问题是我有一个 32 位库文件和一个 64 位库文件。 我的电脑使用的是 64 位。 如果我使用 32 位库文件,并使用 node-gyp rebuild 构建它,当我使用该库的函数时,它会出现未解析的外部符号错误,但如果我使用 64 位库,它工作正常。 我想知道有没有办法在计算机是 32 位时包含 32 位库,如果是 64 位则包含 64 位库

我试过跑步

node-gyp clean configure build --verbose --arch=ia32

但是当我运行 node index.js 时它会返回以下错误

testaddon.node is not a valid Win32 application.

我的库 binding.gyp 文件如下所示

"libraries": [
    "../cppsrc/lib/some32.lib"
]

我检查了这个链接,但在条件下似乎没有拱形选项

谢谢你。

一个可能的解决方案(针对这个老问题)是根据它们构建的体系结构命名你的库文件,然后在 binding.gyp 中使用变量,在 macos 和 linux 上可以这样做:

"libraries": [
    "../cppsrc/lib/some.<!(uname -m | tr A-Z a-z).lib"
]

根据您使用的 shell,Windows 可能具有等价物。

有关详细信息,请参阅https://gyp.gsrc.io/docs/InputFormatReference.md#Variables-and-Conditionals

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM