【问题标题】:An error happened when compiling the FreeImage library as static linking?将 FreeImage 库编译为静态链接时发生错误?
【发布时间】:2018-06-10 13:12:14
【问题描述】:

我正在尝试使用 Visual Studio 2015 编译 FreeImage v3.17.0 库以获取静态库文件,但存在一些问题。

库包如下:

我使用FreeImage.2013文件编译库,编译完成后我找到了这个结果Build: 16 succeeded, 4 failed, 0 up-to-date, 0 skipped。
FreeImage库本身没有编译但是其他第三方库已经编译了,但是出现错误:Error C1189 #error: Macro definition of snprintf conflicts with Standard Library function declaration ..\include\10.0.10240.0\ucrt\stdio.h

如何解决这个问题?

【问题讨论】:

    标签: c++ compiler-errors static-linking


    【解决方案1】:

    我在另一个与我的问题相似但主题不同的问题中找到了解决方案。 Take a look。

    解释问题:

    到目前为止,许多库和程序使用snprintf() 函数 将其定义为_snprintf(),因为支持_snprintf()。

    #define snprintf _snprintf
    

    snprintf() 在 Visual Studio 2015 (v140) 中得到认可。所以, snprintf() 现已正式支持,我们不应该定义它。
    这样做会使 stdio.h 中定义的新 snprintf() 函数黯然失色。

    解决方案:
    在所有项目文件中搜索此行#define snprintf _snprintf 并将其作为注释(将// 放在行首)。

    一个例子:

    【讨论】:

      猜你喜欢
      • 2013-04-17
      • 2012-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多