Compilation errors with CImg

后端 未结 1 1329
Happy的楠姐
Happy的楠姐 2021-01-25 06:40

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?

Progra

相关标签:
1条回答
  • 2021-01-25 07:14

    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).
    0 讨论(0)
提交回复
热议问题