NodeJS - 无法打开包含文件:'unistd.h':

时间:2014-12-23 23:45:46

标签: javascript node.js visual-studio-2012 makefile node-gyp

我正在使用VisualStudio 2012并在windows 7计算机上运行。

我想在我的Windows机器下执行命令make all。为此,我安装了Make for Windows

此外,我想编译节点库talib

我打开了make文件来执行nodeJS本身的命令。这就是我想要运行的命令:

cd ./src/lib && node build.js && cd ../../ && node-gyp configure  && node-gyp build

第一部分,运行良好:

cd ./src/lib && node build.js

但是,运行第二部分cd ../../ && node-gyp configure && node-gyp build,我收到了几个错误:

Kalimini@Kalimini-PC ~/nodeWorkspace/TestProject/node_modules/node-talib-master/sr
c/lib (master)
$ cd ../../ && node-gyp configure  && node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@1.0.2
gyp info using node@0.10.25 | win32 | ia32
gyp info spawn python
gyp info spawn args [ 'c:\\Users\\Kalimini\\AppData\\Roaming\\npm\\node_modules\\n
ode-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=auto',
gyp info spawn args   '-I',
gyp info spawn args   'c:\\Users\\Kalimini\\nodeWorkspace\\TestProject\\node_mod
ules\\node-talib-master\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'c:\\Users\\Kalimini\\AppData\\Roaming\\npm\\node_modules\\n
ode-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'c:\\Users\\Kalimini\\.node-gyp\\0.10.25\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=c:\\Users\\Kalimini\\.node-gyp\\0.10.25',
gyp info spawn args   '-Dmodule_root_dir=c:\\Users\\Kalimini\\nodeWorkspace\\CoinA
nalytics\\node_modules\\node-talib-master',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'c:\\Users\\Kalimini\\nodeWorkspace\\TestProject\\node_mod
ules\\node-talib-master\\build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@1.0.2
gyp info using node@0.10.25 | win32 | ia32
gyp info spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp info spawn args [ 'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=Win32' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  talib.cpp
..\src\talib.cpp(31): fatal error C1083: Cannot open include file: 'unistd.h':
No such file or directory [c:\Users\Kalimini\nodeWorkspace\TestProject\node_mod
ules\node-talib-master\build\talib.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (c:\Users\Kalimini\AppData\Roaming\npm\n
ode_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:
12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "c:\\Program Files (x86)\\nodejs\\node.exe" "c:\\Users\\Kalimini\
\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd c:\Users\Kalimini\nodeWorkspace\TestProject\node_modules\node-talib
-master
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok

我也试过node-gyp configure --msvs_version=2012但是,这给了我相同的结果。

任何建议我做错了什么?

1 个答案:

答案 0 :(得分:1)

unistd.h 是一个UNIX头文件,默认情况下在Windows上找不到。

unistd.h替换为io.h以获得几乎相同的覆盖率,或者使用找到的{GNU windows端口here

相关:Is there a replacement for unistd.h for Windows (Visual C)?

编辑:我刚刚在文件#include <unistd.h>第31行成功注释了src/talib.cpp已注释的模块