Recent

Author Topic: (Solved) Static linking in FPC 3.3.1 problem  (Read 443 times)

Igor Kokarev

  • Full Member
  • ***
  • Posts: 199
(Solved) Static linking in FPC 3.3.1 problem
« on: July 28, 2020, 09:54:07 am »
I get this error:

Quote
StaticLinkingUtils.pas(63,65) Fatal: Syntax error, "BEGIN" expected but "[" found

On this line:
Code: Pascal  [Select][+][-]
  1. function _log(x: double): double; cdecl; export; {$ifdef Win64} [alias: 'log']; {$endif}
  2. begin
  3.   result := 0; // ln(x);
  4. end;

I use this code to link statically some .o files from GCC compiler.

I attach full code in a file.

Lazarus 2.1.0 r63658 FPC 3.3.1 x86_64-win64-win32/win64

P.S. No problem with FPC 3.2.0
« Last Edit: July 30, 2020, 10:51:41 am by Igor Kokarev »

Cyrax

  • Hero Member
  • *****
  • Posts: 830
Re: Static linking in FPC 3.3.1 problem
« Reply #1 on: July 28, 2020, 09:59:31 am »
Change [alias: 'log']; to external name 'log'.

Igor Kokarev

  • Full Member
  • ***
  • Posts: 199
Re: Static linking in FPC 3.3.1 problem
« Reply #2 on: July 28, 2020, 01:19:03 pm »
Thanks, can you show full line of a code?

I get a new error:

Code: Pascal  [Select][+][-]
  1. function _log(x: double): double; cdecl; export; external name 'log';

Quote
StaticLinkingUtils.pas(64,50) Error: Procedure directive "EXTERNAL" cannot be used with "EXPORT"

Cyrax

  • Hero Member
  • *****
  • Posts: 830
Re: Static linking in FPC 3.3.1 problem
« Reply #3 on: July 28, 2020, 01:35:56 pm »
Remove export; directive.

Cyrax

  • Hero Member
  • *****
  • Posts: 830
Re: Static linking in FPC 3.3.1 problem
« Reply #4 on: July 28, 2020, 01:47:07 pm »
Sorry, I just took a look at your unit file. Either change [alias: 'log'] to [public, alias: 'log'] or use public name 'log'.

https://www.freepascal.org/docs-html/ref/refsu71.html

Igor Kokarev

  • Full Member
  • ***
  • Posts: 199
Re: Static linking in FPC 3.3.1 problem
« Reply #5 on: July 30, 2020, 10:51:28 am »
Thanks! Your solution helped me to compile my app in FPC Trunk!

 

TinyPortal © 2005-2018