Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: Audionut on September 09, 2013, 04:54:56 PM

Title: Help compiling cr2hdr
Post by: Audionut on September 09, 2013, 04:54:56 PM
Using the ML VM, I've downloaded mingw development environment and pretty sure I have the paths setup right.

Do I need to change anything in the makefile?

edit:  Got it.  Needed .exe added to CR2HDR_BIN=cr2hdr.exe
Title: Re: Help compiling cr2hdr
Post by: RenatoPhoto on September 10, 2013, 04:20:40 AM
Quote from: Audionut on September 09, 2013, 04:54:56 PM
Using the ML VM, I've downloaded mingw development environment and pretty sure I have the paths setup right.

Do I need to change anything in the makefile?

edit:  Got it.  Needed .exe added to CR2HDR_BIN=cr2hdr.exe
I had the same problem and never solved it.  Where did you add the CR2HDR_BIN=cr2hdr.exe ?
Title: Re: Help compiling cr2hdr
Post by: Audionut on September 10, 2013, 05:52:39 AM
Makefile.cr2hdr

# Makefile for the cr2hdr software

CR2HDR_BIN=cr2hdr.exe
HOSTCC=gcc


When you have installed the mingw development environment, you need to copy the "i686-w64-mingw32" folder from "file system/usr/" to the magic-lantern directory (same place as gcc-arm-none-eabi) and either restructure the directory structure to match that in the makefile, or edit the makefile pointing to the directory location.


Quoteifdef CROSS
   HOSTCC=~/mingw-w32/bin/i686-w64-mingw32-gcc
   CR2HDR_BIN=cr2hdr.exe

Then just run make for the modules as per normal and the exe is generated :)
Title: Re: Help compiling cr2hdr
Post by: a1ex on September 10, 2013, 07:23:04 AM
Quote from: Audionut on September 09, 2013, 04:54:56 PM
edit:  Got it.  Needed .exe added to CR2HDR_BIN=cr2hdr.exe

make cr2hdr.exe should be enough.
Title: Re: Help compiling cr2hdr
Post by: Audionut on September 10, 2013, 07:31:18 AM
That generated permission errors in the VM.

Quote/bin/sh: 1: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: Permission denied
Title: Re: Help compiling cr2hdr
Post by: RenatoPhoto on September 10, 2013, 02:15:19 PM
Quote from: a1ex on September 10, 2013, 07:23:04 AM
make cr2hdr.exe should be enough.
First I make and make clean in dual_iso module
Second I make cr2hdr.exe

I get the following error.

Quotemagiclantern@magiclantern-VirtualBox:~/magic-lantern/modules/dual_iso$ make cr2hdr.exe
[ RM ]  cr2hdr cr2hdr.exe  ../../src/chdk-dng-host.o  cr2hdr-host.o  dcraw-bridge-host.o  exiftool-bridge-host.o
CROSS=1 make cr2hdr.exe
make[1]: Entering directory `/home/magiclantern/magic-lantern/modules/dual_iso'
[ RM ]  cr2hdr.exe cr2hdr.exe.exe  ../../src/chdk-dng-host.o  cr2hdr-host.o  dcraw-bridge-host.o  exiftool-bridge-host.o
[ HOSTCC   ]   ../../src/chdk-dng-host.o
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 1: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: ELF: not found
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 2: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: H���%�1h��%: not found
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 3: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: �1h��%�1h��%��1h��%��1h��%��1h��%��1h��%��1h�1�I��^H��H���PTI����CH����CH��P�@�����H�H�9�1H��t��H�������������UH��SH��=: not found
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 4: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: ���P���: not found
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 5: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: ���1H�[��U�p�JH��H��t���q���P胦: not found
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 6: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: Syntax error: ")" unexpected
make[1]: *** [../../src/chdk-dng-host.o] Error 2
make[1]: Leaving directory `/home/magiclantern/magic-lantern/modules/dual_iso'
make: *** [cr2hdr.exe] Error 2

I guess the VM machine does not include ELF?
Is there a (get apt) command to get the elf installed?
Title: Re: Help compiling cr2hdr
Post by: Audionut on September 10, 2013, 03:06:12 PM
You still need to install the mingw development environment and fix the path.

Use the Ubuntu software center in the VM.  Search for mingw.  Top option.

(http://i.imgur.com/TmKdJN4.png)
Title: Re: Help compiling cr2hdr
Post by: RenatoPhoto on September 11, 2013, 03:46:06 AM
Quote from: Audionut on September 10, 2013, 03:06:12 PM
Use the Ubuntu software center in the VM.  Search for mingw.  Top option.

thanks for your help. 
I had already downloaded mgwin and put it in the the directory structure required...  but just in case I installed it again from the software center.  The installation completed but there is no compilers in the bin directory... i686-w64-mingw32-gcc is not there.  Although I do have it in the installation which I did previously.

Anyway as I said before, it seems that ELF is still missing...
Title: Re: Help compiling cr2hdr
Post by: Audionut on September 11, 2013, 04:39:18 AM
Quote from: RenatoPhoto on September 11, 2013, 03:46:06 AM
The installation completed but there is no compilers in the bin directory... i686-w64-mingw32-gcc is not there.

It's in "file system/usr/"  You have to copy the folders from there to the required directory structure that matches what's in the makefile.

(http://i.imgur.com/iD5P6tN.png)

Your elf errors will go away when you get the correct folders into the correct directory structure ;)
Title: Re: Help compiling cr2hdr
Post by: RenatoPhoto on September 11, 2013, 05:12:15 AM
Thanks, the images are helpful in illustrating the file structure.  I copied the whole  i686-w64-mingw32 directory from usr/  This directory contained the three folders: include, lib, and libsrc.

So now I have the following directory structure:

magiclantern
  mingw-32
    bin
      i686-w64-mingw32
        include
        lib
        libsrc

The error continues as follows:  (The same as before)

make[1]: Entering directory `/home/magiclantern/magic-lantern/modules/dual_iso'
[ RM ]  cr2hdr.exe cr2hdr.exe.exe  ../../src/chdk-dng-host.o  cr2hdr-host.o  dcraw-bridge-host.o  exiftool-bridge-host.o
[ HOSTCC   ]   ../../src/chdk-dng-host.o
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 1: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: ELF: not found
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 2: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: H���%�1h��%: not found
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 3: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: �1h��%�1h��%��1h��%��1h��%��1h��%��1h��%��1h�1�I��^H��H���PTI����CH����CH��P�@�����H�H�9�1H��t��H�������������UH��SH��=: not found
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 4: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: ���P���: not found
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 5: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: ���1H�[��U�p�JH��H��t���q���P胦: not found
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 6: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: Syntax error: ")" unexpected
make[1]: *** [../../src/chdk-dng-host.o] Error 2
make[1]: Leaving directory `/home/magiclantern/magic-lantern/modules/dual_iso'
make: *** [cr2hdr.exe] Error 2


I dont see why I created that new directory because the makefile does not point to it!

New directory created is:

magiclantern
  mingw-32
    bin
      i686-w64-mingw32

The make file points to:

magiclantern
  mingw-32
    bin

The i686-w64-mingw32-gcc is the compiler in the bin directory,  which it is there, and the makefile can find it but cannot proccess it due to some elf stuff.

So the command:

HOSTCC=~/mingw-w32/bin/i686-w64-mingw32-gcc

Reffers to the directories mingw-w32 and bin and the other is the compiler : i686-w64-mingw32-gcc
Title: Re: Help compiling cr2hdr
Post by: Audionut on September 11, 2013, 05:21:52 AM
Look at your directory structure.

Quote from: RenatoPhoto on September 11, 2013, 05:12:15 AM
magiclantern
  mingw-32
    bin
      i686-w64-mingw32
        include
        lib
        libsrc

And now at where ML is looking for the files.

Quote from: RenatoPhoto on September 11, 2013, 05:12:15 AM
[ HOSTCC   ]   ../../src/chdk-dng-host.o
/home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: 1: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: ELF: not found

Either add -gcc to the directory name

Quotemagiclantern
  mingw-32
    bin
      i686-w64-mingw32-gcc
        include
        lib
        libsrc

Or remove it from the makefile

QuoteHOSTCC=~/mingw-w32/bin/i686-w64-mingw32-gcc
Title: Re: Help compiling cr2hdr
Post by: RenatoPhoto on September 11, 2013, 05:26:08 AM
That is news to me, I thought that is the compiler i686-w64-mingw32-gcc and not a directory...  But i can try it ..
Title: Re: Help compiling cr2hdr
Post by: RenatoPhoto on September 11, 2013, 05:31:01 AM
If I do that then I get your permission denied error as you did on previous post.... 

/bin/sh: 1: /home/magiclantern/mingw-w32/bin/i686-w64-mingw32-gcc: Permission denied

Are you able to make cr2hdr.exe???
Title: Re: Help compiling cr2hdr
Post by: Audionut on September 11, 2013, 05:32:35 AM
Edit the makefile

Quote# Makefile for the cr2hdr software

CR2HDR_BIN=cr2hdr.exe
HOSTCC=gcc

Then just run make.

make cr2hdr.exe generates the error.
Title: Re: Help compiling cr2hdr
Post by: RenatoPhoto on September 11, 2013, 05:38:14 AM
So now it does not make the linux version of cr2hdr.

It generated a cr2hdr.exe file but it does not work.  I gives some windows compatibility issue.
Title: Re: Help compiling cr2hdr
Post by: Audionut on September 11, 2013, 05:43:31 AM
Nope.  You can make either one or the other.

Remove the .exe from the makefile and it will generate the linux version.

If you need both versions, run make as normal, copy cr2hdr to safe place, run make clean, edit makefile adding .exe, run make.

Quote from: RenatoPhoto on September 11, 2013, 05:38:14 AM
It generated a cr2hdr.exe file but it does not work.  I gives some windows compatibility issue.

You've buggered the mingw install.  Remove it from ubuntu software manger, check all the other mingw packages in the software manager to ensure they are all removed.  Remove whatever other version you downloaded.

Ensure the i686-w64-mingw32 folder in "file system/usr" got removed when you unistalled mingw through the software manager.

Reinstall the mingw development environment as per
(http://i.imgur.com/TmKdJN4.png)

Make sure you delete all the stuff you put into the ML directory also.  And then copy the freshly installed folders back to the ML directory.
Title: Re: Help compiling cr2hdr
Post by: RenatoPhoto on September 11, 2013, 05:51:33 AM
I will do that-  but I still think that:

i686-w64-mingw32-gcc is the compiler and and not a directory.
Title: Re: Help compiling cr2hdr
Post by: gerk.raisen on October 16, 2013, 02:54:45 PM
I also have compile problem for cr2hdr on the virtual machine.
Followed Audionut suggestion:

-Installed only "Development environment targetting 32- and 64-bit Windows"

copied the folders:
include
lib
libsrc

from /usr/i686-w64-mingw32 to match HOSTCC:
~/mingw-w32/bin/i686-w64-mingw32-gcc

- I have run "make cr2hdr.exe" an I received this error:

root@magiclantern-VirtualBox:~/mylantern/modules/dual_iso# make cr2hdr.exe
make: *** No rule to make target `hgstamp', needed by `module_strings.h'.  Stop.

Help :)
Title: Re: Help compiling cr2hdr
Post by: gerk.raisen on October 22, 2013, 11:35:55 AM
No one can help me :(? please  :)
Title: Re: Help compiling cr2hdr
Post by: mk11174 on October 22, 2013, 12:19:17 PM
Quote from: gerk.raisen on October 22, 2013, 11:35:55 AM
No one can help me :(? please  :)
What I did, looks like we use same Enviroment, I changed lines in Makefile.cr2hdr

From:
ifdef CROSS
   HOSTCC=~/mingw-w32/bin/i686-w64-mingw32-gcc
   CR2HDR_BIN=cr2hdr.exe

To:
ifdef CROSS
   MINGW=/usr/bin/i686-w64-mingw32-gcc
   CR2HDR_BIN=cr2hdr.exe

And and Have to make sure you run make first to generate the strings, then it seems cr2hdr.exe will work fine.
Title: Re: Help compiling cr2hdr
Post by: gerk.raisen on October 22, 2013, 12:28:23 PM
Thank you mk11174.

I've tried but I continue receiving this error:

root@magiclantern-VirtualBox:~/mylantern/modules/dual_iso# make cr2hdr.exe
make: *** No rule to make target `hgstamp', needed by `module_strings.h'.  Stop.
Title: Re: Help compiling cr2hdr
Post by: mk11174 on October 22, 2013, 12:31:08 PM
Quote from: gerk.raisen on October 22, 2013, 12:28:23 PM
Thank you mk11174.

I've tried but I continue receiving this error:

root@magiclantern-VirtualBox:~/mylantern/modules/dual_iso# make cr2hdr.exe
make: *** No rule to make target `hgstamp', needed by `module_strings.h'.  Stop.
Sorry forgot a step check my update on last post
I was stumped for a minute to cause I got the error myself.
Just did a make then make cr2hdr.exe and all was fine.
Title: Re: Help compiling cr2hdr
Post by: RenatoPhoto on October 22, 2013, 01:41:33 PM
Excellent!  I can now compile cr2hdr.exe
Title: Re: Help compiling cr2hdr
Post by: gerk.raisen on October 23, 2013, 11:04:13 AM
Thank you mk11174.

A huge step ahead.
Now I can compile it without error.
The only remaining problem is that when try to run the .exe file on Win7 64bit I receive the error:

The version of this file is not compatible with the version of Windows you're running
....
Title: Re: Help compiling cr2hdr
Post by: mk11174 on October 23, 2013, 11:18:22 AM
Quote from: gerk.raisen on October 23, 2013, 11:04:13 AM
Thank you mk11174.

A huge step ahead.
Now I can compile it without error.
The only remaining problem is that when try to run the .exe file on Win7 64bit I receive the error:

The version of this file is not compatible with the version of Windows you're running
....
you are so right, this is new for sure in the last week, it has always been compatible? I will see if I can figure it out.

Update: It seems the new way it is set up, it has to be set like this in the Makefile.cr2hdr
ifdef CROSS
   HOSTCC=/usr/bin/i686-w64-mingw32-gcc
   CR2HDR_BIN=cr2hdr.exe
endif
Title: Re: Help compiling cr2hdr
Post by: gerk.raisen on October 25, 2013, 10:45:58 AM
Set as last mk11174 post and now it works!!
Thank you. :)