I tried to access a Delphi DLL from within a C program compiled with Borland's command line C compiler (BCC 5.5.1), but it does not accept the .lib file associated with the DLL. When I try to compile a test program I get the error message "'C:\TEMP\HW\DLLTEST.LIB' contains invalid OMF record, type 0x21 (possibly COFF)". I searched the Web for some explanation, but all sites I found say that this error is typical for trying to access a MS .lib file while BCC expects a Borland format. The advice is to use implib to create a Borland type .lib file. But this is exactly what I did to create the .lib file (details below). Any hints?

Dieter K�hler



This is how I created the .lib file from the .dll and tried to compile a test program (hw.c):


C:\temp\hw>implib dllTest.dll Reading dllTest.dll GetDelphiString Writing library DLLTEST.lib for DLLTEST.DLL 1 members, NrOfSymbols 4

C:\temp\hw>bcc32 hw.c DLLTEST.lib
Borland C++ 5.5.1 for Win32 Copyright (c) 1993, 2000 Borland
hw.c:
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: 'C:\TEMP\HW\DLLTEST.LIB' contains invalid OMF record, type 0x21 (possibly
COFF)



This is my Delphi dll project: ------------------------------

library dllTest;

uses
  Windows;

{$R *.res}

function GetDelphiString: PChar; cdecl;
begin
MessageBox(0, 'Click OK and GetDelphiString will return a string!', 'Info',
MB_OK or MB_TASKMODAL);
result := PChar('This is a string passed from a Delphi DLL');
end;


  exports
     GetDelphiString;

begin


This is the C file (hw.c): --------------------------

#include <stdio.h>
#include "DLLTEST.h"

int main(void)
{
  char* S = GetDelphiString();
  puts(S);
  return 0;
}

This is the C header file (DLLTEST.h):
--------------------------------------
char* __cdecl GetDelphiString(void);



_______________________________________________
Delphi mailing list
[EMAIL PROTECTED]
http://ns3.123.co.nz/mailman/listinfo/delphi

Reply via email to