BlitzMax Executables

BlitzMax Forums/BlitzMax Programming/BlitzMax Executables

You can build Blitz MAX executables to have icon if you have MingW installed. The little utility that comes with MINGW that makes it happen is windres.exe.

I have attached my BMX utility code that takes a .ico file and converts it to object file. You then Import the resulting object file ".o" into your application and compile it with Blitzmax and your program will have the icon.

iconmaker.bmx
Import BRL.FileSystem
Import PUB.stdc
Strict
if AppArgs.length < 2 then
	Print "Invalid argument count"
	Print "Usage:IconMaker filename"
	Print "Number of arguments = "+AppArgs.length
	End
Endif
local iconfilename:String= AppArgs[1]
if FileType(iconfilename)<>1 then
	Print iconfilename +" does not exists or is not a file"
	end
end if
local rcfilename:String= stripall(iconfilename)+".rc"
Print "Creating RC File:"+rcfilename
if createfile(rcfilename) then
	Print "File Created"
	local f:TStream=openfile(rcfilename)
	f.WriteLine("1 ICON ~q"+iconfilename+"~q")
	closefile f
end if

Print "Executing Windres to create Object file"
local objfilename:String=stripext(rcfilename)+".o";
local command:string="windres -i ~q"+rcfilename+"~q -o ~q"+objfilename+"~q"
print command
if system_(command)=0 then
	Print "Created "+objfilename
	Print "Add "
	Print "Import ~q"+objfilename+"~q" 
	Print "to your BMX project to link in icon"
end if


Compile this utility as a console application. From a command prompt type>iconmaker "your.ico"

It will generate a file "your.o"

In your bmx source
Import "your.o"


When you compile your application will have the icon you specified.

Note:
1) There is bug in bmk.exe so make sure you dont have directories with spaces in your project or it will fail to link.
2) You must have the MINGW\Bin directory on your search path or it wont find windres or the GCC compiler to create the resulting obj file.

Hope this helps and let me know if you have any questions.
Doug Stastny