Author Topic: Unpacked compatible exe from iq's framework? Guidelines?  (Read 4318 times)

0 Members and 1 Guest are viewing this topic.

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Ok, maybe this is stupid but.. I don't know which options are necessary to change and I can't be sure whether the final result WILL be compatible. That happens when you take a framework that is supposed to do the job for you and you don't initially care.

I have released this 4k here. I used one the 1k/OpenGL framework from iq's page. Someone asked me to include a compatible exe and so I thought it would be a good idea and also learn how to do this for my next intros in the future.

At first I thought to compile the debug mode but then the compatible exe would be like a big 300kb file inside the zip archive which is lame. Then I thought to use compression mode INSTANT but this was a lame idea because it's not the compression that creates incompatibilities but the tricks with the small final exe maybe? Then I used the old linker, of course I got some errors, I had to change the entrypoint (I also copied the winmain function header from the debug code on the release code where it says void entrypoint()) . Somehow I feel now that this way it will be compatible, but I don't know. Is there anything I am missing? Also, I remember that the compatible exes from 4k are something around 8-12kbs. But here it's 60kb (I have optimize for size /O1 enabled and favor small code settings). Not a big problem but maybe I am missing something. I then tried to compress that file with UPX but it compresses 0.0%. Strange..

Is this ok way to make a compatible exe from the 4k framework or should I change more things in the project release propertries? (I am on VC9 btw)
« Last Edit: March 15, 2009 by Optimus »
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
In general I think compatible means just without the exe compression.  Perhaps sometimes there are some assumptions removed in the code - eg. where it's assumed that a particular dll is installed or that an entry point is at a particular position.
You can code round the latter with some #defines when you're creating the program.
You've fixed the entry point which sounds like a good start, I'm guessing it's 60Kb because the new linker options have the standard C runtime linked in.  You still want the /NOD no default libraries switch to be on.

Jim
Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Enabling /NOD gives me: error LNK2001: unresolved external symbol __fltused
also unresolved external symbol _WinMainCRTStartup (this is somehow solved if I change the entrypoint to winmain instead of leaving it empty)

What could it be?
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
The __fltused is an internal variable for VC, meaning you've used floating point somewhere.  Try adding a line
Code: [Select]
int _fltused = 0x9875;

When I'm working with this kind of code, I have a section like this:
Code: [Select]
#ifndef _DEBUG
int _fltused = 0x9875;
void WINAPI WinMainCRTStartup(void)
{
WinMain(GetModuleHandle(NULL), 0, 0, 1);
ExitProcess(0);
}
#endif
which means I can debug the code in Debug mode, and building for Release has the same settings.

Jim

Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Ah shit! It's getting annoying. Not only the int _fltused line doesn't work (or if I put it in some place it says that it's already defined in some obj file. And not only that, but the 60kb version I have just seen it crashes. Maybe I'll leave this for today..
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Hmm .. not sure - but I think for compatible versions they
do not use any WinAPI hacks and use a standard windows
initializing code and include all required system libs ?

So, it would actually mean two different kind of versions
of the prog.

Just guessing though ;-)
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won: