In the last instance, I left with an example of running a Clipper 87 program compiled with a simple C routine, then rebuilt that with Clipper 5.3 using both a 286 & 386 Dos extender.
The next step will be taking that program and making a win32 exe.
And for that we are going to use this great program harbour.
Much like f2c, harbour translates dBase PRG files into either C, or a p-code VM just like clipper did. For this example, I just downloaded Harbour from sourceforge, and installed it in my c:\hmg directory.
Porting applications is pretty straight forward, however Harbour needs a ‘main’ procedure to exist in order to work correctly. So the first change to my simple clipper program is to create wrap my simple Clipper program in a main procedure.
HI.PRG
procedure main
? “hello from clipper”
? “”
c_hi()
return
Now the C program needs some changes as well. Notice how this looks very different from the old c program, but at the same time, it’s not too different. Also because harbour translates the clipper into C, stdio is now working correctly so I can use printf.
HI_C.C
#include “hbvmpub.h”
#include “hbinit.h”HB_FUNC( C_HI )
{
printf(“hi from C\n”);
}
Now to setup the environment, translate the clipper, build the c program and link them together….
\hmg\MINGW\mingwvars.bat
\hmg\HARBOUR\bin\harbour.exe hi.prg -m
gcc hi_c.c -I\hmg\harbour\include -c
gcc -mconsole hi.c hi_c.c -I\hmg\harbour\include -mconsole -Wl,–start-group -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib -Wl,–end-group -ohi.exe -LC:/hmg/HARBOUR/lib
And running this gives me:
C:\temp>hi
hello from clipper
hi from CC:\temp>
Now I know there is all kinds of front ends and other fun stuff, however I think it’s good to know how the thing actually works…
What is even more cool about Harbour is that once you get your program working there, it can be easily rebuilt for OS/2, Linux, Win32, Win64, Windows CE and a few other platforms where GCC is available.
And the best part is that they won’t soak up 100% of your CPU!!!