New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node_curve.cc error Cannot open include file: 'unistd.h': No such file or directory #113

Closed
nzhome opened this Issue Aug 11, 2015 · 9 comments

Comments

Projects
None yet
4 participants
@nzhome

nzhome commented Aug 11, 2015

..\node_curve.cc(6): fatal error C1083: Cannot open include file: 'unistd.h': No such file or directory
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:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.1.7600
gyp ERR! command "node" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Program Files\nodejs\node_modules\homebridge-master\node_modules\HAP-NodeJS\node_modules\curve25519
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok

@KhaosT

This comment has been minimized.

Show comment
Hide comment
@KhaosT

KhaosT Aug 11, 2015

Owner

It appears that Windows doesn't have unistd.h... You can try to use the customized version at here but I'm not sure if other modification may required to get this works.

Owner

KhaosT commented Aug 11, 2015

It appears that Windows doesn't have unistd.h... You can try to use the customized version at here but I'm not sure if other modification may required to get this works.

@nzhome

This comment has been minimized.

Show comment
Hide comment
@nzhome

nzhome Aug 12, 2015

thanks, do you normally do your build on x86 or x64? I saw your raspberry pi2 on instagram, what o/s do you run on it? this will help me know whether to target x86 or x64 when compiling the version for windows. thanks. oh, and what build of nodeJs do you use? 0.10.0 or 0.12.7 or other?

nzhome commented Aug 12, 2015

thanks, do you normally do your build on x86 or x64? I saw your raspberry pi2 on instagram, what o/s do you run on it? this will help me know whether to target x86 or x64 when compiling the version for windows. thanks. oh, and what build of nodeJs do you use? 0.10.0 or 0.12.7 or other?

@KhaosT

This comment has been minimized.

Show comment
Hide comment
@KhaosT

KhaosT Aug 12, 2015

Owner

Raspberry Pi 2 is ARMv7 arch and runs Raspbian. I used NodeJS 0.12 on both OS X and Raspbian.

Owner

KhaosT commented Aug 12, 2015

Raspberry Pi 2 is ARMv7 arch and runs Raspbian. I used NodeJS 0.12 on both OS X and Raspbian.

@nzhome

This comment has been minimized.

Show comment
Hide comment
@nzhome

nzhome Aug 12, 2015

yes I created unistd.h from the most popular answer here
http://stackoverflow.com/questions/341817/is-there-a-replacement-for-unistd-h-for-windows-visual-c

and downloaded getopt.h and getopt.c from here
http://www.codeproject.com/Articles/157001/Full-getopt-Port-for-Unicode-and-Multibyte-Microso

and I put them into C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\

Then YES it compiled curve25519 successfully on windows nodejs 32bit and nodejs 64bit.

nzhome commented Aug 12, 2015

yes I created unistd.h from the most popular answer here
http://stackoverflow.com/questions/341817/is-there-a-replacement-for-unistd-h-for-windows-visual-c

and downloaded getopt.h and getopt.c from here
http://www.codeproject.com/Articles/157001/Full-getopt-Port-for-Unicode-and-Multibyte-Microso

and I put them into C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\

Then YES it compiled curve25519 successfully on windows nodejs 32bit and nodejs 64bit.

@nzhome nzhome closed this Aug 12, 2015

@nzhome

This comment has been minimized.

Show comment
Hide comment
@nzhome

nzhome Aug 12, 2015

ERROR: unistd.h(43): 'int8_t' : redefinition; different basic types

oh and I had to edit the unistd.h file because you can't leave the compiler to decide the default signed or unsigned datatype, because you can change the compilers default. put the word "signed" on all 4 of these lines after typedef, like this... without it the windows compiler throws its toys out of the cot, because it does not know if it is signed or unsigned.

change from:
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;

change to:
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;

nzhome commented Aug 12, 2015

ERROR: unistd.h(43): 'int8_t' : redefinition; different basic types

oh and I had to edit the unistd.h file because you can't leave the compiler to decide the default signed or unsigned datatype, because you can change the compilers default. put the word "signed" on all 4 of these lines after typedef, like this... without it the windows compiler throws its toys out of the cot, because it does not know if it is signed or unsigned.

change from:
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;

change to:
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;

@2longue

This comment has been minimized.

Show comment
Hide comment
@2longue

2longue Mar 29, 2016

Hi,please need help, i have add getopt.h and getopt.c
Make correction in unistd file,
But always the same error, maybe because i have nodeJS v4.4.1 and Visual Studio V14 ? Must downgrade ?
Thanks

2longue commented Mar 29, 2016

Hi,please need help, i have add getopt.h and getopt.c
Make correction in unistd file,
But always the same error, maybe because i have nodeJS v4.4.1 and Visual Studio V14 ? Must downgrade ?
Thanks

@nzhome

This comment has been minimized.

Show comment
Hide comment
@nzhome

nzhome Apr 25, 2016

update: Yes I have been running homebridge and HAP-NodeJS for 9 months with zero downtime on my Windows box. oh and it runs a gazillion times faster on a Windows PC than on a Raspberry PI! A $2000 Intel Corei7 64bit Windows7 Gaming PC I should hope so.. haha. I tried to find a way to convert this into a standalone windows binary app for others. but I couldn't find any proper NodeJS standalone windows app compilers.

2longue: nodeJS v4.4.1 and VS14 should be fine. yes its hard to get going.. it took me 5 entire nights. Looks like someone outlined most of the steps here https://github.com/nfarina/homebridge/wiki/Install-Homebridge-on-Windows:-Old-version-(without-Plugin)

nzhome commented Apr 25, 2016

update: Yes I have been running homebridge and HAP-NodeJS for 9 months with zero downtime on my Windows box. oh and it runs a gazillion times faster on a Windows PC than on a Raspberry PI! A $2000 Intel Corei7 64bit Windows7 Gaming PC I should hope so.. haha. I tried to find a way to convert this into a standalone windows binary app for others. but I couldn't find any proper NodeJS standalone windows app compilers.

2longue: nodeJS v4.4.1 and VS14 should be fine. yes its hard to get going.. it took me 5 entire nights. Looks like someone outlined most of the steps here https://github.com/nfarina/homebridge/wiki/Install-Homebridge-on-Windows:-Old-version-(without-Plugin)

@baysinger

This comment has been minimized.

Show comment
Hide comment
@baysinger

baysinger Aug 19, 2016

I tried removing the #include of unistd.h from node_curve.cc, and it seems to work just fine that way. I don't know why it was there in the first place. This should eliminate the need for the workaround of creating a unistd.h.

I submitted a pull request to KhaosT/node-curve25519. Maybe I should submit it to volschin/node-curve25519, as well? (KhaosT forked it from volschin.)

baysinger commented Aug 19, 2016

I tried removing the #include of unistd.h from node_curve.cc, and it seems to work just fine that way. I don't know why it was there in the first place. This should eliminate the need for the workaround of creating a unistd.h.

I submitted a pull request to KhaosT/node-curve25519. Maybe I should submit it to volschin/node-curve25519, as well? (KhaosT forked it from volschin.)

@KhaosT

This comment has been minimized.

Show comment
Hide comment
@KhaosT

KhaosT Aug 19, 2016

Owner

I'll try to build in different configuration and ensure it didn't break the build. I'll merge the change after that.

Owner

KhaosT commented Aug 19, 2016

I'll try to build in different configuration and ensure it didn't break the build. I'll merge the change after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment