Monday, August 13, 2007

Do you want to use Windows CE SDK 5.0 headers but compile for 2003 or previous versions?

Do you want to use Windows CE SDK 5.0 headers but compile for 2003 or previous versions?

Beside the answer,you might ask why would anybody want to do this?

Well,i ran into this case.
Compatibility and single binary file for different versions of pocketpcs.
If you want to run your .exe file in both PocketPc 5.0 and 2003 versions,the simplest solution is to compile it as Pocket PC 2003(ARMV4) in your Visual Studio.
But How can you use new definitions,defined in newer sdk files?
Copy/Paste?
I am really not a big fan of copy/paste.Just don have any good reasons to convince you,but I've had really bad problems with copy/pasting stuff,so i try as much as possible to prevent it.
Or,
Another reason is you want to compile for 2003 but debug it under 5.0 emulator.
or,
To simple do this.I don't know really another reasons,but i just wanted to do this.

Another reason is AFAIR you could do the same with embedded visual studios.
You only have to use under_ce definition to link to previous version of sdk(2002).

So here is the answer :

1. Set Buffer security check in c/c++ compiler tab in Project Options to no.
2. Set additional library directory in general/linker tab to your 2003 sdk lib directory.
mine is in "E:\Microsoft Visual Studio 8\SmartDevices\SDK\PocketPC2003\Lib\armv4"
3. Add /MACHINE:ARM to commands in linker.
4. I also changed _under_ce and win32_wce definitions in compiler tab into 0x420 .

Beside all this there are some things you should know when trying this approach.
Stay away from specific function in newer SDKs,or if you have to use LoadLibrary and GetProcAddress after checking for the right OS version.

No comments: