Search code examples
c++node.jsnode-webkitnode-gyp

Import .dll for NWJS module causes '#import of type library is an unsupported Microsoft feature'


I have a legacy module for our app. It uses external dll from other software. If I run this command

 nw-gyp rebuild --target=0.34.3 --msvs_version=2019 --target_arch=ia32 --arch=ia32

it produces some warnings, but compiles (where 0.34.3 is a nw.js version)

But if I run this command

nw-gyp rebuild --target=0.68.0 --msvs_version=2019 --target_arch=ia32 --arch=ia32

I receive following errors

clang-cl : warning : argument unused during compilation: '/Gm-' [-Wunused-command-line-argument] 
clang-cl : warning : argument unused during compilation: '/external:W3' [-Wunused-command-line-argument] 
..\src\atol8.cpp(2,2): error : #import of type library is an unsupported Microsoft feature 
..\src\atol8.cpp(27,2): error : unknown type name 'CLSID' 
..\src\atol8.cpp(28,2): error : unknown type name 'IDispatch' 
..\src\atol8.cpp(29,2): error : use of undeclared identifier 'FprnM1C' 
..\src\atol8.cpp(30,2): error : unknown type name 'DISPPARAMS' 

As I understand, main error is that compiler can't import external library, throws #import of type library is an unsupported Microsoft feature and it causes other errors.

atol8.cpp code

#import "D:\Program Files (x86)\ATOL\Drivers8\Bin\FprnM1C.dll" raw_interfaces_only

#include <node.h>
#include <iostream>
#include <locale>
#include <string>
#include <wchar.h>

std::locale ru("rus_rus.1251");

namespace Atol8Drv {

using v8::Exception;
using v8::FunctionCallbackInfo;
using v8::Isolate;
using v8::Local;
using v8::Number;
using v8::Object;
using v8::String;
using v8::Value;
using v8::HandleScope;
using v8::Array;
using v8::Integer;
using v8::Boolean;

CLSID clsid;
IDispatch *pWApp;
FprnM1C::IFprnM45 *pMiDrv;
/** other code is not relevant **/

I am not a C programmer and the person who originally wrote this module is not available, but as I remember there should be a parameter for the nw-gyp or node-gyp and I can't nor remember or google how to resolve this error.

I'm ready to answer your questions and provide additional information if required.


Solution

  • Finally, I found a way to compile this module. The problem is in clang.

    If I try to compile it with --clang=false option - it works perfectly.

    So, if someone in the future will stuck with the same error, command for compilation should be:

    nw-gyp rebuild --target=0.68.0 --msvs_version=2019 --target_arch=ia32 --arch=ia32 --clang=false