[英]Changing processor architecture with node-gyp configure
I am trying to create a Node C Addon. 我正在尝试创建一个Node C Addon。 Mine is a 64bit machine but I need to compile the Node C Addon as a 32 bit binary.
我是64位机器,但我需要将Node C Addon编译成32位二进制文件。 By default, node-gyp picks up all the 64 bit libraries for compilation and linking process.
默认情况下,node-gyp选择所有64位库进行编译和链接过程。
{
"targets": [
{
"cflags": [ "-m32" ],
"ldflags": [ "-m elf_i386" ],
"cflags_cc": [ "-fPIC -m32" ],
"target_name": "hello",
"sources": [ "Hello.cpp" ],
}
}
This is my bindings.gyp file. 这是我的bindings.gyp文件。 I am passing
-m32
in cflags and setting ldflags
as -m elf_i386
. 我在cflags中传递
-m32
并将ldflags
设置为-m elf_i386
。 It compiles fine but I still see -m64
as well in the verbose output of compilation process. 它编译得很好,但我仍然在编译过程的详细输出中看到
-m64
。
g++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' ...
-fPIC -Wall -Wextra -Wno-unused-parameter -pthread -m64 -m32 -O2 -fno-strict-aliasing
-fno-tree-vrp -fno-tree-sink -fno-rtti -fno-exceptions -fPIC -MMD -MF
./Release/.deps/Release/obj.target/hello/Hello.o.d.raw -c -o
Release/obj.target/hello/Hello.o ../Hello.cpp
And It still tries to find 64 bit libraries during the linking process and fails. 它仍然试图在链接过程中找到64位库并失败。
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-****/4.1.2/libstdc++.so when searching for -lstdc++
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status
That incompatible file is actually a soft link to /lib64/libstdc++.so.6.0.8
这个不兼容的文件实际上是
/lib64/libstdc++.so.6.0.8
的软链接
I compile with node-gyp clean configure build --verbose
我使用
node-gyp clean configure build --verbose
编译
How can I override this behaviour and make node-gyp compile for 32 bit architecture? 如何覆盖此行为并为32位体系结构进行node-gyp编译?
我终于想出办法来做到这一点。
node-gyp clean configure build --verbose --arch=ia32
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.