Sign in Join

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

Mailing lists / fpc-pascal / 2008-08

FPC shared libraries for Mac OS X

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Werner Bochtler

Hi,

Can anyone give me a hint how to set the 'install_name', 'compatibility_version' and 'current_version' in FPC shared libraries for Mac OS X?

By default my libraries get the following values:

- install_name: <complete path to the generated library>
- compatibility_version: 0.0.0
- current_version: 0.0.0

Many thanks in advance,

Werner

Reply by email

Jonas Maebe
to Werner Bochtler
Werner Bochtler wrote
Can anyone give me a hint how to set the 'install_name', 'compatibility_version' and 'current_version' in FPC shared libraries for Mac OS X?

In exactly the same way as for a C shared library: by passing the appropriate flags to the linker. From "man ld":

-install_name name
Sets an internal "install path" (LC_ID_DYLIB) in a dynamic
library. Any clients linked against the library will record
that path as the way dyld should locate this
library. If
this option is not specified, then the -o path will be used.
This option is also called -dylib_install_name for compati-
bility.

-compatibility_version number
Specifies the compatibility version number of the
library.
When a library is loaded by dyld, the compatibility version
is checked and if the program's version is greater that the
library's version, it is an error. The format of
number is
X[.Y[.Z]] where X must be a positive non-zero number less
than or equal to 65535, and .Y and .Z are optional and if
present must be non-negative numbers less than or
equal to
255. If the compatibility version number is not
specified,
it has a value of 0 and no checking is done when the library
is used. This option is also called -
dylib_compatibil-
ity_version for compatibility.

-current_version number
Specifies the current version number of the library. The cur-
rent version of the library can be obtained
programmatically
by the user of the library so it can determine
exactly which
version of the library it is using. The format of number is
X[.Y[.Z]] where X must be a positive non-zero number less
than or equal to 65535, and .Y and .Z are optional and if
present must be non-negative numbers less than or
equal to
255. If the version number is not specified, it has a value
of 0. This option is also called -
dylib_current_version for
compatibility.

->

fpc -k"-install_name somename" -k"-compatibility_version 1.2.3" -k"- current_version 11.12.13" mysharedlib.pp

Jonas

Reply by email

Werner Bochtler
to Jonas Maebe
Jonas Maebe wrote 14 lines
On 19 Aug 2008, at 12:55, Werner Bochtler wrote: > Can anyone give me a hint how to set the 'install_name', > 'compatibility_version' and 'current_version' in FPC shared > libraries for Mac OS X? In exactly the same way as for a C shared library: by passing the appropriate flags to the linker. -> fpc -k"-install_name somename" -k"-compatibility_version 1.2.3" -k"-current_version 11.12.13" mysharedlib.pp

This works fine for the commandline but if I try to add e.g. -k"-install_name libTest.1.dylib" to my local configuration file fpc.cfg I get the following error message:

ld: unknown option: -install_name libTest.1.dylib
/usr/bin/libtool: internal link edit command failed

Any ideas?

Thanks in advance,

Werner

Reply by email

Jonas Maebe
to Werner Bochtler
Werner Bochtler wrote 9 lines
This works fine for the commandline but if I try to add e.g. -k"-install_name libTest.1.dylib" to my local configuration file fpc.cfg I get the following error message: ld: unknown option: -install_name libTest.1.dylib /usr/bin/libtool: internal link edit command failed Any ideas?

Anything you enter on the command line is first interpreted by the shell. Using "..." has a special meaning in shells: it means "treat everything between these two characters as a single string, but still interpret any shell variables or other substitution commands in this string". The result is that when fpc asks for the paramstr(x) corresponding to this parameter, it will see

-k-install_name libTest.1.dylib

(as one parameter, with the space). Without the quotes, fpc would see two parameters, the first one being -k-install_name and the second one libTest.1.dylib

If you put parameters inside a configuration file, then those parameters are not interpreted by any shell, but read straight away by fpc. So if you put -k"-install_name libTest.1.dylib" in there, fpc will actually read that exact string. As a result, it will not pass this to the linker:

-install_name libTest.1.dylib

but this:

"-install_name libTest.1.dylib"

The result is that the linker will not get the two parameters it expects (first a parameter called -install_name, followed by a parameter with the name of the install name), but one single parameter called

-install_name libTest.1.dylib

There is obviously no linker parameter with that name.

You may want to read some tutorials about unix shell scripting if you're going to be working a lot on the command line.

Jonas

Reply by email