码迷,mamicode.com
首页 > 编程语言 > 详细

node c/c++扩展模块build失败.

时间:2015-12-22 06:28:41      阅读:358      评论:0      收藏:0      [点我收藏+]

标签:

"深入浅出nodejs 朴灵" 例子 c/c++扩展模块

hello.cc

#include <node.h>
#include <v8.h>

using namespace v8;

Handle<Value> SayHello(const Arguments& args){
	HandleScope scope;
	return scope.Close(String::New("Hello world!"));
}

void Init_Hello(Handle<Object> target){
	target->Set(String::NewSymbol("sayHello"), FunctionTemplate::New(SayHello)->GetFunction());
}

NODE_MODULE(hello, Init_Hello)

binding.gyp

{
	‘targets‘:[
		{
			‘target_name‘:‘hello‘,
			‘sources‘:[
				‘./hello.cc‘
			],
			‘conditions‘:[
				[‘OS == "win"‘,
				{
					‘libraries‘:[‘-lnode.lib‘]
				}
				]
			]
		}
	]
}

configure没有问题:

C:\wxg\test\nodejs\dll_demo
λ node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@3.2.1
gyp info using node@0.12.1 | win32 | x64
gyp info spawn C:\Python27\python.EXE
gyp info spawn args [ ‘E:\\wxg\\Git\\nvmw\\v0.12.1\\node_modules\\node-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:\\wxg\\test\\nodejs\\dll_demo\\build\\config.gypi‘,
gyp info spawn args   ‘-I‘,
gyp info spawn args   ‘E:\\wxg\\Git\\nvmw\\v0.12.1\\node_modules\\node-gyp\\addon.gypi‘,
gyp info spawn args   ‘-I‘,
gyp info spawn args   ‘C:\\Users\\WXG\\.node-gyp\\0.12.1\\common.gypi‘,
gyp info spawn args   ‘-Dlibrary=shared_library‘,
gyp info spawn args   ‘-Dvisibility=default‘,
gyp info spawn args   ‘-Dnode_root_dir=C:\\Users\\WXG\\.node-gyp\\0.12.1‘,
gyp info spawn args   ‘-Dnode_gyp_dir=E:\\wxg\\Git\\nvmw\\v0.12.1\\node_modules\\node-gyp‘,
gyp info spawn args   ‘-Dnode_lib_file=node.lib‘,
gyp info spawn args   ‘-Dmodule_root_dir=C:\\wxg\\test\\nodejs\\dll_demo‘,
gyp info spawn args   ‘--depth=.‘,
gyp info spawn args   ‘--no-parallel‘,
gyp info spawn args   ‘--generator-output‘,
gyp info spawn args   ‘C:\\wxg\\test\\nodejs\\dll_demo\\build‘,
gyp info spawn args   ‘-Goutput_dir=.‘ ]
gyp info ok

build失败.

C:\wxg\test\nodejs\dll_demo
λ node-gyp build
gyp info it worked if it ends with ok
gyp info using node-gyp@3.2.1
gyp info using node@0.12.1 | win32 | x64
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=x64‘ ]
VCBUILD : error : project file ‘C:\wxg\test\nodejs\dll_demo\build\hello.vcproj‘ was not found or not a valid p roject file. [C:\wxg\test\nodejs\dll_demo\build\binding.sln]
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 (E:\wxg\Git\nvmw\v0.12.1\node_modules\node-gyp\lib\build.js:276:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1067:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "E:\\wxg\\Git\\nvmw\\v0.12.1\\\\node.exe" "E:\\wxg\\Git\\nvmw\\v0.12.1\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
gyp ERR! cwd C:\wxg\test\nodejs\dll_demo
gyp ERR! node -v v0.12.1
gyp ERR! node-gyp -v v3.2.1
gyp ERR! not ok

在网上搜索了下:  http://www.imooc.com/qadetail/38800 , http://stackoverflow.com/questions/32964144/gyp-err-stack-error-c-program-files-x86-msbuild-12-0-bin-msbuild-exe-fail ,

最靠谱的应该还是 https://www.npmjs.com/package/node-gyp 

Windows 7/8:
Microsoft Visual Studio C++ 2013 for Windows Desktop (Express version works well)

但是,我还没装"Microsoft Visual Studio C++ 2013", studio文件太大,下载要很久. 我在网上找的一个"Microsoft Visual C++ 2013运行库",安装了,没效果. 这个等以后下载了studio再验证下.

 

node c/c++扩展模块build失败.

标签:

原文地址:http://www.cnblogs.com/juedui0769/p/5065455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!