小编Mar*_*nio的帖子

Visual C++下dllimport/dllexport及静态库编译

我迫切需要你的帮助。

我尝试使用 Visual C++ 2008 编译器在 Windows 上静态编译 poppler 库(特别是 qt4)。为了完成这个任务,我还需要静态编译一堆其他库作为 poppler 的依赖项。当我最终生成 poppler 的静态版本时,我在构建应用程序时遇到链接错误:

error LNK2019: unresolved external symbol "__declspec(dllimport)...
Run Code Online (Sandbox Code Playgroud)

我已经添加了新的包含路径并链接了 poppler-qt4.lib 但我仍然收到错误。寻找解决方案我在 stackoverflow 中找到了这个讨论

如何在 Visual C++ 2008 中链接静态库?

根据这些信息,我查看了库的包含文件(poppler 的依赖项,如 zlib、libpng、cairo 等),我发现在各种情况下,它们没有预处理器指令来指定静态版本图书馆。静态指令示例(openjpeg.h):

#if defined(OPJ_STATIC) || !(defined(_WIN32) || defined(WIN32) || defined(__WIN32__))
# define OPJ_API
# define OPJ_CALLCONV
#else
# define OPJ_CALLCONV __stdcall
# ifdef OPJ_EXPORTS
#  define OPJ_API __declspec(dllexport)
# else
#  define OPJ_API __declspec(dllimport)
# endif /* OPJ_EXPORTS */
#endif /* !OPJ_STATIC || !WIN32 */
Run Code Online (Sandbox Code Playgroud)

没有静态指令的示例(jpeg lib …

static poppler dllimport dllexport visual-c++-2008

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

dllexport ×1

dllimport ×1

poppler ×1

static ×1

visual-c++-2008 ×1