C ++ Node.js – 得到错误LNK 2001

有一个未解决的外部问题。

问题 – >一个头文件(myImpressiveHeaderFile.h)告诉他找不到符号。 但另一个文件(holys_i.c)是一个c文件存在于这个项目中,并拥有这些符号。

如果我创build一个新的win32控制台项目(空),并添加这些文件(和第三个文件,一个主要function,并包括头文件),它完美的作品。

但 – >如果我让node-gyp构build项目(除了主文件xD,即与v8.h和node.h的节点spcefic文件相同的文件 – 但也包括头文件) – 我有错误(LNK 2001见上文) 。

如果我用node-gyp创build它,似乎链接器不会或者稍后会发送c-file? 或者node-gyp不能编译c文件? 那不可能? 要么?

你有什么想法我可以做/testing/检查?

编辑(添加例子):

第一个例子(作品)! 头文件(1) (像extern var-name top.h中添加的那样)

EXTERN_C const IID IID_IOPCServer;

C文件 (定义了var-name top_i.c)

 MIDL_DEFINE_GUID(IID, IID_IOPCServer,0x39c13a4d,0x011e,0x11d0,0x96,0x75,0x00,0x20,0xaf,0xd8,0xad,0xb3); 

另一个头文件(2) (包括头文件1 – top.h – 什么都不做 – 名字stop.h)

头文件的CPP文件(2) (包括头文件2 – 使用的var – 名称stop.cpp)

 hr = CoCreateInstance (clsid, NULL, CLSCTX_LOCAL_SERVER ,IID_IOPCServer, (void**)&m_IOPCServer); 

主CPP文件 (包括头文件2 – 不使用var-name test.cpp)这个Fule使用stop.cpp的函数。 Ans stop.cpp使用了extern var。

当我将这些文件添加到一个空的win32控制台项目 – 它的工作原理。 所有的精细!

在其他的例子

(相同的top.h,相同的top_i.c,相同的stop.h和相同的stop.cpp)我让node-gyp构build。

绑定Gyp:

 { "targets": [ { "target_name": "test", "sources": [ "src/top.h", "src/top_i.c", "src/stop.h", "src/stop.cpp", "src/test.cpp" ] } ] } 

在test.cpp里面就是这样的:

 #include <node.h> #include <v8.h> #include "stop.h" Handle<Value> Method(const Arguments& args) { HandleScope scope; return scope.Close(String::New("world")); } void init(Handle<Object> target) { NODE_SET_METHOD(target, "hello", Method); } NODE_MODULE(test, init); 

这个例子失败了Oo

 stop.obj : error LNK2001: unresolved external symbol "IID_IOPCServer". [D:\Dev\Workspaces\Nax\Github\node-test\build\test.vcxproj] stop.obj : error LNK2001: unresolved external symbol "IID_IOPCItemMgt". [D:\Dev\Workspaces\Nax\Github\node-test\build\test.vcxproj] stop.obj : error LNK2001: unresolved external symbol "IID_IOPCSyncIO". [D:\Dev\Workspaces\Nax\Github\node-test\build\test.vcxproj] D:\Dev\Workspaces\Nax\Github\node-test\build\Release\test.node : fatal error LNK1 120: 3 unresolved externals [D:\Dev\Workspaces\Nax\Github\node-test\build\test.vcxproj]