How to compile Image Writer?

Asked by Paul Rattink

Hello,
I downloaded the latest version 0.5 of Win32DiskImager.
I copied the files in c:\Projects Qt\src

I installed QT SDK 4.8.0 and tried to compile the Win32DiskImager.
Using the compile.bat I get:
  C:\Projects QT>compile
  C:/QtSDK/mingw/bin/mingw32-make -f Makefile.Release
  mingw32-make[1]: Entering directory `C:/Projects QT/src'
  Makefile.Release:65: *** missing separator. Stop.
  mingw32-make[1]: Leaving directory `C:/Projects QT/src'
  mingw32-make: *** [release] Error 2
  Press any key to continue . . .

I also tried the Visual Studio 2010 Addin of QT.
I get also a lot of errors:
  diks.h: error C1014: too many include files: depth = 1024
  And 'include file 'disk.h' includes itself
  And cannot open source file QApilcation
  And cannot open source file QtGui

Can someone help me?
What can I do to make this work?

Thank your very much for your help.
Paul Rattink

Question information

Language:
English Edit question
Status:
Solved
For:
Image Writer Edit question
Assignee:
No assignee Edit question
Solved by:
Paul Rattink
Solved:
Last query:
Last reply:
Revision history for this message
Jeff B (skydiver38) said :
#1

I don't have a good idea of why you're having a problem, but a few things to try -

* Use a path without a space in it. Don't know if it matters, but maybe worth a shot.

* I'm not sure a build's been done with QT 4.8. Try the 4.7 build (in SDK 1.1.2, vs SDK 1.2).

* Do you really ned to compile? If not, try the binary download....

I'm not familiar with the VS2010 addin at all....

Revision history for this message
Paul Rattink (prattink) said :
#2

Hello Jeff B,

Thank you very much for helping me. I installed the QTSDK version 4.7 you advised me. But I get the same errors. Later I set the environment variabele of Windows XP to:
QMAKESPEC = C:\QtSDK\Desktop\Qt\4.7.3\mingw\mkspecs\win32-g++
And I used the original compile.bat file and added the path:
 cd src
 C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qmake.exe
 c:\QtSDK\mingw\bin\mingw32-make.exe
 cd ..
After running the compile.bat I get the error 'disk.h', because in disk.h
#include "disk.h". The file includes itself:too many include files.
I get an endless list of disk.h: errors...

I don't understand: EVERY ONE should have this error...because the file disk.h includes itself????!

I thougth I had a briliant Idea, I added macro's:
#ifndef DISK_H
#define DISK_H
(..original file lines)
#endif // DISK_H
But...I get another list of errors:
starting with:
 disk.h: In function 'bool isVolumeUnmounted(void*)':
 disk.h:134: error: 'FSCTL_IS_VOLUME_MOUNTED' was not declared in this scope
 disk.h: At global scope:
 disk.h:217: error: 'PSTORAGE_DEVICE_DESCRIPTOR' has not been declared
 disk.h:218: error: 'DEVICE_NUMBER' has not been declared
 disk.h: In function 'BOOL GetDisksProperty(void*, int, int*)':
 disk.h:220: error: 'STORAGE_PROPERTY_QUERY' was not declared in this scope
 disk.h:220: error: expected ';' before 'Query'
 disk.h:226: error: 'Query' was not declared in this scope
 (...)

Note: There are however several qmake.exe files.
1C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qmake.exe
2C:\QtSDK\Desktop\Qt\4.7.3\msvc2008\bin\qmake.exe
3C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qmake.exe
4C:\QtSDK\Simulator\Qt\mingw\bin\qmake.exe
5C:\QtSDK\Simulator\Qt\msvc2008\bin\qmake.exe
6C:\QtSDK\Symbian\SDks\Symbian1Qt463\bin\qmake.exe
7C:\QtSDK\Symbian\SDks\Symbian1Qt473\bin\qmake.exe
8C:\QtSDK\Symbian\SDks\Symbian3Qt463\bin\qmake.exe

Which one should I use..?

I really do hope you have can give me some tips to solve the compile problem,
because I want to use the ImageWrite to do some MD5 Hash checking after
he has burned an USB Stick.
I really like the Win32ImageMaker...! So I do hope you can give me a clue how
to compile the source of this program.

Can you help me? Do I have to set more Environment variables..?
Greetings from Holland, Paul

Revision history for this message
Jeff B (skydiver38) said :
#3

Sorry - just seeing your response.

*My* "disk.h" specifically does NOT "#include 'disk.h'". I agree that would be a problem. Not sure why yours would differ... Corruption?

Also, what version of windows?
These are all in the windows headers:
FSCTL_IS_VOLUME_MOUNTED
PSTORAGE_DEVICE_DESCRIPTOR
STORAGE_PROPERTY_QUERY

You should have them defined just from inclusion of the windows headers. But, I suspect that you have some kind of corruption issue, which means that I wouldn't try to track these down that hard. Did you try the binary download?

Revision history for this message
Jeff B (skydiver38) said :
#4

Just FYI, md5sum for 0.5 source distribution:
win32diskimager-source.zip 095ad037054a472288d146a3ed57db8e

Revision history for this message
Paul Rattink (prattink) said :
#5

Hello Jeff,
You were right I was working with version V0.4 in stead of V0.5.
I really tried 10000 things in order to compile the source.

When I compile version V0.5 of Win32ImageMaker I get still errors:
disk.h: 60: error: 'STORAGE_BUS_TYPE' does not name a type.
disk.cpp: In function 'bool checDriveType(char*, ULONG*)':
disk.cpp: 337: error: 'strukct _STORAGE_DEVICE_DESCRIPTOR'has no member named 'BusType'
disk.cpp: 337: error: 'BusTypeUsb' was not declared in this scope
mingw32-make]1]: *** [relase/disk.o] Error 1

Note: when I start the bin-file (Win32ImageMaker.exe) I also get an error:
'File Error. An error occured while accessing the device. This usually means something is currently accessing the device; please close all applicatins and try again.
Error 1: Incorrect function'

Revision history for this message
Jeff B (skydiver38) said :
#6

STORAGE_BUS_TYPE is defined in winioctl.h which is included by disk.h.

What version of Windows are you using?

Revision history for this message
Jeff B (skydiver38) said :
#7

As far as your problem with "An error occured while accessing the device" - make sure that all open windows that point to the device are closed. This includes any open explorer windows.

Revision history for this message
Paul Rattink (prattink) said :
#8

Hello Jeff,
Again thank you for helping me.
I have new information.
I installed the Qt Creater version 4.7.3 (default installation) on the pc of my work.
It has Windows XP Professional Service Pack3.
When I start the original Win32ImageMaker.exe it does not generate an error, like I get on my PC at home.

I compiled the Image Maker source v0.5 two times, in the Qt Creator.

First with Compiler Qt4.7.3 for Desktop - MinGw4.4 (Qt SDK) Debug
I get the following:
 In file included from ..\src\disk.cpp:33:
 ..\src\/disk.h:60: error: 'STORAGE_BUS_TYPE' does not name a type
 ..\src\disk.cpp: In function 'bool checkDriveType(char*, ULONG*)':
 ..\src\disk.cpp:337: error: 'struct _STORAGE_DEVICE_DESCRIPTOR' has no member
    named 'BusType'
 ..\src\disk.cpp:337: error: 'BusTypeUsb' was not declared in this scope
 mingw32-make[1]: Leaving directory `C:/ProjectsQT/FlashV5/DiskImager-build-desktop'
 mingw32-make[1]: *** [release/disk.o] Error 1
 mingw32-make: *** [release] Error 2
The process "C:\QtSDK\mingw\bin\mingw32-make.exe" exited with code 2.
 Error while building project DiskImager (target: Desktop)
 When executing build step 'Make'

Secondly I compiled in Qt Creator using Compiler Qt4.7.3 for Desktop - MSVC2008 (Qt SDK) Debug
I get the following:
Note: Compiled with Qt 4.7.3 for Desktop - MSVC2008 (Qt SDK) Debug
  c:\projectsqt\flashv5\src\disk.h(49) : error C2011: '_STORAGE_DEVICE_DESCRIPTOR' : 'struct'
  type redefinition
        C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winioctl.h(710) : see declaration
        of '_STORAGE_DEVICE_DESCRIPTOR'
  c:\projectsqt\flashv5\src\disk.h(67) : error C2011: '_STORAGE_QUERY_TYPE' : 'enum' type
  redefinition
        C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winioctl.h(641) : see declaration
        of '_STORAGE_QUERY_TYPE'
  c:\projectsqt\flashv5\src\disk.h(76) : error C2011: '_STORAGE_PROPERTY_ID' : 'enum' type
  redefinition
        C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winioctl.h(652) : see declaration
        of '_STORAGE_PROPERTY_ID'
  c:\projectsqt\flashv5\src\disk.h(84) : error C2011: '_STORAGE_PROPERTY_QUERY' : 'struct' type
  redefinition
        C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\winioctl.h(667) : see declaration
        of '_STORAGE_PROPERTY_QUERY'
(...)

So the second build is more hopeful, because I got too much info..:-)
I tried already to remove the " C:\Program Files\Microsoft SDKs\Windows\v6.0A\include" directory, to eliminate the redefinition errors, but then I get other errors.

I do hope you can give me a tip to make it compile completely.

Revision history for this message
Jeff B (skydiver38) said :
#9

Thanks for the info. Can you try a command line build, instead of using QT Creator? I haven't played around with QT Creator.

In the Image Writer directory, run clean.bat and compile.bat. See if you get the same errors.....

Revision history for this message
Paul Rattink (prattink) said :
#10

Hello Jef,

I tried your new disk.h and I tried to use clean.bat and another compile.bat.
But I get the same errors:

Using compile.bat, with lines:
C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qmake.exe
c:\QtSDK\mingw\bin\mingw32-make.exe
generates:
 In file included from disk.cpp:33:
 disk.h:65: error: 'STORAGE_BUS_TYPE' does not name a type
 disk.cpp: In function 'bool checkDriveType(char*, ULONG*)':
 disk.cpp:337: error: 'struct _STORAGE_DEVICE_DESCRIPTOR' has no member
  named 'BusType'
 disk.cpp:337: error: 'BusTypeUsb' was not declared in this scope
 mingw32-make[1]: *** [release/disk.o] Error 1
 mingw32-make[1]: Leaving directory `C:/ProjectsQT/Jef1/src'
 mingw32-make: *** [release] Error 2

Using compile lines:
C:\QtSDK\Desktop\Qt\4.7.3\msvc2008\bin\qmake.exe
c:\QtSDK\mingw\bin\mingw32-make.exe
Errors. It does not compile with compile.bat.

I also tried to compile your new disk.h file with Qt Creator, selecting the MSVC2008
compiler. Still errors. The trick of using the
'#ifndef _STORAGE_DEVICE_DESCRIPTOR' did not work.
I tried to removed the contents with /*...*/, make it take the winioctl.h file, but still errors.
The compiler keeps fightng with the winioctl.h of Microsoft SDK and that of the QtSDK directory.

Jef is it not possible to send me your source and your compiler, and all the steps you have taken (like environment variables, path, direcotries) to make the
compiler work....so that I can do the same you can...?
Thanks for the support.

Revision history for this message
Jeff B (skydiver38) said :
#11

Paul - my source is no different than your source (or at least not significantly different) - it's 0.5 with the QT sdk. My compiler is mingw.

At the beginning of my PATH env dir, I added paths to the qt bin dir in order to use QMake, and to the mingw/bin area to find mingw-make (as well as g++).

But, saying that your disk.h includes "disk.h" - mine doesn't. So, something seems completely out of sync here. It doesn't strike me as a simple path problem....

Revision history for this message
Paul Rattink (prattink) said :
#12

Hello Jef,
I used the latest source 0.5, so the "disk.h" is now ok.
I have set the same environment paths to mingw-make32 and g++.

When I have time (I have small children...) I am going to investigate why I get the 'STORAGE_BUS_TYPE' error.
I think I need to set another path, to make the compiler find the h-file where the
'STORAGE_BUS_TYPE' type has been defined.
Maybe this is the only problem I am dealing with...!
Thanx for your support.

Revision history for this message
Jeff B (skydiver38) said :
#13

I have small kids too, so I know the deal. :-)

I added "-E" to my CXXFLAGS in my "Makefile.Release" to see precisely where STORAGE_BUS_TYPE (and hence winioctl.h) was being defined. What I see (in "release/disk.o") is this:
-------------------------------------
# 241 "c:\\perl\\c\\bin\\../lib/gcc/i686-w64-mingw32/4.4.3/../../../../i686-w64-
mingw32/include/winioctl.h" 3
  typedef enum _STORAGE_BUS_TYPE {
    BusTypeUnknown = 0x00,BusTypeScsi,BusTypeAtapi,BusTypeAta,BusType1394,BusTyp
eSsa,BusTypeFibre,BusTypeUsb,BusTypeRAID,BusTypeiScsi,
    BusTypeSas,BusTypeSata,BusTypeMaxReserved = 0x7F
  } STORAGE_BUS_TYPE,*PSTORAGE_BUS_TYPE;
-------------------------------------

So, deciphering that path, it's coming from c:\\perl/c/i686-w64-mingw32/include/winioctl.h

So, it seems to be coming from my perl install, which I installed in order to configure QT (IIRC).

Since I don't believe that it's a requirement to install perl to install the qtsdk (I installed and built QT from source), I'm not sure what QT does with it's include path when that's the case.

Let me know how it's going - we'll get you there building eventually. :-)

Revision history for this message
Paul Rattink (prattink) said :
#14

Hello Jef,
The good news I have been able to compile source 0.5 using Qt Creator!!!
I added the following lines in disk.h:
//-----------Paul copied from Q:\QtSDK\mingw\include\ddk\ntddstor.h-----
typedef enum _STORAGE_BUS_TYPE {
        BusTypeUnknown = 0x00,
        BusTypeScsi,
        BusTypeAtapi,
        BusTypeAta,
        BusType1394,
        BusTypeSsa,
        BusTypeFibre,
        BusTypeUsb,
        BusTypeRAID,
        BusTypeMaxReserved = 0x7F
} STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
// ---------------------------------------------------------------------
just above line:
'typedef struct _STORAGE_DEVICE_DESCRIPTOR {'

The Bad news is that I can't find the 'MD5 Hash' check box in the 'mainwindow.ui'
In the Win32 Disk Imager.exe I can see the checkbox 'MD5 Hash', but it isn't in my 0.5 source.
Can you help me..??
Thanx!

Revision history for this message
Paul Rattink (prattink) said :
#15

Hello Jef,

In the latest version 0.5 zipfile, that you can download with:
  https://launchpad.net/win32-image-writer
the md5 hash function is not available in the source.
The binary download has the md5 function. It is not in the mainwindow.ui and the md5.h file is missing.....???

I found the mainwindow.ui file in source files of revision 37:
http://bazaar.launchpad.net/~gruemaster/win32-image-writer/0.5/files/head:/src/
  ~gruemaster/win32-image-writer/0.5 : /src (revision 37)
  Tobin Davis, Date Date: 2012-02-15 22:38:41 UTC
  mainwindow.ui 33.1.1 2012-02-15 18:00:30 UTC 8.3K
But the md5.h is missing !!

I found the mainwindow.ui file in source files of revision 44:
http://bazaar.launchpad.net/~image-writer-devs/win32-image-writer/0.3/files/head:/src/
 ~image-writer-devs/win32-image-writer/0.3 : /src (revision 44)
 jeffB, Date: 2012-03-23 23:02:00 UTC
 mainwindow.ui 33.1.1 2012-02-15 18:00:30 UTC 8.3K
 md5.h 39 2012-02-16 15:01:56 UTC 11.5K

Conclusion: the 'binary zip'-file of version 0.5 can not be created with the 'source zip'-file of version 0.5, because an older version has been zipped, without the md5 code.

Can you tell me what the latest version of Win32ImageMaker is...? Revision 44??

Thank you.

Revision history for this message
Jeff B (skydiver38) said :
#16

Good find - it looks like version 0.5 was built off of rev 37, and md5.h was added in rev 39. The binary download was recreated due to some changes, but I'm guessing that the source zip wasn't.

The "latest version" is always going to be whatever's on "trunk" Right now, that's rev 44. That won't build to a specific "version" of ImageWriter though, obviously.

I'll ping Tobin about doing a release to rectify the source/binary discrepancy.

Thanks...

Revision history for this message
Paul Rattink (prattink) said :
#17

Hello Jef,

I am happy that I could contribute a little bit to this opensource program..!!

So I am now able to add new code to the Image Maker source and to test it as well.

The only thing that I have to do, when I download the source files is to add the following
lines to the "disk.h" file, so that I can compile it with QT Creator (4.7.3, default download,
dowload file: Qt_SDK_Win_offline_v1_1_2_en.exe):
//-----------Paul copied from Q:\QtSDK\mingw\include\ddk\ntddstor.h-----
  typedef enum _STORAGE_BUS_TYPE {
        BusTypeUnknown = 0x00,
        BusTypeScsi,
        BusTypeAtapi,
        BusTypeAta,
        BusType1394,
        BusTypeSsa,
        BusTypeFibre,
        BusTypeUsb,
        BusTypeRAID,
        BusTypeMaxReserved = 0x7F
  } STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
  // ---------------------------------------------------------------------

I place these lines just above the following orignal lines of "disk.h":
  // retrieve the storage device descriptor data for a device.
  typedef struct _STORAGE_DEVICE_DESCRIPTOR {
  (...)
       STORAGE_BUS_TYPE BusType;
  (...)
  } STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;

I need to do this, because the STORAGE_BUS_TYPE is defined in this additional code, that I have
copied from file: Q:\QtSDK\mingw\include\ddk\ntddstor.h.

Thank you for helping me out.

Revision history for this message
Jeff B (skydiver38) said :
#18

Glad that you're closer to it working, but the fact that you have to add those lines disturbs me. It should be picked up in the files from QT or MinGW.

But, glad that we're over the major hurdles.

Revision history for this message
Tobin Davis (gruemaster) said :
#19

I think I have figured out this STORAGE_BUS_TYPE issue (or at least glanced into the insanity behind the issue). It appears that the mingw that ships with QT SDK 4.8.* is broken (I am now using 4.8.1 at work and have the same compiler error). Not sure why I didn't see this thread before (I found it via google of all things).

From what I have found, mingw switched their w32api to the cygwin w32api implementation some time ago. And that implementation was broken until 12/2010. Now, why this isn't updated in QT released 4/2012 is beyond me. I'm still trying to get answers.

In the meantime, I would suggest not installing mingw with qt 4.8.x at this time, install it separately from http://mingw.org or try the mingw-w64 builds from http://mingw-w64.sourceforge.net/.

Revision history for this message
Tobin Davis (gruemaster) said :
#20

OK, so to get around this, install mingw from mingw.org and point QT-Creator to it instead of the one that ships with QT.

Revision history for this message
Paul Rattink (prattink) said :
#21

Hello Tobin,
Thank you for the information!
I am glad I found a workaround...but a good 'mingw' that is not brooken should be better of cource.
Thank you for your support.
Greetings, Paul

Revision history for this message
Tobin Davis (gruemaster) said :
#22

The STORAGE_BUS_TYPE issue goes even deeper it would appear. Newer device types are not defined in the mingw w32api.

Need to add the following to winioctl.h to be complete.:
  BusTypeSd = 0x0C,
  BusTypeMmc = 0x0D,
  BusTypeVirtual = 0x0E,
  BusTypeFileBackedVirtual = 0x0F,
  BusTypeSpaces = 0x10,
  BusTypeMax = 0x11,

NOTE: I am currently experimenting with this to see if it will resolve the newer SD reader issue, but I don't have high hopes.