简体   繁体   English

在 Visual Studio 2019 上使用 XLCALL32.LIB 时出现 LNK2019 错误

[英]LNK2019 error when using XLCALL32.LIB on Visual Studio 2019

I am using an old C++ library that makes use of an external XLCALL32.LIB library file.我正在使用一个旧的 C++ 库,它利用了一个外部 XLCALL32.LIB 库文件。 This external library hasn't been updated in many years.这个外部库已经很多年没有更新了。

The comment in the XLCALL.H header file says below: /* ** Microsoft Excel Developer's Toolkit ** Version 5.0 */ XLCALL.H 头文件中的注释如下: /* ** Microsoft Excel Developer's Toolkit ** Version 5.0 */

I am using VS 2019 for a Debug x64 build and my linker errors are below:我正在使用 VS 2019 进行 Debug x64 构建,我的链接器错误如下:

error LNK2019: unresolved external symbol Excel4 referenced in function xxxxx error LNK2019: unresolved external symbol Excel4v referenced in function xlAutoOpen错误 LNK2019:在函数 xxxxx 中引用了未解析的外部符号 Excel4 错误 LNK2019:在函数 xlAutoOpen 中引用了未解析的外部符号 Excel4v

A Debug Win32 build was successful but I get below strange error when loading the XLL file in Excel.调试 Win32 构建成功,但在 Excel 中加载 XLL 文件时出现以下奇怪错误。

"Unable to initialize cable order data. Missing static data" “无法初始化电缆订单数据。缺少静态数据”

I am using Microsoft Excel for Office 365 32-bit.我正在使用 Microsoft Excel for Office 365 32 位。

I couldn't find any help online for this error and so I am trying a x64 build but I am stuck with the linker errors mentioned above.我无法在线找到有关此错误的任何帮助,因此我正在尝试 x64 构建,但我遇到了上面提到的链接器错误。

Can someone advise if I should be doing a 32-bit build and if Microsoft has a newer XLCALL32.lib that I should be using.有人可以建议我是否应该进行 32 位构建,以及 Microsoft 是否有我应该使用的更新的 XLCALL32.lib。

Greatly appreciate your help!非常感谢您的帮助!

You cannot use a 32-bit DLL or import library (LIB) in a 64-bit build.您不能在 64 位版本中使用 32 位 DLL 或导入库 (LIB)。 So, yes, you must do a 32-bit build if you plan to use this LIB.所以,是的,如果您打算使用这个 LIB,您必须进行 32 位构建。 You will also need to do a 32-bit build anyway, since you're targeting a 32-bit version of Office.无论如何,您还需要进行 32 位构建,因为您的目标是 32 位版本的 Office。

Additionally, since this LIB was surely built with an older version of the compiler, it is not surprising that you would be seeing errors.此外,由于这个 LIB 肯定是用旧版本的编译器构建的,因此您会看到错误也就不足为奇了。 LIB files do not maintain binary compatibility across compiler versions. LIB 文件不保持跨编译器版本的二进制兼容性。 (And especially not across major version releases of the compiler.) 尤其是在编译器的主要版本发行版中。)

I would recommend obtaining a newer version of this library.我建议获取此库的较新版本。 The documentation is here .文档在这里 It should be shipped with the Microsoft Office SDK.它应该随 Microsoft Office SDK 一起提供。 Download the correct SDK matching the version number of Office that you are targeting with your C++ code.下载与您的 C++ 代码面向的 Office 版本号匹配的正确 SDK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM