我正在尝试在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上使用,以防万一。我不知道为什么会这样。任何帮助表示赞赏
[似乎fopen_s
仅存在于Microsoft提供的C库中,即MSVC中。来源:Is there a way to use fopen_s() with GCC or at least create a #define about it?
您最好的选择就是切换到MSVC,因为您拥有的代码显然从未用MinGW进行过测试,因为后者无法编译。
或者,如果您感到幸运,可以使用一些#define
技巧将fopen_s
转换为标准fopen
(请参阅链接问题中的答案),并希望这是代码中唯一的不兼容性。