I'm using dev-c++ to cross compile to a 8051 processor using the sdcc-compiler. My "problem" is that dev-c++ assumes that my output should be .EXE, and I would like it to be .HEX to be compatible with my programmer and for windows to know that it's not executable.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As far as I know you cant create a .HEX file with a C++ compiler. You might use a hex editor instead.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-03-09
Have you have got the compiler working? (Dev-C++ normally requires gcc compilers, but if your compiler has a compatible command line interface I guess it will work)
Dev-C++ calls the output .exe by default, but its format will be whatever format your compiler/linker toolchain produce. I'll assume it is some sort of linked/located binary file - check your documentation.
If you have it working with Dev-C++, great. You need to use the project tool to do what you want - Just compiling with the default options will not do what you want.
Having created your project, go to Project->Project Options->Build Options.
Form this dialog, you can change the name of the output file. It is a good idea to change it from .exe to stop Windows from attempting to execute it! Depending on the actual format you mignt name it .bin, .hex, .o, .out etc.
If the output is not directly in HEX you will have to use a binary or object code to hex conversion tool. Perhaps your compiler comes with one? If it is already in HEX you need do nothing else.
You can then automate the output of the hex file by creating make 'include' file with an 'all-after' rule. The file should be included via the Project->Project Options->Makefile dialog. Dev executes any all-after rule after it has built the executable. The rule should look something like this:
Note that the <TAB> must be a hard-tab character. Some editors (including Dev) can replace hard tabs with spaces. To be on the safe side, use notepad.
The the command string needs to be modified to suit whatever tool you use to generate the hex file - this is just an example and assumes a program bin2hex used as follows:
bin2hex <input file> <output file>
The $(BIN) macro is what Dev-C++ uses for the output filename you specified in the Build Output dialog. The subst function replaces the string "bin" with "hex" to generate the hex output file name.
Specify this file an make include in the Makefile dialog and that should get you going.
LATE EDIT !
Now having said all that I have just checked the sdcc documentation (I was not previously aware of this compiler). It seems that the default output is in fact Intel Hex (and can be forced by the --out-fmt-ihx option if not), so despite being called .exe, your output file is probably already in HEX (have you checked it in a text editor?).
So all you actually need ot do is change the output name in the Build Options dialog.
I am leaving all the original text in because a) it was a lot of work, and b) it may still be useful!
Clifford
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It's not going to be that simple Cliff. The exe is going to be generated for win32 console subsystem and will be dependent on msvcrt.dll whether he likes it or not. Converting it to flat binary output will not do anything for his purposes.
He is probably best to attempt the same with DJGPP under Dev, but have it set to not link against "standard startup libraries," msvcrt.dll.
Kip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-03-10
He has set Dev-C++ up to use a cross-compiler - there is no way it will generate x86 code.
DJGPP won't generate 8051 code either.
I'm trying to avoid exclamation marks here because I figure your're just tired ;-)
Clifford.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Guessed right. I am so lazy with this forum sometimes.
Kip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2005-03-10
Thanx a lot.
@Clifford: the simple solution is the way, and (sorry) I already knew that sdcc gave the output in the Intel HEX format, But I couldn't find the option anywhere.
Thanx again.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using dev-c++ to cross compile to a 8051 processor using the sdcc-compiler. My "problem" is that dev-c++ assumes that my output should be .EXE, and I would like it to be .HEX to be compatible with my programmer and for windows to know that it's not executable.
As far as I know you cant create a .HEX file with a C++ compiler. You might use a hex editor instead.
Have you have got the compiler working? (Dev-C++ normally requires gcc compilers, but if your compiler has a compatible command line interface I guess it will work)
Dev-C++ calls the output .exe by default, but its format will be whatever format your compiler/linker toolchain produce. I'll assume it is some sort of linked/located binary file - check your documentation.
If you have it working with Dev-C++, great. You need to use the project tool to do what you want - Just compiling with the default options will not do what you want.
Having created your project, go to Project->Project Options->Build Options.
Form this dialog, you can change the name of the output file. It is a good idea to change it from .exe to stop Windows from attempting to execute it! Depending on the actual format you mignt name it .bin, .hex, .o, .out etc.
If the output is not directly in HEX you will have to use a binary or object code to hex conversion tool. Perhaps your compiler comes with one? If it is already in HEX you need do nothing else.
You can then automate the output of the hex file by creating make 'include' file with an 'all-after' rule. The file should be included via the Project->Project Options->Makefile dialog. Dev executes any all-after rule after it has built the executable. The rule should look something like this:
all-after :
<TAB>bin2hex $(BIN) $(subst bin, hex, $(BIN))
Note that the <TAB> must be a hard-tab character. Some editors (including Dev) can replace hard tabs with spaces. To be on the safe side, use notepad.
The the command string needs to be modified to suit whatever tool you use to generate the hex file - this is just an example and assumes a program bin2hex used as follows:
bin2hex <input file> <output file>
The $(BIN) macro is what Dev-C++ uses for the output filename you specified in the Build Output dialog. The subst function replaces the string "bin" with "hex" to generate the hex output file name.
Specify this file an make include in the Makefile dialog and that should get you going.
LATE EDIT !
Now having said all that I have just checked the sdcc documentation (I was not previously aware of this compiler). It seems that the default output is in fact Intel Hex (and can be forced by the --out-fmt-ihx option if not), so despite being called .exe, your output file is probably already in HEX (have you checked it in a text editor?).
So all you actually need ot do is change the output name in the Build Options dialog.
I am leaving all the original text in because a) it was a lot of work, and b) it may still be useful!
Clifford
It's not going to be that simple Cliff. The exe is going to be generated for win32 console subsystem and will be dependent on msvcrt.dll whether he likes it or not. Converting it to flat binary output will not do anything for his purposes.
He is probably best to attempt the same with DJGPP under Dev, but have it set to not link against "standard startup libraries," msvcrt.dll.
Kip
He has set Dev-C++ up to use a cross-compiler - there is no way it will generate x86 code.
DJGPP won't generate 8051 code either.
I'm trying to avoid exclamation marks here because I figure your're just tired ;-)
Clifford.
Guessed right. I am so lazy with this forum sometimes.
Kip
Thanx a lot.
@Clifford: the simple solution is the way, and (sorry) I already knew that sdcc gave the output in the Intel HEX format, But I couldn't find the option anywhere.
Thanx again.