Author Topic: Compiling Magic Lantern with Cygwin/MinGW-64  (Read 15082 times)

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3146
  • 60Da / 1100D / EOSM
Re: Compiling Magic Lantern with Cygwin/MinGW-64
« Reply #25 on: March 22, 2016, 03:47:07 AM »
I'm pretty sure that's a spambot

vstrglv

  • Member
  • ***
  • Posts: 128
Re: Compiling Magic Lantern with Cygwin/MinGW-64
« Reply #26 on: November 22, 2016, 07:54:32 AM »
I am trying to compile with
 "hg clone -r unified https://bitbucket.org/hudson/magic-lantern
cd magic-lantern/platform/5D3.113/
make clean && make zip",
but there is an error for raw_rec.mo:
Code: [Select]
[ GCC      ]   raw2dng
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lm
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lcygwin
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libadvapi32.a when searching for -ladvapi32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libadvapi32.a when searching for -ladvapi32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libadvapi32.a when searching for -ladvapi32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -ladvapi32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libshell32.a when searching for -lshell32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libshell32.a when searching for -lshell32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libshell32.a when searching for -lshell32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lshell32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libuser32.a when searching for -luser32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libuser32.a when searching for -luser32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libuser32.a when searching for -luser32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -luser32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libkernel32.a when searching for -lkernel32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libkernel32.a when searching for -lkernel32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/w32api/libkernel32.a when searching for -lkernel32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lkernel32
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0//libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libgcc_s.dll.a when searching for -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc_s
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0//libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-pc-cygwin/5.3.0/libgcc.a when searching for -lgcc
/usr/lib/gcc/x86_64-pc-cygwin/5.3.0/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status
Makefile:16: recipe for target 'raw2dng' failed
make[4]: *** [raw2dng] Error 1

********************************************************
WARNING: module raw_rec failed to build, deleting
********************************************************
What is wrong?
Canon 5D3, SanDisk Extreme PRO,160MB/s, 256GB

dfort

  • Hero Member
  • *****
  • Posts: 1552
Re: Compiling Magic Lantern with Cygwin/MinGW-64
« Reply #27 on: November 22, 2016, 09:17:20 AM »
That's odd, it is building raw2dng.exe. As I recall that doesn't build properly with a 64-bit compiler.

I can't reproduce the error because my PC is a very slow and old 32-bit laptop. Here are some things you can try.

Go into the modules/lv_rec directory and open up the file named Makefile with a text editor. Find this line:

Code: [Select]
all:: raw2dng
and comment it out like this:

Code: [Select]
# all:: raw2dng
That doesn't solve the issue with being able to build raw2dng with a 64-bit compiler. For that you can look for this block of code:

Code: [Select]
raw2dng.exe: FORCE
$(call build,MINGW,$(MINGW_GCC) -c $(SRC_DIR)/chdk-dng.c -m32 -mno-ms-bitfields -O2 -Wall -I$(SRC_DIR))
$(call build,MINGW,$(MINGW_GCC) -c raw2dng.c -m32 -mno-ms-bitfields -O2 -Wall -I$(SRC_DIR) -D_FILE_OFFSET_BITS=64)
$(call build,MINGW,$(MINGW_GCC) raw2dng.o chdk-dng.o -o raw2dng.exe -lm -m32)

and change that second "call build" line to include the -std=c99 switch:

Code: [Select]
$(call build,MINGW,$(MINGW_GCC) -c raw2dng.c -m32 -mno-ms-bitfields -O2 -Wall -I$(SRC_DIR) -D_FILE_OFFSET_BITS=64 -std=c99)
If neither of these works you can delete your 64-bit Cygwin installation and install a 32-bit version in its place.

Please post which "fix" worked for you.
EOSM.202 EOSM.203 700D.115 5D3.*

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 9730
  • 5D Mark Free
Re: Compiling Magic Lantern with Cygwin/MinGW-64
« Reply #28 on: November 22, 2016, 09:35:03 AM »
Searching for (parts of) the error message is a good idea. Just be careful with dashes, e.g. search for:
Code: [Select]
x86_64-pc-cygwin/bin/ld: "cannot find -lgcc"

Without quotes, -lgcc in the search string means "return pages that do not contain lgcc".

http://stackoverflow.com/questions/30119573/compile-32bit-code-from-cygwin64

vstrglv

  • Member
  • ***
  • Posts: 128
Re: Compiling Magic Lantern with Cygwin/MinGW-64
« Reply #29 on: November 22, 2016, 05:33:18 PM »
Thank you for reply dfort and alex. dfort, i have tried your fixes, but it does not work. No raw2dng.exe, no raw_rec.mo. May be i have to install cygwin32.
Now commented # all:: raw2dng in modules/raw_rec and raw_rec.mo appeared!
Canon 5D3, SanDisk Extreme PRO,160MB/s, 256GB

dfort

  • Hero Member
  • *****
  • Posts: 1552
Re: Compiling Magic Lantern with Cygwin/MinGW-64
« Reply #30 on: November 22, 2016, 08:11:57 PM »
I don't have a 64-bit PC to test out these issues. On the tutorial I included this:

Quote
...What if you have a 64-bit system?
Note that most module exe helpers are targeted for x86 code, i.e. even if you run cygwin x64 (which you should on a x64 Windows) you need to use the i686 mingw toolchain.
Please leave feedback if you get mingw64-x86-64-gcc-core working and on which command line tools--it is going to need some tweaks to the ML source code.

That might be a little confusing but basically it means that if you are going to compile the command line tools, like raw2dng.exe, it has been tested to work with the 32-bit compiler (i686) but not with the 64-bit compiler (x64).

I wasn't aware that building a platform automatically builds raw2dng but now that I see that does. It was the same with cr2hdr until just recently with this commit. The other popular command line tool, mlv_dump, isn't built when a platform is compiled so I thought that was preferred method. Build rules for raw2dng are in both raw_rec and lv_rec so perhaps we should look into that.

Of course this doesn't resolve another issue which is that raw2dng.exe can't be built with a 64-bit compiler. I'm not sure if this is true for all 64-bit compilers but it is a problem when I cross compile a Windows binary on a Mac:

Code: [Select]
[ MINGW    ]   raw2dng.exe
raw2dng.c: In function 'find_and_fix_cold_pixels':
raw2dng.c:1213:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
         for (int y = 0; y < h; y++)
         ^
raw2dng.c:1213:9: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
raw2dng.c:1215:13: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
             for (int x = 0; x < w; x++)
             ^
raw2dng.c:1233:5: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
     for (int p = 0; p < cold_pixels; p++)
     ^
raw2dng.c:1243:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
         for (int i = -4; i <= 4; i++)
         ^
raw2dng.c:1245:13: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
             for (int j = -4; j <= 4; j++)
             ^
make: *** [raw2dng.exe] Error 1

Simply adding the "-std=c99" switch worked for me but it should be tested on other 64-bit systems.

Thank you for reply dfort and alex. dfort, i have tried your fixes, but it does not work. No raw2dng.exe, no raw_rec.mo. May be i have to install cygwin32.
Now commented # all:: raw2dng in modules/raw_rec and raw_rec.mo appeared!

I'm a bit confused with that comment. So commenting out the "all" rule worked for you? This should build the raw_rec module but not raw2dng.exe.

What was it that didn't work, adding the "-std=c99" switch?

@alex - Which compiler are you using on Linux and are you cross compiling Windows binaries? Would adding the "-std=c99" switch to the raw2dng make rules have any negative consequences? It seems to work fine with the Windows binaries that I have compiled on my Mac.
EOSM.202 EOSM.203 700D.115 5D3.*

vstrglv

  • Member
  • ***
  • Posts: 128
Re: Compiling Magic Lantern with Cygwin/MinGW-64
« Reply #31 on: November 22, 2016, 08:28:55 PM »
So commenting out the "all" rule worked for you? This should build the raw_rec module but not raw2dng.exe.

What was it that didn't work, adding the "-std=c99" switch?


Yes, if i comment "all", raw_rec module  is built but not raw2dng.exe
If add "-std=c99" switch, raw_rec module  is not built.
But it is possible to compile raw2dng.exe by "make raw2dng.exe" from modules/raw_rec folder. The same for cr2hdr.exe from modules/dual_iso
Canon 5D3, SanDisk Extreme PRO,160MB/s, 256GB

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 9730
  • 5D Mark Free
Re: Compiling Magic Lantern with Cygwin/MinGW-64
« Reply #32 on: November 22, 2016, 08:29:37 PM »
@alex - Which compiler are you using on Linux and are you cross compiling Windows binaries?

The one from Makefile. The nightly build server compiles cr2hdr.exe and mlv_dump.exe, but raw2dng binaries weren't updated lately (maybe I should set up a job for it as well).

Quote
Would adding the "-std=c99" switch to the raw2dng make rules have any negative consequences?

Nope.

BTW, gcc 5.x uses -std=gnu11 by default, whereas gcc 4.x uses -std=gnu89.

dfort

  • Hero Member
  • *****
  • Posts: 1552
Re: Compiling Magic Lantern with Cygwin/MinGW-64
« Reply #33 on: November 22, 2016, 09:27:45 PM »
Ok--looks like @vstrglv is able to compile ML so I'll test some Makefile changes that should keep these issues from coming up again.
EOSM.202 EOSM.203 700D.115 5D3.*

vstrglv

  • Member
  • ***
  • Posts: 128
Re: Compiling Magic Lantern with Cygwin/MinGW-64
« Reply #34 on: December 06, 2016, 04:20:38 PM »
Quote
Ok--looks like @vstrglv is able to compile ML so I'll test some Makefile changes that should keep these issues from coming up again.
Thank you. Now this error has gone.
Canon 5D3, SanDisk Extreme PRO,160MB/s, 256GB