BlitzMax Executables

BlitzMax Forums/BlitzMax Programming/BlitzMax Executables

Chugs40(Posted 2005) [#1]
How do I make executables to use my own icon?


N(Posted 2005) [#2]
Hax0rage.


Perturbatio(Posted 2005) [#3]
I was wondering, does mingw have any facility for adding an icon during compile time?


N(Posted 2005) [#4]
No.


FlameDuck(Posted 2005) [#5]
I was wondering, does mingw have any facility for adding an icon during compile time?
No. But try reading up on "res2coff".


RetroRusty(Posted 2005) [#6]
What's Hax0rage?

Thanks


Stuart Morgan(Posted 2005) [#7]
How do I make executables to use my own icon?

Resource hacker - http://www.users.on.net/johnson/resourcehacker/


Chugs40(Posted 2005) [#8]
Maybe I should have been more specific.
You can't build BlitzMax sources to have their own executable icon?


Stuart Morgan(Posted 2005) [#9]
Maybe I should have been more specific.
You can't build BlitzMax sources to have their own executable icon?


Yes you're right. But you can add it to the executable using a resource program.


DStastny(Posted 2005) [#10]
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


Chugs40(Posted 2005) [#11]
Where do i find windres.exe? or install mingw?
I compiled and it created the rc file but didn't create 'o' file.
need more info.


DStastny(Posted 2005) [#12]
Download mingw from mingw.org
http://prdownloads.sf.net/mingw/MinGW-3.1.0-1.exe?download

follow the instructions to configure you path and enviorment strings.

See Marks post on mingw

http://www.blitzbasic.com/Community/posts.php?topic=44537


Let me know if you need more

Doug Stastny


Chugs40(Posted 2005) [#13]
Thanx for your help. I will try this. Will reply later....


Grisu(Posted 2005) [#14]
Resourcehacker?
http://www.users.on.net/johnson/resourcehacker/


Azathoth(Posted 2005) [#15]
Can more recent versions of MinGW be used?


DStastny(Posted 2005) [#16]
I dont know aeiou. I just used the version Mark suggested. I can rebuild the mods and make my own C/C++ code with that no problem havent tried 3.2 as I am not sure of the compatibility with the linker(LD.exe) that is distributed with BlitzMax

I just follwed the url in Marks post and used the tools that came with that version of MingW.

Other than the BMK bug it works great. Now if I could actually draw a descent icon :)

Doug Stastny


Chugs40(Posted 2005) [#17]
I downloaded mingw last night and installed it this morning, and I'm still having problems.
I'm sure it's the path.
Does it matter where I install It?
And how do I set the path to make it work correctly?
Once I do so will it work where ever I need it to?
Or to I have run that 'iconmaker' in a specific place.


DStastny(Posted 2005) [#18]
It shouldnt matter where you install it as long as you have the path and MINGW enviroment variable setup right

On my machine I installed MingW to C:\tools\mingw

For winxp and (Wink 2k i believe) right click my Computer select properties.

On the Advanced tab: Click the "Enviroment Variables" button.

Edit the System Variables:
Select "Path" and click edit. Add ;C:\Tools\Mingw\Bin to the value

Click OK

Click "New" to create a new variable
Variable Name=MINGW
Value = C:\Tools\MINGW

Click OK

Open a command prompt and type GCC

If you get message gcc: no input files you should be good to go.

You should run iconmaker in the directory you want that has the icon file. Its a quicky app so i didnt write any fancy path handling.

Doug


Chugs40(Posted 2005) [#19]
Thanx again for your help...

Steve


Chugs40(Posted 2005) [#20]
I got every thing installed, and got it to work. created 'o' file.
except I got a link error: c:\program files\blitzmax\bin\ld.exe: cannot find.
I noticed that file exists in the mingw/bin directory and the blitzmax/bin directory. conflict?
I am confused, it should have worked.
Is the link failure due to spaces in directories, like you said earlier? the only directory with a space is 'program files' which is what my blitzmax is installed under, and my source files are in my own folders under blitzmax with no spaces. what to do?


DStastny(Posted 2005) [#21]
Yes that is the space problem. "See sticky in bug reports"

place the .o file in a directory like c:\icono and change import line in your bmx file to read "import "c:\icono\<name.o>" and it should work fine.

Your almost there :)


Chugs40(Posted 2005) [#22]
I moved it to a directory right off of my root and it worked just fine.

Thanx for the help.


Perturbatio(Posted 2005) [#23]
The whole pathnames with spaces in thing is a little weird, because my programming directory is stored in my documents, the path of which is
C:\Documents and Settings\MyUsername.Domain\My Documents\Programming\Blitzmax

three spaces in the path and no problems compiling.


Chris C(Posted 2005) [#24]
wonder if its spaces in a relative path...


DStastny(Posted 2005) [#25]
Great Steve, glad I was able to help.

Perturbatio, I have most of my stuff on a folder on my desktop, had no problems importing BMX file. Until i started importing object files ie. Import "coolfunc.o". And BMK butchers the path only on them its odd.

Need that source :)


Red(Posted 2005) [#26]
I think Ive a better solution for you.

BMK preproc: http://www.blitzbasic.com/Community/posts.php?topic=47636

It builds icon resource.