Forum > Ported from Delphi/Kylix
Convert Delphi Package that uses C .obj files?
snorkel:
I have a older Delphi component package from Delphi 6 and I got it to compile, but it won't link as it uses several C .obj files compiled with C++ builder.
Is there anyway to recompile those c files if the source is available so they can work with Lazarus?
taazz:
--- Quote from: snorkel on November 09, 2015, 06:24:24 pm ---I have a older Delphi component package from Delphi 6 and I got it to compile, but it won't link as it uses several C .obj files compiled with C++ builder.
Is there anyway to recompile those c files if the source is available so they can work with Lazarus?
--- End quote ---
yes fpc can statically link what ever the mingw gcc compiles.
snorkel:
So the only issue may be whether or not mingw will have issues with the C++ builder source.
The component docs say it's C code so I guess that should work.
The current obj files raise this error when linking:
lazarus.pp(142,1) Error: Illegal COFF Magic while reading C:\Users\snorkel\Documents\laz_components\Envision\Trees.Obj
Cyrax:
FPC doesn't support OMF object format which is used in (Turbo) C++ Builder. If you don't have source files for those .obj files, there isn't much to be done.
parcel:
I'm using TDM-GCC with C sources in the past.
In opensource Imgaginlib, tiff support with compiled OBJ files, It works.
zlib in Imaginglib like this,
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit ZLibDelphi; interface uses SysUtils; const {$ifdef FPC} ZLIB_VERSION = '1.2.8'; {$else} ZLIB_VERSION = '1.2.1'; {$endif} Z_NO_FLUSH = 0; Z_FINISH = 4; Z_OK = 0; Z_STREAM_END = 1; type PRZStream = ^RZStream; RZStream = record NextIn: PByte; AvailIn: Cardinal; TotalIn: Cardinal; NextOut: PByte; AvailOut: Cardinal; TotalOut: Cardinal; Msg: PAnsiChar; State: Pointer; AllocFunc: Pointer; FreeFunc: Pointer; Opaque: Cardinal; DataType: Integer; Adler: Cardinal; Reserved: Cardinal; end; function inflateInit_(strm: Pointer; version: Pointer; stream_size: Integer): Integer; cdecl; external;function inflateReset(strm: Pointer): Integer; cdecl; external;function inflate(strm: Pointer; flush: Integer): Integer; cdecl; external;function inflateSync(strm: Pointer): Integer; cdecl; external;function deflateInit(strm: Pointer; level: Integer): Integer;function deflateInit_(strm: Pointer; level: Integer; version: Pointer; stream_size: Integer): Integer; cdecl; external;function deflateReset(strm: Pointer): Integer; cdecl; external;function deflate(strm: Pointer; flush: Integer): Integer; cdecl; external;function deflateEnd(strm: Pointer): Integer; cdecl; external;function inflateEnd(strm: Pointer): Integer; cdecl; external;function deflateParams(strm: Pointer; level: Integer; strategy: Integer): Integer; cdecl; external; implementation uses LibDelphi; function deflateInit(strm: Pointer; level: Integer): Integer;begin Result:=deflateInit_(strm,level,PAnsiChar(ZLIB_VERSION),SizeOf(RZStream));end; {$ifdef FPC}{$ifndef CPUX86_64}{$L Compiled\inflate.o}{$else}{$L Compiled\x64\inflate.o}{$endif}{$ifndef CPUX86_64}{$L Compiled\crc32.o}{$else}{$L Compiled\x64\crc32.o}{$endif}{$ifndef CPUX86_64}{$L Compiled\adler32.o}{$else}{$L Compiled\x64\adler32.o}{$endif}{$ifndef CPUX86_64}{$L Compiled\inftrees.o}{$else}{$L Compiled\x64\inftrees.o}{$endif}{$ifndef CPUX86_64}{$L Compiled\inffast.o}{$else}{$L Compiled\x64\inffast.o}{$endif}{$ifndef CPUX86_64}{$L Compiled\deflate.o}{$else}{$L Compiled\x64\deflate.o}{$endif}{$ifndef CPUX86_64}{$L Compiled\zutil.o}{$else}{$L Compiled\x64\zutil.o}{$endif}{$ifndef CPUX86_64}{$L Compiled\trees.o}{$else}{$L Compiled\x64\trees.o}{$endif}{$ifndef CPUX86_64}{$L Compiled\compress.o}{$else}{$L Compiled\x64\compress.o}{$endif}{$ifndef CPUX86_64}{$L Compiled\uncompr.o}{$else}{$L Compiled\x64\uncompr.o}{$endif}{$else}{$L Compiled\inflate.obj}{$L Compiled\crc32.obj}{$L Compiled\adler32.obj}{$L Compiled\inftrees.obj}{$L Compiled\inffast.obj}{$L Compiled\deflate.obj}{$L Compiled\zutil.obj}{$L Compiled\trees.obj}{$L Compiled\compress.obj}{$L Compiled\uncompr.obj}{$endif} end.
also need libdelphi.pas in attachment.
but it's not good idea, sometimes conflict with other lib linked other parts. cannot find local 'C' proxy functions(malloc, free and so on) in unit definition. when it's defined global, sometimes conflict with other library functions, but delphi is not.
And other example is pcre.
Navigation
[0] Message Index
[#] Next page