Sign in Join

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

Mailing lists / fpc-pascal / 2010-08

darwin external library name

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

dmitry boyarintsev

Hi All

Is it expected behavior, that explicitly set library name is not used in linking for Drawin target (fpc 2.5.1)?

function SomeFunc: Integer; external 'LibName';

'LibName' is not added to link.res, so {$linklib LibName} is required for successful linking.

Docs says nothing about it:
http://lazarus-ccr.sourceforge.net/fpcdoc/prog/progsu131.html#x175-1720007.1.1 In fact, docs say that the linker should use the specified library name. If ignoring the specified name is fine, then it's worthy adding it to docs.

thanks,
dmitry

Jonas Maebe
to dmitry boyarintsev
dmitry boyarintsev wrote
Is it expected behavior, that explicitly set library name is not used in linking for Drawin target (fpc 2.5.1)? function SomeFunc: Integer; external 'LibName';

The log entry for the removal of that functionality was this:

revision 1.16
date: 2004-06-02 09:03:49 +0200; author: jonas; state: Exp; lines: +11 -3;
- disabled automatic adding of libraries from "external lib name 'xxx'"
for now (until we have proper framework support)

The problem was (and actually still is) that many of those units can be used either in combination with a library or with a framework. In one case you need {$linklib LibName}, in the other case {$linkframework LibName}. If you don't want to force one or the other on the program using the unit (and if you don't want to create two ppu files for every import unit), then deciding which library/framework to use should be left to the main program. Rather than adding {$ifndef darwin}'s around every declaration's external library name, I decided that simply ignoring those library names for Darwin would be better.

Now, in many cases we added {$linklib LibName} for Darwin to the units anyway so in practice it doesn't make that much of a difference. I guess in some cases we use {$linkframework xxx} instead though. We could add a switch to decide that the external library names should be interpreted as framework names instead, since I guess in most units everything is either in a library or in a framework (rather than in a mixture of libraries and frameworks).

I don't know what the best solution is.

Jonas

dmitry boyarintsev
to Jonas Maebe
Jonas Maebe wrote
I don't know what the best solution is.

Thanks for the explanation, I've had a feeling that's caused by framework/library selection.

Should it be added to the documentation?

thanks,
dmitry

dmitry boyarintsev
to dmitry boyarintsev

Another lib naming bug (seems to be darwin only).
If the name contains '-' character, the compiler fails to assemble the unit with "Error while assembling exitcode 1"
(which is strange, since the name should be ignored).

the example:

function anyfunc2: Integer; external name 'libname';
function anyfunc: Integer; external name 'libname-1';
begin
  writeln(anyfunc2); // all is fine
  writeln(anyfunc); // assembling error here
end.

should i bug report this? should i bug report the missing note in documentation about darwin external library names?

thanks,
dmitry