You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级NWJS版本后导入.dll模块编译报错:#import类型库不受支持

NWJS升级后nw-gyp编译遗留模块失败问题

问题背景

我们有一个依赖外部DLL的遗留模块,使用nw-gyp编译时出现版本兼容问题:

  • 基于NWJS 0.34.3执行以下命令时,仅出现若干警告但编译成功:
    nw-gyp rebuild --target=0.34.3 --msvs_version=2019 --target_arch=ia32 --arch=ia32
  • 升级到NWJS 0.68.0执行相同参数命令时,编译失败:
    nw-gyp rebuild --target=0.68.0 --msvs_version=2019 --target_arch=ia32 --arch=ia32

错误信息

编译抛出的核心错误及连锁错误如下:

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' 

核心问题是编译器不支持#import导入类型库,进而引发后续类型未声明的错误。

相关代码片段

atol8.cpp中的关键代码如下:

#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 **/

求助需求

本人非C语言程序员,原模块开发者已无法联系,记得nw-gyp或node-gyp有参数可解决此类编译器不支持#import的问题,但无法回忆或搜索到具体方法,恳请提供解决方案,可补充更多相关信息。

内容的提问来源于stack exchange,提问作者Rulisp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 19:40:19