xinxinlx / openjpeg

Automatically exported from code.google.com/p/openjpeg
Other
0 stars 0 forks source link

Compilation fails on Windows with mingw32 gcc4.8 #361

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. svn checkout http://openjpeg.googlecode.com/svn/trunk/ openjpeg-read-only

2. run cmake-gui (all defaults but select mingw gcc compiler (4.8) 
3. mingw32-make on command prompt

What is the expected output? What do you see instead?
expected: clean build

[ 40%] Building C object Modules/ThirdParty/OpenJPEG/src/openjpeg/CMakeFiles/itk
openjpeg.dir/openjpeg.c.obj
D:\sources\InsightToolkit-4.5.2\Modules\ThirdParty\OpenJPEG\src\openjpeg\openjpe
g.c:155:1: error: conflicting types for 'DllMain'
 DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
 ^
In file included from c:\mingw\include\windows.h:62:0,
                 from D:\sources\InsightToolkit-4.5.2\Modules\ThirdParty\OpenJPE
G\src\openjpeg\openjpeg.c:29:
c:\mingw\include\winbase.h:1051:13: note: previous declaration of 'DllMain' was
here
 BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID);
             ^
Modules\ThirdParty\OpenJPEG\src\openjpeg\CMakeFiles\itkopenjpeg.dir\build.make:3
45: recipe for target 'Modules/ThirdParty/OpenJPEG/src/openjpeg/CMakeFiles/itkop
enjpeg.dir/openjpeg.c.obj' failed
mingw32-make[2]: *** [Modules/ThirdParty/OpenJPEG/src/openjpeg/CMakeFiles/itkope
njpeg.dir/openjpeg.c.obj] Error 1
CMakeFiles\Makefile2:3812: recipe for target 'Modules/ThirdParty/OpenJPEG/src/op
enjpeg/CMakeFiles/itkopenjpeg.dir/all' failed
mingw32-make[1]: *** [Modules/ThirdParty/OpenJPEG/src/openjpeg/CMakeFiles/itkope
njpeg.dir/all] Error 2
Makefile:145: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

What version of the product are you using? On what operating system?

Please provide any additional information below.

Windows 7 64bit 
MingW32 gcc 4.8
cmake 2.8.12

Original issue reported on code.google.com by mohammed...@gmail.com on 22 Jun 2014 at 11:08

GoogleCodeExporter commented 9 years ago
The issue report mention checking out openjpeg from svn , but the bug report 
contains code from third party app: ITK.

You need to check directly with ITK people about there custom version of 
openjpeg. Our openjpeg compiles with mingw (w32 & w64).

Original comment by mathieu.malaterre on 23 Jun 2014 at 7:25

GoogleCodeExporter commented 9 years ago
Hi Mathieu,

I also check out sources from this svn and got the same error. I can post that 
error message also.

Original comment by mohammed...@gmail.com on 23 Jun 2014 at 7:29

GoogleCodeExporter commented 9 years ago
Post the correct compilation output, please.

Original comment by mathieu.malaterre on 23 Jun 2014 at 7:34

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Using version.2.1 from svn with default cmake options I get:

C:\Users\jf\delmoi\openjpeg-build>mingw32-make
Scanning dependencies of target openjp2
[  2%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/bio.c.obj
[  5%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/cio.c.obj
[  8%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/dwt.c.obj
[ 11%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/event.c.obj
[ 14%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/image.c.obj
[ 17%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/invert.c.obj
[ 20%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/j2k.c.obj
[ 22%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/jp2.c.obj
[ 25%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/mct.c.obj
[ 28%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/mqc.c.obj
[ 31%] Building C object src/lib/openjp2/CMakeFiles/openjp2.dir/openjpeg.c.obj
C:\Users\jf\delmoi\openjpeg-read-only\src\lib\openjp2\openjpeg.c:135:1: error: 
conflicting types for 'DllMain'
 DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
 ^
In file included from c:\mingw\include\windows.h:62:0,
                 from C:\Users\jf\delmoi\openjpeg-read-only\src\lib\openjp2\openjpeg.c:35:
c:\mingw\include\winbase.h:1051:13: note: previous declaration of 'DllMain' was 
here
 BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID);
             ^
src\lib\openjp2\CMakeFiles\openjp2.dir\build.make:294: recipe for target 
'src/lib/openjp2/CMakeFiles/openjp2.dir/openjpeg.c.obj' failed
mingw32-make[2]: *** [src/lib/openjp2/CMakeFiles/openjp2.dir/openjpeg.c.obj] 
Error 1
CMakeFiles\Makefile2:91: recipe for target 
'src/lib/openjp2/CMakeFiles/openjp2.dir/all' failed
mingw32-make[1]: *** [src/lib/openjp2/CMakeFiles/openjp2.dir/all] Error 2
Makefile:136: recipe for target 'all' failed
mingw32-make: *** [all] Error 2

Replacing openjpeg.c:135 with 
  DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
instead of the original
  DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {

seemed to solve this issue with mingw gcc 4.8.1

Original comment by jf.pamb...@gmail.com on 25 Jun 2014 at 2:16

GoogleCodeExporter commented 9 years ago
Another workaround if to add an ifndef guard for mingw

#if !defined(OPJ_STATIC) && !defined(__MINGW32__)

Original comment by mohammed...@gmail.com on 25 Jun 2014 at 2:38

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2878.

Original comment by antonin on 16 Sep 2014 at 3:38