Recent

Author Topic: What exactly is the o. file?  (Read 22276 times)

Danail

  • Full Member
  • ***
  • Posts: 151
What exactly is the o. file?
« on: March 21, 2007, 02:26:27 pm »
So?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
RE: What exactly is the o. file?
« Reply #1 on: March 21, 2007, 02:45:48 pm »
a .o file is a so called object file.
This file contains compiled code. FPC compiles every unit into a .o (and a .ppu, containing info needed for fpc). After compilation, all .o files get linked together through a linker (ld or the internal linker) into a executable.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Danail

  • Full Member
  • ***
  • Posts: 151
What exactly is the o. file?
« Reply #2 on: March 22, 2007, 04:31:39 pm »
Then can I use a the o. file of some of my units in another program. If I can, then how?

abb

  • New Member
  • *
  • Posts: 40
What exactly is the o. file?
« Reply #3 on: March 22, 2007, 07:08:06 pm »
Quote from: "Danail"
Then can I use a the o. file of some of my units in another program. If I can, then how?

I'd look at the compiler directives. Borland pascal compilers have {$L} directive for object files linking. Hope Free Pascal also has similar directive. Please take a look at the docs.

HTH!

Danail

  • Full Member
  • ***
  • Posts: 151
What exactly is the o. file?
« Reply #4 on: March 23, 2007, 02:01:58 pm »
I used the {$L} option and the program compiled successfuly, so it is supported. However it remained to me unclear how to use the functions and the procedures there (in the linked o. file). Trying to call them provokes error.

Bart

  • Hero Member
  • *****
  • Posts: 5563
    • Bart en Mariska's Webstek
What exactly is the o. file?
« Reply #5 on: March 23, 2007, 03:50:23 pm »
Did you declare the functions you want to use from the .o file like
Code: [Select]
{$L someunit.o}
procedure foo; external;

This is the old TP style of linking in external object files.

Bart

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
What exactly is the o. file?
« Reply #6 on: March 23, 2007, 05:25:00 pm »
And now the question.....
Why do you want to do this ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Danail

  • Full Member
  • ***
  • Posts: 151
What exactly is the o. file?
« Reply #7 on: March 23, 2007, 08:48:02 pm »
It has many advantages. Now I can think out for two: you can use units without revealing your code; use code compiled with GCC and other languages creating o. files without even knowing the language that they are made.

abb

  • New Member
  • *
  • Posts: 40
What exactly is the o. file?
« Reply #8 on: March 24, 2007, 12:52:11 pm »
Quote from: "Danail"
I used the {$L} option and the program compiled successfuly, so it is supported. However it remained to me unclear how to use the functions and the procedures there (in the linked o. file). Trying to call them provokes error.

Do you know the calling model type of your external procedure? May be it it is a C procedure? It's worth to know it.

Danail

  • Full Member
  • ***
  • Posts: 151
What exactly is the o. file?
« Reply #9 on: March 24, 2007, 08:39:36 pm »
Er... by the way does anyone know a java compiler that makes o. files?

abb

  • New Member
  • *
  • Posts: 40
What exactly is the o. file?
« Reply #10 on: March 25, 2007, 08:37:28 pm »
Quote from: "Danail"
Er... by the way does anyone know a java compiler that makes o. files?

Offtopic....

Java COMPILER??? Java is not a compiler. It works a p-code, which Java RTE interpets and executes. This is the reason why Java is platform-independent.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
What exactly is the o. file?
« Reply #11 on: March 25, 2007, 10:11:08 pm »
If you want to convert java code to .o files, I would say you shouldn't be using Java in the first place.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
What exactly is the o. file?
« Reply #12 on: March 26, 2007, 11:46:04 am »
Bewarned that you cannot export any class, ansistring or dynarray this way.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Danail

  • Full Member
  • ***
  • Posts: 151
What exactly is the o. file?
« Reply #13 on: March 28, 2007, 11:00:10 am »
If the o. file is a readily compiled output, so it is supposed to be a platform dependant. So o. file compiled for windows may not be useful on Linux, Is it right?

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
What exactly is the o. file?
« Reply #14 on: March 28, 2007, 01:39:51 pm »
Quote from: "Danail"
If the o. file is a readily compiled output, so it is supposed to be a platform dependant. So o. file compiled for windows may not be useful on Linux, Is it right?


Yes, exactly.

 

TinyPortal © 2005-2018