Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting types while building FreeImage with MinGW #644

Open
velika12 opened this issue Oct 14, 2016 · 1 comment
Open

Conflicting types while building FreeImage with MinGW #644

velika12 opened this issue Oct 14, 2016 · 1 comment

Comments

@velika12
Copy link

velika12 commented Oct 14, 2016

Hello! I have a problem trying to compile OpenCascade according to your instructions here. The only difference is that I use MinGW installed with Qt. The compilation stops with this error

[  5%] Building C object oce-win-bundle/FreeImage.cmake/CMakeFiles/FreeImage.dir
/__/libs/FreeImage/Source/LibJXR/image/sys/strcodec.c.obj
d:/oce/oce-win-bundle/libs/FreeImage/Source/LibJXR/image/sys/strcodec.c:674:5: error: conflicting types for '_byteswap_ulong' U32 _byteswap_ulong(U32 bits)
In file included from d:/oce/oce-win-bundle/libs/FreeImage/Source/LibJXR/image/sys/windowsmediaphoto.h:35:0,
                 from d:/oce/oce-win-bundle/libs/FreeImage/Source/LibJXR/image/sys/strcodec.h:35,
                 from d:/oce/oce-win-bundle/libs/FreeImage/Source/LibJXR/image/sys/strcodec.c:28:
d:/Programs/Qt/Qt5.5.0/Tools/mingw492_32/i686-w64-mingw32/include/stdlib.h:356:25: note: previous declaration of '_byteswap_ulong' was here
   unsigned long __cdecl _byteswap_ulong (unsigned long _Long);
                         ^
oce-win-bundle/FreeImage.cmake/CMakeFiles/FreeImage.dir/build.make:9238: recipe
for target `oce-win-bundle/FreeImage.cmake/CMakeFiles/FreeImage.dir/__/libs/Free
Image/Source/LibJXR/image/sys/strcodec.c.obj' failed
make[2]: *** [oce-win-bundle/FreeImage.cmake/CMakeFiles/FreeImage.dir/__/libs/Fr
eeImage/Source/LibJXR/image/sys/strcodec.c.obj] Error 1
CMakeFiles/Makefile2:1149: recipe for target 'oce-win-bundle/FreeImage.cmake/CMa
keFiles/FreeImage.dir/all' failed
make[1]: *** [oce-win-bundle/FreeImage.cmake/CMakeFiles/FreeImage.dir/all] Error
 2
Makefile:160: recipe for target `all' failed
make: *** [all] Error 2

Everything completes successfully if I don't specify FreeImage dependency with cmake, but I need this library. Could you help me to solve this problem?

@velika12
Copy link
Author

I have found the conflicting _byteswap_ulong in D:\oce\oce-win-bundle\libs\FreeImage\Source\LibJXR\image\sys\strcodec.c and just commented its definition. This action helped me to compile the code with FreeImage.

Maybe there is some bug in preprocessor checks? Here is the code

//================================================================
// Memory access functions
//================================================================
#if (defined(WIN32) && !defined(UNDER_CE) && (!defined(__MINGW32__) || defined(__MINGW64_TOOLCHAIN__) || defined(__MINGW64__))) || (defined(UNDER_CE) && defined(_ARM_))
// WinCE ARM and Desktop x86
#else
// other platform
#ifdef _BIG__ENDIAN_
#define _byteswap_ulong(x)  (x)
#else // _BIG__ENDIAN_
U32 _byteswap_ulong(U32 bits)
{
    U32 r = (bits & 0xffu) << 24;
    r |= (bits << 8) & 0xff0000u;
    r |= ((bits >> 8) & 0xff00u);
    r |= ((bits >> 24) & 0xffu);

    return r;
}
#endif // _BIG__ENDIAN_
#endif

I use Windows 7 64-bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant