简体   繁体   English

尽管在dumpbin.exe中报告了链接功能问题

[英]Issues linking functions despite being reported in dumpbin.exe

I'm having serious issues linking a library despite doing the same routine I've done with all other libraries. 尽管执行与其他所有库相同的例程,但是在链接库时遇到了严重的问题。 The library is libmupdf.lib (a pdf viewing library). 该库是libmupdf.lib(一个pdf查看库)。

Anyways, I have compiled the .lib and added it as a "Additional Dependencies" in the linker, added the header includes as additional includes, and specified where VSC++ should look for the libraries. 无论如何,我已经编译了.lib并将其作为链接器中的“其他依赖项”添加,添加了头文件头作为附加头文件,并指定了VSC ++在何处查找库。 It doesn't complain about not finding libmupdf.lib as linking begins. 它不会抱怨在链接开始时找不到libmupdf.lib。

I then get the standard looking linker error: 然后,我得到标准外观的链接器错误:

error LNK2019: unresolved external symbol "int __cdecl fz_strlcat(char *,char const *,int)" (?fz_strlcat@@YAHPADPBDH@Z) referenced in function "void __cdecl winerror(struct pdfapp_s *,int)" (?winerror@@YAXPAUpdfapp_s@@H@Z)

However, if I do the below I see that fz_strlcat is indeed in libmupdf.lib but prepended with a _ .... is this normal? 但是,如果执行以下操作,我会发现fz_strlcat确实在libmupdf.lib中,但以_ ....开头是否正常?

C:\Program Files\Microsoft Visual Studio 10.0\VC>dumpbin /SYMBOLS "libmupdf.lib" | "grep.exe" fz_strlcat
033 00000000 SECTC  notype ()    External     | _fz_strlcat
060 00000000 UNDEF  notype ()    External     | _fz_strlcat
381 00000000 UNDEF  notype ()    External     | _fz_strlcat

Note: I tried changing the call to fz_strlcat to _fz_strlcat and made the change in the header, but still no linkage. 注意:我尝试将对fz_strlcat的调用更改为_fz_strlcat,并在标头中进行了更改,但仍然没有链接。

Any clues or help is appreciated at this point. 在此感谢您提供任何线索或帮助。 Thanks! 谢谢!

You seem to be missing the Fitz library. 您似乎缺少Fitz库。 This is part of the MuPDF project but it builds as a separate LIB file. 这是MuPDF项目的一部分,但作为单独的LIB文件构建。

Edit 编辑
I stand corrected: in looking at the vcproj files on MuPDF's GIT repository, it appears that libmupdf.lib builds as one big library, with all the Fitz stuff as well as even 3rd party libraries per-se. 我的立场是正确的:在查看MuPDF的GIT存储库中的vcproj文件时,似乎libmupdf.lib是一个大型库,包含所有Fitz内容以及3rd party库。

Now... in looking in more detail at the error message, this looks like a C vs C++ linkage issue . 现在...在更详细地查看错误消息时, 这看起来像是C vs C ++的链接问题 Am I wrong in seeing that the fz_strlcat function is called from C++, whereby fitz.h has maybe not been included with the extern "C" {} linkage? 看到从C ++调用了fz_strlcat函数,这可能是错误的,因此extern "C" {}链接中可能未包含fitz.h?
What happen in such case is that C++ produces a mangled name for linkage ( fz_strlcat@@YAHPADPBDH@Z ), one that includes codes for the full signature of the function (parameter types etc.). 在这种情况下,发生的情况是C ++为链接生成了错误的名称( fz_strlcat@@YAHPADPBDH@Z ),其中包括用于函数完整签名的代码(参数类型等)。
By adding 通过增加

extern "C" {
   #include "fitz.h"   //  or whatever other include file which in turn includes fitz.h
}

around the includes that pertain to functions and variables in the libmupdf library, the LNK error should disappear. 围绕与libmupdf库中的函数和变量有关的包含,LNK错误应消失。

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

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