c语言error lnk 2001,c++引用c函数时,报错误 error LNK2001: 无法解析的外部符号

我的c头文件是这么写的

#ifdef __cplusplus

extern "C" {

#endif

extern int shmdb_initParent(STHashShareHandle *handle,unsigned int size);

#ifdef __cplusplus

}

#endif

我的c++代码是这么写的

//引用头文件

extern "C" {

#include "mm.h"

}

//调用代码

int rv = shmdb_initParent(&obj->_handle,obj->counter_);

然后编译c++代码的时候被报出错误

int rv = shmdb_initParent(&obj->_handle,obj->counter_);

编译错误信息:

D:\temp\addone\cpp2node>node-gyp configure build --msvs_version=2012

gyp info it worked if it ends with ok

gyp info using node-gyp@0.13.0

gyp info using node@0.10.17 | win32 | x64

gyp info spawn python

gyp info spawn args [ 'C:\\Users\\sunny\\AppData\\Roaming\\npm\\node_modules\\no

de-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=2012',

gyp info spawn args '-I',

gyp info spawn args 'D:\\temp\\addone\\cpp2node\\build\\config.gypi',

gyp info spawn args '-I',

gyp info spawn args 'C:\\Users\\sunny\\AppData\\Roaming\\npm\\node_modules\\no

de-gyp\\addon.gypi',

gyp info spawn args '-I',

gyp info spawn args 'C:\\Users\\sunny\\.node-gyp\\0.10.17\\common.gypi',

gyp info spawn args '-Dlibrary=shared_library',

gyp info spawn args '-Dvisibility=default',

gyp info spawn args '-Dnode_root_dir=C:\\Users\\sunny\\.node-gyp\\0.10.17',

gyp info spawn args '-Dmodule_root_dir=D:\\temp\\addone\\cpp2node',

gyp info spawn args '--depth=.',

gyp info spawn args '--no-parallel',

gyp info spawn args '--generator-output',

gyp info spawn args 'D:\\temp\\addone\\cpp2node\\build',

gyp info spawn args '-Goutput_dir=.' ]

gyp info spawn msbuild

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' ]

在此解决方案中一次生成一个项目。若要启用并行生成,请添加“/m”开关。

LINK : fatal error LNK1181: 无法打开输入文件“lib\shmdb.lib” [D:\temp\addone\cp

p2node\bu

ild\shmdb.vcxproj]

gyp ERR! build error

gyp ERR! stack Error: `msbuild` failed with exit code: 1

gyp ERR! stack at ChildProcess.onExit (C:\Users\sunny\AppData\Roaming\npm\no

de_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:789:

12)

gyp ERR! System Windows_NT 6.2.9200

gyp ERR! command "node" "C:\\Users\\sunny\\AppData\\Roaming\\npm\\node_modules\\

node-gyp\\bin\\node-gyp.js" "configure" "build" "--msvs_version=2012"

gyp ERR! cwd D:\temp\addone\cpp2node

gyp ERR! node -v v0.10.17

gyp ERR! node-gyp -v v0.13.0

gyp ERR! not ok

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值