首页 > 解决方案 > 无法使用 make 构建诺基亚 HEIF 库

问题描述

我正在尝试在https://github.com/nokiatech/heif中构建 HEIF 库,但我没有运气。

我安装了 CMake 和最新版本的 MinGW。我正在按照构建库的步骤操作,但出现错误。

第一步,也就是这样:

cd heif/build
cmake --help
cmake ../srcs -G"<Generator listed by above command for your target platform>"

有效,但第二步,即:

cmake --build .

似乎正在工作,但是当它完成 41% 时,我收到此错误:

C:\Users\dantelo\Documents\heif-master\srcs\reader\heifstreamfile.cpp: In constructor 'HEIF::FileStream::FileStream(const char*)':
C:\Users\dantelo\Documents\heif-master\srcs\reader\heifstreamfile.cpp:44:9: error: 'fopen_s' was not declared in this scope
     fopen_s(&m_file, filename, "rb");
     ^~~~~~~
C:\Users\dantelo\Documents\heif-master\srcs\reader\heifstreamfile.cpp:44:9: note: suggested alternative: 'fopen'
     fopen_s(&m_file, filename, "rb");
     ^~~~~~~
     fopen
reader\CMakeFiles\heif_static.dir\build.make:93: recipe for target 'reader/CMakeFiles/heif_static.dir/heifstreamfile.cpp.obj' failed
mingw32-make.exe[2]: *** [reader/CMakeFiles/heif_static.dir/heifstreamfile.cpp.obj] Error 1
mingw32-make.exe[2]: Leaving directory 'C:/Users/dantelo/Documents/heif-master/build'
CMakeFiles\Makefile2:233: recipe for target 'reader/CMakeFiles/heif_static.dir/all' failed
mingw32-make.exe[1]: *** [reader/CMakeFiles/heif_static.dir/all] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/dantelo/Documents/heif-master/build'
Makefile:85: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2

我在 Windows 10 上,以防万一。我不知道为什么会这样。任何帮助表示赞赏

标签: cmakemingwnokiaheif

解决方案


它似乎fopen_s只存在于微软提供的 C 库中,即 MSVC 中。资料来源:有没有办法将 fopen_s() 与 GCC 一起使用,或者至少创建一个关于它的#define?

您最好的选择是切换到 MSVC,因为您拥有的代码显然从未使用 MinGW 测试过,因为后者无法编译它。

或者,如果您感到幸运,您可以使用一些#define技巧来转换fopen_s为标准fopen(请参阅链接问题中的答案)并希望这是代码中唯一的不兼容。


推荐阅读