Recent

Author Topic: how to use/link .c files in lazarus as .obj like in delphi?  (Read 7584 times)

Человек_Борща

  • New Member
  • *
  • Posts: 33
    • My little IT world.
how to use/link .c files in lazarus as .obj like in delphi?
« on: August 26, 2013, 07:13:21 pm »
Greetings all!

I search solution for ZLib & GZIP(priority) using in Lazarus from Delphi. As a base, I'm use Delphi.Zlib sources, and want to implement Lazarus support into it.

Project sources compile ok, but compiler can't link .obj files, and I have that errors:
Quote
Note: DWARF debug information cannot be used with smart linking on this target, switching to static linking
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_DEFLATEINIT_$TZSTREAMREC$LONGINT$PCHAR$LONGINT$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_DEFLATEINIT2_$crcB53E13EB
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_DEFLATE$TZSTREAMREC$LONGINT$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_DEFLATEEND$TZSTREAMREC$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_DEFLATERESET$TZSTREAMREC$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_INFLATEINIT_$TZSTREAMREC$PCHAR$LONGINT$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_INFLATEINIT2_$TZSTREAMREC$LONGINT$PCHAR$LONGINT$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_INFLATE$TZSTREAMREC$LONGINT$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_INFLATEEND$TZSTREAMREC$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_INFLATERESET$TZSTREAMREC$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_ADLER32$LONGINT$formal$LONGINT$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: ZLIBEXAPI_CRC32$LONGINT$formal$LONGINT$$LONGINT
project1.lpr(20,1) Error: Undefined symbol: memcpy
project1.lpr(20,1) Error: Undefined symbol: memset
project1.lpr(20,1) Error: Undefined symbol: zcalloc
project1.lpr(20,1) Error: Undefined symbol: zcfree
project1.lpr(20,1) Error: Undefined symbol: z_errmsg
project1.lpr(20,1) Error: Undefined symbol: __ImageBase
project1.lpr(20,1) Fatal: There were 18 errors compiling module, stopping

How to resolve that?  Also I have sources of Zlib as *.c files, how to make FPC/Lazarus compatible *.obj files from it?
With best regards, Alexandr.
_
OS: Windows 8.1 x64 / Ubuntu 14.02 x64
IDE: CodeTyphon 5.4 (win32-win64/win64) / FPC 3.1.1

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1947
« Last Edit: August 27, 2013, 11:44:37 am by theo »

Человек_Борща

  • New Member
  • *
  • Posts: 33
    • My little IT world.
Re: how to use/link .c files in lazarus as .obj like in delphi?
« Reply #2 on: August 27, 2013, 11:49:00 am »
Sources is too old. I think, it cant be compile under new lazarus, and file access methods goes from prehistoric times  :(
I need work with GZIP in memory, no files.

Maybe rebuild C zlib sources to object-files for FPC is more simple, but how to do that?
« Last Edit: August 27, 2013, 11:58:26 am by Человек_Борща »
With best regards, Alexandr.
_
OS: Windows 8.1 x64 / Ubuntu 14.02 x64
IDE: CodeTyphon 5.4 (win32-win64/win64) / FPC 3.1.1

ttomas

  • Sr. Member
  • ****
  • Posts: 251

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1947
Re: how to use/link .c files in lazarus as .obj like in delphi?
« Reply #4 on: August 27, 2013, 11:57:06 am »
Sources is too old. I think, it cant be compile under new lazarus, and file access methods goes from prehistoric times  :(

Hu? These files are part of Lazarus and Freepascal. You don't need to install external packages.

just write
Code: [Select]
uses zstream;

Leledumbo

  • Hero Member
  • *****
  • Posts: 8836
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: how to use/link .c files in lazarus as .obj like in delphi?
« Reply #5 on: August 27, 2013, 04:50:55 pm »
Quote
Sources is too old. I think, it cant be compile under new lazarus, and file access methods goes from prehistoric times  :(
I need work with GZIP in memory, no files.
The unit is part of paszlib, which is shipped with fpc, it should be compilable (and in fact, it is) as newer fpc comes. Last commit was on 24th December 2012. File access uses modern techniques using streams. I really have no idea how you get such a conclusion...

Человек_Борща

  • New Member
  • *
  • Posts: 33
    • My little IT world.
Re: how to use/link .c files in lazarus as .obj like in delphi?
« Reply #6 on: August 27, 2013, 05:26:20 pm »
I build *.o files, using GGC
Code: [Select]
gcc.exe -c <filename>.c
But linker doesn't link it:
Quote
project1.lpr(20,1) Error: Illegal COFF Magic while reading F:\Program Files (x86)\CMP\ZLib\Lazarus\deflate.o
With best regards, Alexandr.
_
OS: Windows 8.1 x64 / Ubuntu 14.02 x64
IDE: CodeTyphon 5.4 (win32-win64/win64) / FPC 3.1.1

 

TinyPortal © 2005-2018