编译错误与CImg [英] Compilation errors with CImg

查看:1816
本文介绍了编译错误与CImg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用CImg库,我使用简单的测试程序(包括CImg.h)获得编译错误。这是为什么?如何解决此问题?



计划代码:

  #include ../headers/CImg.h
using namespace cimg_library;
int main()
{
return 0;
}

编译错误:

 在函数'FILE * cimg_library :: cimg :: fopen(const char *,const char *)':
5065 | error:'_fileno' scope
在函数'int cimg_library :: cimg :: fseek(FILE *,INT_PTR,int)':
5093 |错误:'_fseeki64'未在此范围中声明
在函数' INT_PTR cimg_library :: cimg :: ftell(FILE *)':
5102 |错误:'_ftelli64'未在此范围内声明

这是在64位Windows 8.1的电脑上完成的。



命令:

  g ++。exe -Wall -fexceptions -g -std = c ++ 11 -cD:\informatics\Projects\image experiments \Rectangle to circle stretcher\sources\main.cpp-o obj\Debug\sources\main.o 

我试过这个没有 -std = c ++ 11 部分,我得到2错误,而不是3.我不会得到 5065 |错误:'_fileno'未在此作用域中声明。如果我用 -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

//如果需要
// #define _fileno fileno

#includeCImg.h

如果 stdio.h 不包含 _fseeki64 和其他人的声明




  • 使用CImg 1.6.9不使用 _fseeki64

  • 升级gcc / g ++或

  • _fseeki64 (如果可以在某处找到)。


I am using the CImg library for the first time and I get compilation errors with a simple test program that just includes CImg.h. Why is that? How can I fix this?

Program code:

#include "../headers/CImg.h"
using namespace cimg_library;
int main()
{
    return 0;
}

Compilation errors:

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

This was done on a PC with a 64 bit Windows 8.1.

Command:

g++.exe -Wall -fexceptions -g -std=c++11  -c "D:\informatics\Projects\image experiments\Rectangle to circle stretcher\sources\main.cpp" -o obj\Debug\sources\main.o

I tried this without the -std=c++11 part and I get 2 errors instead of 3. I don't get 5065|error: '_fileno' was not declared in this scope. Same happens if I replace it with -std=gnu++11

I also tried it on my laptop, which runs a 64 bit version of windows 7, and the same happens there.

So far, I have a work around for the first error, but nothing for the other two.

解决方案

In case of CodeBlock 16.01 stdio.h contains lines

#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

i.e. those functions are not declared unless __MSVCRT_VERSION__ is at least 0x800. The following might work (at least it did for CodeBlocks 16.01)

#if defined(__MINGW32__)
#define __MSVCRT_VERSION__ 0x800
#define _WIN32_WINNT 0x0500
#endif

// if needed
// #define _fileno fileno

#include "CImg.h"

If stdio.h does not contain declaration for _fseeki64 and others, either

  • Use CImg 1.6.9 that does not use _fseeki64,
  • upgrade gcc/g++, or
  • provide an own implementation for _fseeki64 (if such one can be found somewhere).

这篇关于编译错误与CImg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆