PDA

View Full Version : using .obj in delphi



arthurprs
29-09-2008, 07:57 PM
I'm trying to compile a library to use with delphi, i can compile the library perfectly on GCC, but unfortunately GCC .o files are not compatible with delphi

so i tried compiling with BCC5.5 , it compiles nice, generates a .obj file for each .c,

i used {$link xxx.obj} on all generated .obj , declared all needed C missing routines,

but Delphi complains about functions not declared

Unsatisfied forward or external declaration: '_bitindex'
etc..

but these functions are under the C files i compiled :roll:

how to solve the problem? :?

JernejL
29-09-2008, 08:04 PM
It means the obj uses external function "_bitindex", which you need to implement in your pascal program before it will link properly (yes obj linking works both ways, you use obj function and obj may need a few of your functions back).

arthurprs
29-09-2008, 08:37 PM
[quote="Delfi"]It means the obj uses external function "_bitindex", which you need to implement in your pascal program before it will ]


i need to rewrite these funcs on delphi :shock: ?

efilnukefesin
29-09-2008, 09:10 PM
i think he means you need to declare the function header in delphi before importing the .obj.
didn't do that before but i think it's similar to dlls... :?

efilnukefesin
29-09-2008, 09:13 PM
perhaps this can be useful:
http://rvelthuis.de/articles/articles-cobjs.html

especially the

implementation

uses
SysUtils;

{$LINK 'regexp.obj'}

function _regcomp(exp: PChar): PRegExp; cdecl; external;
function _regexec(prog: PRegExp; str: PChar): LongBool; cdecl;
external;
function _reggeterror: Integer; cdecl; external;
procedure _regseterror(Err: Integer); cdecl; external;

end.

part

efilnukefesin
29-09-2008, 09:21 PM
the longer you searrch the better the results get :lol:

http://dn.codegear.com/ru/article/10156#H11


unit DAPPMAIN;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs,
StdCtrls;

type
TMain = class(TForm)
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Main: TMain;

implementation

{$R *.DFM}

{Specify the name of the OBJ containing the function.}
{$L cobj.obj}

procedure COBJ_Function; StdCall; far; external;

procedure TMain.Button1Click(Sender: TObject);
begin
COBJ_Function;
end;

end.

arthurprs
30-09-2008, 01:04 AM
solved in parts :)

now delphi is complaining about a missing those variables
extern unsigned char *wordpointer;
extern int bitindex;


how i can declare them on delphi?


edit: if i remove the extern keyword the application trows an access violation when the lib tries access those variables :?