[fpc-devel] FPC for minimal Win-32

Sven Barth pascaldragon at googlemail.com
Thu Mar 24 21:10:10 CET 2011


On 24.03.2011 11:26, Mark Morgan Lloyd wrote:
> I'm currently looking at the potential of a minimal Win32-compatible OS
> called Sanos, which supposedly implements a useful subset of the Windows
> console-mode API. As a starting point, I'm using the standard Windows
> variant of the FPC compiler, but if I build a minimal program (i.e.
> program test0; begin end.) the executable requires the oleaut32 DLL
> which is not implemented.
>
> Is there an easy way to break this requirement, or do I need to hack and
> rebuild FPC? If the latter is feasible, could somebody give me a hint
> where to start?
>

You don't need to rebuild FPC itself, but you need to modify the RTL.

Three functions from oleaut32 are included for Windows compatible 
widestring management. As FPC has a fallback mechanism you can disable that.

For that create dummy implementations for the three functions that are 
imported from oleaut32 in system.pp (search for "oleaut32" in 
rtl/win32/system.pp, remove the "external ..." part and add empty 
bodies). Then you need to enable the fallback mechanism. You can do this 
by adding the following line to the top of the initialization section of 
system.pp (attention: system.pp uses the "begin" variant):

winwidestringalloc := False;

This is defined in rtl/inc/wstringh.inc, which is included by system.pp. 
And don't be afraid that it's a "const", because system.pp has "writable 
typed consts" enabled ;)

Then you need to rebuild the RTL.
If you've never done this here is the quick version:

- open command line and navigate to FPC directory
- make rtl OS_TARGET=win32
Note:
* if you are on a Win64 system you might want to add CPU_TARGET=i386 as well
* if FPC is not in your PATH you need to add FPC=c:\path\to\your\fpc.exe

This should built the RTL in rtl\units\i386-win32. You can copy the 
contents of that directory to the rtl directory that is mentioned in 
your fpc.cfg file (maybe backup that first...). Alternatively you copy 
your fpc.cfg and just alter the path for the rtl directory.

I have not tested what I've written here, so if it does not work then 
feel free to ask back. :)

Regards,
Sven



More information about the fpc-devel mailing list