Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2002-03

c -> fpc

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Peter Beisel

Hi all,
I need your help!

Compiler: FPC 1.0.4
Target: GO32V2

I want to link some librarys generated by a 32bit c-compiler (target: DOS) to my FPC programs.

1. WatCom
Neither the *.LIB nor the *.OBJ files generated by WatCom are accepted from the FP linker. Is there any way to make them usable?

2. DJGPP
The *.o files generated by DJGPP are accepted from the FP linker and the generated EXE-file executes quite well.

BUT: the *.o file represents only the code of the one module.

Example:
DJGPP:
test.h:
long aFunc()

test.c:
long aFunk()
{
return 4711
}

compile: test.o

FPC:
Testo.PAS:
program Testo;
uses crt;
{l test.o}
function aFunc: longint; cdecl; external;
begin
writeln( aFunc);
end.

Compile, link, run: output: 4711 - very well.

You see this little module needs nothing else. All it's code is represented by it's o-File (test.o). If test.c needs other modules their code is not represented in test.o. You need to link to this other modules too. But if there is a reference to a library, there is no object file that represents the code of the library. You have to bind a library yourself. And now you are at the point:

How can a library generated by DJGPP linked into a FPC program ?? -----------------------------------------------------------------

Regards, Peter

Reply by email

Marco van de Voort
to Peter Beisel
Show quoted text 10 lines
You see this little module needs nothing else. All it's code is represented by it's o-File (test.o). If test.c needs other modules their code is not represented in test.o. You need to link to this other modules too. But if there is a reference to a library, there is no object file that represents the code of the library. You have to bind a library yourself. And now you are at the point: How can a library generated by DJGPP linked into a FPC program ?? -----------------------------------------------------------------
{$linklib <libname>}

and make sure your searchpath (-Fl) is ok.

See packages/base/gdbint/gdbint.pp (or packages/gdbint/gdbint.pp if you have older sources) as an example. (links in several libs for the debugger support of the IDE)

Reply by email

Peter Beisel
to Marco van de Voort

Thank you very much,
I tried what you told me.
1. from the IDE: no error message but also no EXE-file
2. from the IDE: with option: "Call linker after": Error message : cannot open -llib1.a no such file or directory (ENOENT) (lib1.a is my archiv)
3. from command line (DOS) Error message : cannot open -lc:\t2\lib1.a no such file or directory (ENOENT) (but there is the file c:\t2\lib1.a)

My lib1.a was created with DJGPP - but do I need special compiler switches? Examining my lib1.a with a hex-editor: !<arch> are the first charakters - seems realy to be an archive file.
Projekt folder: c:\t2
Lib Path: c:\t2
File Path: c:\t2
Location of the lib1.a file: C:\t2\lib1.a

But the linker tells me in any case: connot open -lLib1.a no such file or directory (ENOENT)
Could it be the format is wrong?

What's about the compiler switches is found in the example gdbint.pp:

{$ifdef go32v2}
  {$undef NotImplemented}
  { ifdef GDB_V418 changed to ifndef GDB_V416}
  {$ifdef USE_GDB_OBJS}
    {$include gdbobjs.inc}
  {$else USE_GDB_OBJS}
    {$LINKLIB gdb}
    {$ifdef GDB_V5}
      {$LINKLIB bfd}
      {$LINKLIB readline}
      {$LINKLIB opcodes}
      {$LINKLIB history}
      {$LINKLIB iberty}
    {$endif GDB_V5}
  {$endif ndef USE_GDB_OBJS}
  {$LINKLIB dbg}
  {$LINKLIB c}
{$endif go32v2}

Have I to use them?

Regards, Peter

Show quoted text 14 lines
> How can a library generated by DJGPP linked into a FPC program ?? > ----------------------------------------------------------------- {$linklib <libname>} and make sure your searchpath (-Fl) is ok. See packages/base/gdbint/gdbint.pp (or packages/gdbint/gdbint.pp if you have older sources) as an example. (links in several libs for the debugger support of the IDE) _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email