Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Change .exe icon; "Bad object file header in...", "Unable to read object file..."
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
fiercedeity




PostPosted: Sun Oct 14, 2018 9:05 pm   Post subject: Change .exe icon; "Bad object file header in...", "Unable to read object file..."

What is it you are trying to achieve?
To change the icon on my Turing standalone program (.exe).

What is the problem you are having?
All the third party programs I found (two courtesy of these forums) result in the .exe becoming non-functional after I, in any way, adjust the icon. While my program runs just the way I want it before I do any "fiddling," after I save my changes, it won't start and a window pops up saying either "Unable to read object file [name of my program]" or "Bad object file header in [name of my program]."

Describe what you have tried to solve this problem
I used "ResourceHacker" and "IconChanger" (these two resulted in the "Bad object file header in..." message), and "XNResourceEditor" (this one, the "Unable to read object file..."). I tried generating the standalone .exe using both the Turing 4.1 program and a version of OpenTuring I found on here, but both seemed to lead to the same problem from these third parties.


Am I doing something wrong? Is it a problem with these third party applications? Is it the Turing program I am using that's preventing me from doing this/would a different version of Turing work?

Thanks in advance for any help.
Sponsor
Sponsor
Sponsor
sponsor
Srlancelot39




PostPosted: Mon Oct 15, 2018 3:14 pm   Post subject: RE:Change .exe icon; "Bad object file header in...", "Unable to read object file..."

You should be able to do it through the operating system by right-clicking the .exe, clicking Properties, and selecting an icon via the Change Icon button.

No need to install any 3rd party software.
fiercedeity




PostPosted: Mon Oct 15, 2018 4:55 pm   Post subject: Re: Change .exe icon; "Bad object file header in...", "Unable to read object file..."

Thanks, but unfortunately no. The "Change Icon..." button doesn't exist in "Properties" for .exes like it does for shortcuts, and folders (and maybe other kinds of files). From Googling it seems the only way to change the icon for an .exe is by changing the resource embedded in the file using one of these third party apps. And I've done such a thing successfully on other .exes, just not ones generated using Turing.

If anyone HAS changed the icon on their Turing-generated program or has come across the problem I did and managed to figure it out, please let me know how!
Srlancelot39




PostPosted: Mon Oct 15, 2018 6:42 pm   Post subject: RE:Change .exe icon; "Bad object file header in...", "Unable to read object file..."

Damn. I might have been thinking of shortcuts then. I tested on a shortcut before posting that, but thought I had done it to an executable for my own Turing game years ago. I probably did it to the shortcut though, it seems.
fiercedeity




PostPosted: Wed Oct 17, 2018 9:04 am   Post subject: Re: Change .exe icon; "Bad object file header in...", "Unable to read object file..."

So after fiddling a great deal longer, I'm pretty sure it's Turing that's the problem (in case I needed another reason to switch from Turing after finishing my current project). I'm able to change the icons associated with other .exes using the software I downloaded, just not the .exes created using Turing. I'm thinking there must be something embedded in the files that is preventing me from doing so, or at least something that does not easily agree with my attempts to do so.

BUT...

There is a different icon associated with .exes created using Turing (by Holtsoft) and OpenTuring. Since OpenTuring is open source I was wondering if it was possible to determine if/why this problem existed, and if there was a way to fix it.

Thanks if anyone has any suggestions!
fiercedeity




PostPosted: Wed Oct 17, 2018 3:16 pm   Post subject: Re: Change .exe icon; "Bad object file header in...", "Unable to read object file..."

ALRIGHT! SOOOO...

After many hours I did finally find a way to change the icon on my .exe, but, boy, was it complicated. Below is a walkthrough of what I did, in case anyone else wants to change the icon on their Turing-generated program.


So first of all, I had to generate my program using a version of OpenTuring I found here: http://compsci.ca/v3/viewtopic.php?t=40574.
The version of Open Turing 1.0 found about a quarter of the way down the page on this website https://github.com/Open-Turing-Project/OpenTuring may also work. I'm honestly not sure if there's a difference between these two versions, but the first link is the one I used and the one I am sure works.
It's important that you DON'T generate your program using a version of Turing made by Holtsoft (one that has whatever that orange icon is supposed to be of in the top-left corner). I found that if I edited my file's resources in any way (a below step in this walkthrough), it became immediately nonfunctional the next time I tried to execute it.


NOW THIS IS IMPORTANT: .ico files store images in multiple sizes and in a specific order. The problem I was having was that the sizes and order of images in my .ico file didn't match that of the default .ico file applied to all programs made by OpenTuring.
And making an .ico file that matches the default OpenTuring .ico file was actually harder than you might think. Here's what I had to do:

I made an .ico file using this website here: https://redketchup.io/icon/edit.
I clicked "Create ICO from Image" and selected the image (.png) from my computer that I wanted to appear as my program's icon. What pops up is an image editor, and on the left, the different sizes that will be stored in your .ico file when you download it. The only sizes you need are 16x16, 32x32, 48x48, 128x128, and 256x256. Delete all the sizes that are not one of these five. You will also have to change the 256x256 image from PNG to BMP (32 bits) via the "Change format" option accessed by right-clicking said image on the left.
Now you can download the .ico file.

Next you have to download an app that will let you change the order in which the images (that you just created) are stored within the .ico file. I tried many, but I actually couldn't find ANY that let me do exactly this; some apps want to change the 256x256 image into a .png stored in the .ico file (which will not work with the next step), while other apps just won't let a 256x256 image be part of the .ico file altogether.
I did, however, find an app that suffices for this specific need. While I don't know that it has a feature that lets you put the images stored in the .ico file in whatever order you want, it DOES conveniently re-organize them into the order we NEED. Unfortunately this is a 30-day-trial app, so if you plan on changing the icons for Turing-generated programs in the future, then... I guess at that stage you'll have to buy it (though I recommend joining me and just using a different language/IDE in the future). It's Axialis IconWorkshop and can be found here: https://www.axialis.com/iconworkshop/.

Once you've downloaded and opened the app, open the .ico file and you'll see the images stored within have been put into a biggest-to-smallest order (this is what we need!). You'll have to right-click the 256x256 image on the left and de-select the "PNG Compressed Image Format (Windows Vista)" option. Then you can save your .ico file.


Next you'll have to download ResourceHacker, from here: http://www.angusj.com/resourcehacker/.

Open ResourceHacker and open your Turing-generated program (you might want to make a back-up just in case) using this app. Open "Icon Group" on the left, then right-click on the first of the two "resources" that comes up. Select "Replace Icon..." then find your .ico file and select "Replace."
You can save it now, and all the icons outside of the program will be replaced with your icon! When you look at your program from "File Explorer," you'll see your icon. When the program is running, you'll see your icon on the taskbar at the bottom. If the program doesn't run and comes up with one of the two error messages that are in this topic's title, the images in your .ico file are probably still the wrong size or are in the wrong order. You might need to retry some of the above steps.

If everything works out, hold on! We're still not done. You'll probably want to change the icon that appears in the top-left of the window when your program is running, too.
This fortunately is much easier!
When creating an icon, just make there be one image that is 16x16. Then, using ResourceHacker, go to "Icon Group" and, following the same steps as above when replacing icons, replace the second "resource" that comes up.

You can also (and I certainly recommend doing so) change the information seen when somebody checks the properties of your program. Using ResourceHacker, open your program and, on the left, open "Version Info." You can edit the text in that "resource," however, I could not find a way to edit the specific tags that are seen when your program's properties are checked (such as "FileDescription," "LegalCopyright," and "Comments"; the words that come after each instance of "VALUE"). But you can change the values after these tags to whatever you want, so that they're more relevant to your program.


And that's that!

I've spent many months searching this forum and others for ways of changing Turing-generated programs' icons, and spent the last few days getting really into the nitty gritty of it (I'm just about done the project I've been working on after all). Since I REALLY couldn't find an answer from Googling, I thought I should provide a walkthrough of what I did, in case anyone in the future wants to do the same.

If there's a simpler way to do ALL OF THIS though, I'd love to hear it! Otherwise, yeah, here it is ^
Srlancelot39




PostPosted: Thu Oct 25, 2018 7:37 am   Post subject: RE:Change .exe icon; "Bad object file header in...", "Unable to read object file..."

Nice. lol

As for the Holtsoft logo, I believe it is a sun on a horizon.

In the past, I think I've made icon files simply by changing the file ending to .ico, though I'm not sure if that still works. Also, I believe most image editors let you save as .ico.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: