NodeJS - Cannot open include file: 'unistd.h':

匿名 (未验证) 提交于 2019-12-03 10:10:24

问题:

I am using VisualStudio 2012 and run on a windows 7 machine.

I want to execute the command make all under my windows machine. For this I installed Make for Windows.

Furthermore, I want to compile node library talib.

I opened the make file to execute the commands by nodeJS itself. That`s the command I want to run:

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

The first part, runs well:

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

However, running the second partcd ../../ && node-gyp configure && node-gyp build, I get several errors:

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 

I also tried node-gyp configure --msvs_version=2012 however, this gives me the same result.

Any recommendation what I am doing wrong?

回答1:

unistd.h is a UNIX header file, not found by default on windows.

Either replace unistd.h with io.h for almost the same coverage, or use the GNU windows port found here

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

Edit: I just compiled the module with #include <unistd.h> commented out successfully in file src/talib.cpp line 31



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!