CImg 的编译错误
Compilation errors with CImg
我是第一次使用 CImg
库,使用仅包含 CImg.h 的简单测试程序时出现编译错误。为什么?我该如何解决这个问题?
程序代码:
#include "../headers/CImg.h"
using namespace cimg_library;
int main()
{
return 0;
}
编译错误:
In function 'FILE* cimg_library::cimg::fopen(const char*, const char*)':
5065|error: '_fileno' was not declared in this scope
In function 'int cimg_library::cimg::fseek(FILE*, INT_PTR, int)':
5093|error: '_fseeki64' was not declared in this scope
In function 'INT_PTR cimg_library::cimg::ftell(FILE*)':
5102|error: '_ftelli64' was not declared in this scope
这是在装有 64 位 Windows 8.1 的 PC 上完成的。
命令:
g++.exe -Wall -fexceptions -g -std=c++11 -c "D:informaticsProjectsimage experimentsRectangle to circle stretchersourcesmain.cpp" -o objDebugsourcesmain.o
我在没有-std=c++11
部分的情况下尝试了这个,我得到了 2 个错误而不是 3 个错误。我不明白5065|error: '_fileno' was not declared in this scope
.如果我用-std=gnu++11
替换它,也会发生同样的情况
我也在我的笔记本电脑上尝试了它,它运行 64 位版本的 Windows 7,那里也发生了同样的情况。
到目前为止,我对第一个错误有一个解决方法,但对其他两个错误没有任何解决方法。
在 CodeBlock 16.01 的情况下,stdio.h 包含行
#if __MSVCRT_VERSION__ >= 0x800
_CRTIMP int __cdecl __MINGW_NOTHROW _fseek_nolock (FILE*, long, int);
_CRTIMP long __cdecl __MINGW_NOTHROW _ftell_nolock (FILE*);
_CRTIMP int __cdecl __MINGW_NOTHROW _fseeki64 (FILE*, __int64, int);
_CRTIMP __int64 __cdecl __MINGW_NOTHROW _ftelli64 (FILE*);
_CRTIMP int __cdecl __MINGW_NOTHROW _fseeki64_nolock (FILE*, __int64, int);
_CRTIMP __int64 __cdecl __MINGW_NOTHROW _ftelli64_nolock (FILE*);
#endif
即,除非__MSVCRT_VERSION__
至少0x800,否则不会声明这些函数。以下方法可能有效(至少对于 CodeBlocks 16.01 是这样)
#if defined(__MINGW32__)
#define __MSVCRT_VERSION__ 0x800
#define _WIN32_WINNT 0x0500
#endif
// if needed
// #define _fileno fileno
#include "CImg.h"
如果 stdio.h 不包含 _fseeki64
和其他人的声明,则
- 使用不使用
_fseeki64
的 CImg 1.6.9 , - 升级 GCC/G++,或
- 为
_fseeki64
提供自己的实现(如果可以在某处找到这样的实现)。
相关文章:
- 用MacOS Mojave编译C++:致命错误:mpi.h:没有这样的文件或目录
- std::is_base_of表示ctor编译错误
- 我的项目不会像"undefined reference to `grpc::g_core_codegen_interface'"那样使用未定义的引用错误进行编译
- 在没有定义返回类型的函数中返回布尔值,并将结果保存在无错误的char编译中-为什么
- Qt5:使用QCommandLineParser类时出现奇怪的编译错误
- Qt Cmake 错误编译"GuiSupportQt not found"
- Opengl 精度转换错误编译错误 E0415
- 库将ARM架构错误编译为架构X64
- RT 音频 Mac 错误 g++ 编译错误
- 错误编译Boost.log
- 错误编译QT创建者 / QT窗口小部件示例
- 错误编译MIPS32
- Visual Studio 2013 中的错误(编译和运行代码)
- 链接错误编译qt项目在visual 2010
- 无法用模板错误编译nsgmls
- 奇怪的错误.编译失败
- 如果有人调用c++中的方法,则强制错误(编译时)
- 来自autoconf测试的错误编译命令
- 时间限制超出错误C++编译
- SFML 2.3 和 CodeBlocks 错误编译