[fpc-pascal]More BeOS fun..
Full_Name
memsom at post.interalpha.co.uk
Fri Jun 15 15:28:09 CEST 2001
I just got FPC to link against a C shared object that I created natively on
BeOS. This is pretty amazing as it worked FIRST TIME!! (lol)
Just to share the info..
Created a simple Shared Object in the BeIDE.. consisted of the following:
/* begin libtest.c */
#define BUILDING_LIB 1
#include "libtest.h"
int TestFunc(void)
{
return 20; //nominal value.. could be anything..
};
/* end libtest.c */
/* begin libtest.h */
//conditional defines for building shared object/header
//I borrowed this from a tutorial on the 'net..
#if BUILDING_LIB
#define UGLY_IMPEXP __declspec(dllexport)
#else
#define UGLY_IMPEXP __declspec(dllimport)
#end
//the function..
int UGLY_IMPEXP TestFunc(void);
/* end libtest.h */
Then I wrote an import unit:
{* begin import unit *}
unit libtest;
interface
function TestFunc: integer; external 'libtest.so';
implementation
end.
{* end import unit *}
Then a little test proggy:
{* begin test proggy *}
program testlib; {original name I know ;) }
uses
libtest;
begin
if TestFunc = 20 then writeln('It works')
else writeln('who knows?!?!');
end.
{* end test proggy *}
Compile with the folowing script:
(UNIT_PATH = path to the compiled units, eg './units/beos')
ppc386 -Cn -FuUNIT_PATH testlib.pas
gcc UNIT_PATH/sysbeos.o UNIT_PATH/prt0.o libtest.so testlib.o -otestlib
//
Does anybody have any ideas on how to take GCC out of the loop?? I'm guessing
that there must be a way... either that or I'll symlink GCC into a nicer
looking form ;)
I'm going to look into writing a *very* simple flattened API a-la Kylix/QT for
BeOS in the next few weeks. (always loved BeOS ;).. I'm looking into finding a
simple shared library that implements a well thought out and simple to
use 'revised' BeOS GUI Wrapper. If anyone knows of one.. please let me know. I
just want something that will avoid all the additional gumpf that BeOS needs to
be done behind the scenes (simple forms, buttons, text/edit boxes, checks,
combos etc.. nothing too fancy.) Probably end up learning the BeOS API though!!
I'll wait for FPC to link against C++ Shared Libraries before I do anything
spectacular ;)
Please feedback..
Matt
More information about the fpc-pascal
mailing list