Added support for "node-gyp" build - #17
Conversation
brianmcd
commented
Feb 8, 2012
Thanks! I've been following the thread on the Node mailing list and was planning on looking into this this weekend. Is there a way to specify a target architecture for brianmcd@home:~/projects/contextify$ node-gyp clean
info it worked if it ends with ok info done ok brianmcd@home:~/projects/contextify$ node-gyp configure
info it worked if it ends with ok spawn python [ '/home/brianmcd/.node-gyp/0.6/tools/gyp_addon',
'-f',
'make',
'--suffix',
'.gyp' ]
info done ok brianmcd@home:~/projects/contextify$ node-gyp build
info it worked if it ends with ok spawn make [ 'BUILDTYPE=Release', '-f', 'Makefile.gyp' ]
CXX(target) out/Release/obj.target/contextify/src/contextify.o
In file included from /usr/include/features.h:388:0,
from /usr/include/stdint.h:26,
from /usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/include/stdint.h:3,
from ../../.node-gyp/0.6/deps/uv/include/uv.h:54,
from ../../.node-gyp/0.6/src/node.h:61,
from src/contextify.cc:1:
/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory
compilation terminated.
make: *** [out/Release/obj.target/contextify/src/contextify.o] Error 1
ERR!`make` failed with exit code: 2
ERR! not okThis is with node-gyp installed locally in contextify/node_modules, if that matters. |
TooTallNate
commented
Feb 8, 2012
So I'm guessing that gyp is adding the |
brianmcd
commented
Feb 8, 2012
Thanks for the help. You were right about gyp adding {
'variables' : {'target_arch': 'x64'
},
'targets': [
{ 'target_name': 'contextify','sources': [ 'src/contextify.cc' ],'cflags': ['-fPIC']
} ]}I had to add -fPIC to cflags or else I got this output: brianmcd@home:~/projects/contextify$ node-gyp build -v
info it worked if it ends with ok verb command'build' [] verb build args [] verb `which` succeededmake '/usr/bin/make' spawn make [ 'V=1', 'BUILDTYPE=Release', '-f', 'Makefile.gyp' ]
g++ '-D_LARGEFILE_SOURCE''-D_FILE_OFFSET_BITS=64''-DNDEBUG' -I../../.node-gyp/0.6/src -I../../.node-gyp/0.6/deps/uv/include -I../../.node-gyp/0.6/deps/v8/include -Wall -pthread -ansi -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -fno-rtti -fno-exceptions -MMD -MF out/Release/.deps/out/Release/obj.target/contextify/src/contextify.o.d.raw -c -o out/Release/obj.target/contextify/src/contextify.o src/contextify.cc
flock out/Release/linker.lock g++ -shared -pthread -rdynamic -Wl,-soname=contextify.node -o out/Release/obj.target/contextify.node -Wl,--start-group out/Release/obj.target/contextify/src/contextify.o -Wl,--end-group /usr/bin/ld: out/Release/obj.target/contextify/src/contextify.o: relocation R_X86_64_32 against `node::ObjectWrap::WeakCallback(v8::Persistent<v8::Value>, void*)' can not be used when making a shared object; recompile with -fPICout/Release/obj.target/contextify/src/contextify.o: could not read symbols: Bad valuecollect2: ld returned 1 exit statusmake: *** [out/Release/obj.target/contextify.node] Error 1ERR! `make` failed with exit code: 2ERR! not okShould these things be made defaults in |
TooTallNate
commented
Feb 8, 2012
These may indeed be good defaults. Thanks for the suggestion, I'll look into it. |
brianmcd
commented
Feb 9, 2012
Landed, thanks! |
TooTallNate
commented
Feb 10, 2012
@brianmcd fyi, as of |
benjamine
commented
Mar 13, 2012
I don't know if this is the place, but I'm getting an error trying to install contextify using node-gyp. Platform: Windows 7, node 0.6.7, npm 1.1.0-beta-10 |
TooTallNate
commented
Mar 13, 2012
Upgrade to v0.612 On Tuesday, March 13, 2012, Benjamn Eidelman <
|
benjamine
commented
Mar 13, 2012
ops, you were right! now I'm installing python :), regards! |
benjamine
commented
Mar 13, 2012
configure now works fine, but I'm getting an error build, stdin.h file not found... This might be a very silly error I can't understand as I'm totally ignorant on C/C++ |
TooTallNate
commented
Mar 13, 2012
Do you have Visual Studio 2010 installed? Apparently 2008 and below don't include |
benjamine
commented
Mar 13, 2012
Actually I have both installed, notice that it's using .Net 4.0 msbuild. As a Visual Studio developer I'm used to MS bizarreness :), I can try to invoke an specific msbuild version to test. |
TooTallNate
commented
Mar 13, 2012
@benjamine try invoking the $ node-gyp configure -- -f msvs -G msvs_version=2010 |
benjamine
commented
Mar 13, 2012
looks like that did the trick! |
brianmcd
commented
Mar 14, 2012
Thanks for helping with this, @TooTallNate ! |
hughlomas
commented
Mar 21, 2012
From the comments above, I installed Visual Studio C++ 2010, and Python 2.7.2 I am running into the following error: C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8>node-gyp build info it worked if it ends with ok spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe [ 'build/binding.sln', '/clp:Verbosity=minimal', '/nologo', '/p:Configuration=Release;Platform=Win32' ] contextify.cc C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\.node-gyp\0.6.7\src\node_object_wrap.h(57): warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Persisten t' needs to have dll-interface to be used by clients of class 'node::ObjectWrap' [C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\contextify.vcxproj ] with [ T=v8::Object ] C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocale(323): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\Hugh\Downloads\br ianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\contextify.vcxproj] C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4 ae8\build\Release\contextify.dll) does not match the Linker's OutputFile property value (C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\Release\contex tify.node). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.Outp utFile). [C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\contextify.vcxproj] C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991,5): warning MSB8012: TargetExt(.dll) does not match the Linker's OutputFile property value (.node). This may cause you r project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile). [C:\Users\Hugh\Downlo ads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\contextify.vcxproj] C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\.node-gyp\0.6.7\Release\node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0xA2 [C:\User s\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\contextify.vcxproj] ERR! Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1 at Array.0 (C:\Users\Hugh\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:176:25) at EventEmitter._tickCallback (node.js:192:40) ERR! not ok I'm unfamiliar with these things, if anyone has any suggestions I would greatly appreciate it. |
TooTallNate
commented
Mar 21, 2012
@hughlomas I haven't seen that one before. Looks like your dev file Then, what happens if you just type in |
hughlomas
commented
Mar 22, 2012
Using Deleted the .node-gyp directory, and did C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8>node-gyp install info it worked if it ends with ok info downloading: http://nodejs.org/dist/v0.6.7/node-v0.6.7.tar.gz info downloading: http://nodejs.org/dist/v0.6.7/node.lib 0.6.7 info done ok then typing C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8>npm install contextify C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8> No output whatsoever. Not sure if this helps but also C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8>node-gyp rebuild info it worked if it ends with ok spawn C:\Python27\python.exe [ 'C:\\Users\\Hugh\\Downloads\\brianmcd-contextify-v0.1.2-0-g9ed4ae8\\brianmcd-contextify-9ed4ae8\\.node-gyp\\0.6.7\\tools\\gyp_addon', 'binding.gyp', '-IC:\\Users\\Hugh\\Downloads\\brianmcd-contextify-v0.1.2-0-g9ed4ae8\\brianmcd-contextify-9ed4ae8\\build\\config.gypi', '-f', 'msvs', '-G', 'msvs_version=2010' ] spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe [ 'build/binding.sln', '/clp:Verbosity=minimal', '/nologo', '/p:Configuration=Release;Platform=Win32' ] contextify.cc C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\.node-gyp\0.6.7\src\node_object_wrap.h(57): warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Persisten t' needs to have dll-interface to be used by clients of class 'node::ObjectWrap' [C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\contextify.vcxproj ] with [ T=v8::Object ] c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocale(323): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\Users\Hugh\Downloads\br ianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\contextify.vcxproj] C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4 ae8\build\Release\contextify.dll) does not match the Linker's OutputFile property value (C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\Release\contex tify.node). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.Outp utFile). [C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\contextify.vcxproj] C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991,5): warning MSB8012: TargetExt(.dll) does not match the Linker's OutputFile property value (.node). This may cause you r project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile). [C:\Users\Hugh\Downlo ads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\contextify.vcxproj] C:\Users\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\.node-gyp\0.6.7\Release\node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0xA2 [C:\User s\Hugh\Downloads\brianmcd-contextify-v0.1.2-0-g9ed4ae8\brianmcd-contextify-9ed4ae8\build\contextify.vcxproj] ERR! Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1 at Array.0 (C:\Users\Hugh\AppData\Roaming\npm\node_modules\node-gyp\lib\build.js:176:25) at EventEmitter._tickCallback (node.js:192:40) ERR! not ok |
TooTallNate
commented
Mar 22, 2012
@hughlomas That's an older version of npm. Try updating: $ npm install -g npm |
hughlomas
commented
Mar 22, 2012
C:\Users\Hugh\Downloads\contextify>npm install -g npm npm http GET https://registry.npmjs.org/npm npm http 200 https://registry.npmjs.org/npm npm http GET https://registry.npmjs.org/npm/-/npm-1.1.10.tgz npm http 200 https://registry.npmjs.org/npm/-/npm-1.1.10.tgz C:\Users\Hugh\AppData\Roaming\npm\npm -> C:\Users\Hugh\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js npm@1.1.10 C:\Users\Hugh\AppData\Roaming\npm\node_modules\npm C:\Users\Hugh\Downloads\contextify>npm -v 1.1.0-beta-10 edit: nevermind, I just downloaded the source from https://github.com/isaacs/npm/ and copy-pasted it to replace my npm directory, that seems to have worked, now at |
hughlomas
commented
Mar 22, 2012
C:\hugh\army>npm install contextify
npm http GET https://registry.npmjs.org/contextify
npm http 304 https://registry.npmjs.org/contextify
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings
> contextify@0.1.2 install C:\hugh\army\node_modules\contextify
> node-gyp rebuild
C:\hugh\army\node_modules\contextify>node "C:\Program Files (x86)\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
info it worked if it ends with ok
info downloading: http://nodejs.org/dist/v0.6.7/node-v0.6.7.tar.gz
info downloading `node.lib` http://nodejs.org/dist/v0.6.7/node.lib
spawn C:\Python27\python.exe [ 'C:\\Users\\Hugh\\.node-gyp\\0.6.7\\tools\\gyp_addon',
'binding.gyp',
'-IC:\\hugh\\army\\node_modules\\contextify\\build\\config.gypi',
'-f',
'msvs',
'-G',
'msvs_version=2010' ]
spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe [ 'build/binding.sln',
'/clp:Verbosity=minimal',
'/nologo',
'/p:Configuration=Release;Platform=Win32' ]
contextify.cc
C:\Users\Hugh\.node-gyp\0.6.7\src\node_object_wrap.h(57): warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Persistent' needs to have dll-interface to be used by clients of class 'node::Obje
ctWrap' [C:\hugh\army\node_modules\contextify\build\contextify.vcxproj]
with
[
T=v8::Object
]
c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocale(323): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc [C:\hugh\army\node_modules\
contextify\build\contextify.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\hugh\army\node_modules\contextify\build\Release\contextify.dll) does not match the
Linker's OutputFile property value (C:\hugh\army\node_modules\contextify\build\Release\contextify.node). This may cause your project to build incorrectly. To correct this, please make sure that $(Out
Dir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile). [C:\hugh\army\node_modules\contextify\build\contextify.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(991,5): warning MSB8012: TargetExt(.dll) does not match the Linker's OutputFile property value (.node). This may cause you
r project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile). [C:\hugh\army\node_mo
dules\contextify\build\contextify.vcxproj]
C:\Users\Hugh\.node-gyp\0.6.7\Release\node.lib : fatal error LNK1107: invalid or corrupt file: cannot read at 0xA2 [C:\hugh\army\node_modules\contextify\build\contextify.vcxproj]
ERR! Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
at Array.0 (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:169:25)
at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok
npm ERR! contextify@0.1.2 install: `node-gyp rebuild`
npm ERR! `cmd "/c" "node-gyp rebuild"` failed with 1
npm ERR!
npm ERR! Failed at the contextify@0.1.2 install script.
npm ERR! This is most likely a problem with the contextify package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls contextify
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "contextify"
npm ERR! cwd C:\hugh\army
npm ERR! node -v v0.6.7
npm ERR! npm -v 1.1.10
npm ERR! code ELIFECYCLE
npm ERR! message contextify@0.1.2 install: `node-gyp rebuild`
npm ERR! message `cmd "/c" "node-gyp rebuild"` failed with 1
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\hugh\army\npm-debug.log
npm not ok |
hughlomas
commented
Mar 23, 2012
Well I should have checked earlier, but based on the part of the error that says the invalid file is <title>404 Not Found</title> which is the response from |
TooTallNate
commented
Mar 23, 2012
@hughlomas Ahhh yes, you hadn't told us your node version. I should have thought of that. You need to upgrade to node |
hughlomas
commented
Mar 23, 2012
Phew, finally worked! Thanks very much for your assistance. |
thefourtheye
commented
Jul 19, 2013
@TooTallNate The suggestion you gave to @brianmcd didnt work for me. I use Node 0.10.4. But I found a workaround I wonder why passing arguments in command line is not documented anywhere (atleast, it is difficult for even google to find). I had to go through the code completely to figure this out. Please let me know, if you need someone to document it. I would be happy to do that. :) |
Hey @brianmcd! So I've added a
bindings.gypfile which is compatible withnode-gyp, sincenode-wafis removed in nodev0.8.x. So this essentially adds Windows support and ensures forwards compatibility. Cheers!