2

have problem with an unresolved extern.

the problem -> an header (myImpressiveHeaderFile.h) file tolds that he cannot find a symbol. But another file (holys_i.c) a c-file exists in this project and holds this symbols.

if i create a new win32-console-project (empty) and add these files (and a third file, with a main function and include the header file) it works perfectly.

BUT -> if i let node-gyp build the project (same files except main file xD that is a node spcefic file with v8.h and node.h - but included header file too) - i got errors (LNK 2001 see above).

it seems that the linker gots the c-file not or later if i create it with node-gyp? or does node-gyp not compile c-files? that cant be? or?

Do you have any ideas what i can do/test/check?

EDIT (add example):

First Example (works)! Header File (1) (added sth like an extern var - name top.h)

EXTERN_C const IID IID_IOPCServer;

C-File (defined the var - name top_i.c)

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

Another Header File (2) (included Header File 1 - top.h - do nothing relevant - name stop.h)

CPP File of Header File (2) (included Header File 2 - used var - name stop.cpp)

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

Main CPP File (includes Header File 2 - dont used var - name test.cpp) This Fule uses Functions of stop.cpp. Ans stop.cpp used the extern var.

When i add these file to a empty win32 console project - it works. ALL FINE!

BUT in other example

(same top.h, same top_i.c, same stop.h and same stop.cpp) i let node-gyp build.

Binding Gyp:

{
  "targets": [
    {
      "target_name": "test",

      "sources": [ 


        "src/top.h",
        "src/top_i.c",

        "src/stop.h",
        "src/stop.cpp",

        "src/test.cpp"
      ]
    }
  ]
}

inside of test.cpp sth like this:

#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);

This Example fails 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]
4

0 回答 0