Recent

Author Topic: Linking error: Unsupported target architecture  (Read 1746 times)

andies

  • Newbie
  • Posts: 2
Linking error: Unsupported target architecture
« on: January 15, 2022, 07:32:41 pm »
I just installed Lazarus on an Apple M1 (2020, OS Monterey 12.1) as described in the wiki. I did not install XCode but only the command line tools and had to upgrade them immediately. Then I installed the precompiled binary fpc and wrote my usual program
Code: Pascal  [Select][+][-]
  1. program Project1;
  2. begin
  3.   writeln('Hello World');
  4. end.
  5.  
and smoothly runs through fpc. Then I installed lazarus and if I compile this program I get the error
Code: Pascal  [Select][+][-]
  1. Error: Unsupported target architecture -Paarch64, invoke the "fpc" compiler driver instead.
(I have used target OS=darwin and architecture=aarch64; if I use default I get an i386-error). Is there someone who can help me?

PS fpc Compiler version 3.2.2 [2021/05/16] for aarch64, Lazarus 2.2.0
« Last Edit: January 15, 2022, 07:34:42 pm by andies »

VTwin

  • Hero Member
  • *****
  • Posts: 1112
  • Former Turbo Pascal 3 user
Re: Linking error: Unsupported target architecture
« Reply #1 on: January 15, 2022, 08:48:50 pm »
Did you install:

fpc-3.2.2.intelarm64-macosx.dmg
fpc-src-3.2.2-20210709-macosx.dmg
Lazarus-2.2.0-0-x86_64-macosx.pkg

These work fine for me.

“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 10.13.6: Lazarus 2.2.0 (64 bit Cocoa)
macOS 12.0.1: Lazarus 2.2.0 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.0 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.0 (64 bit on VBox)

andies

  • Newbie
  • Posts: 2
Re: Linking error: Unsupported target architecture
« Reply #2 on: January 15, 2022, 09:09:28 pm »
Yes, these are exactly the three files I used. On the first run I mixed everything up (starting with Lazarus instead of XCode compile tools), I then had to uninstall everything and started anew. To no avail.

Did you modify any of the config details in lazarus or fpc?

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 970
Re: Linking error: Unsupported target architecture
« Reply #3 on: January 15, 2022, 09:12:00 pm »
This suggests you have configured ppcx64 rather than "fpc" as your compiler binary in Lazarus (Lazarus menu -> Preferences -> Environment: compiler executable should be /usr/local/bin/fpc).

VTwin

  • Hero Member
  • *****
  • Posts: 1112
  • Former Turbo Pascal 3 user
Re: Linking error: Unsupported target architecture
« Reply #4 on: January 15, 2022, 09:21:36 pm »
No. Maybe your lazarus config info was not updated when you reinstalled.

Try Jonas' answer.
« Last Edit: January 15, 2022, 09:27:25 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 10.13.6: Lazarus 2.2.0 (64 bit Cocoa)
macOS 12.0.1: Lazarus 2.2.0 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.0 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.0 (64 bit on VBox)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1983
  • Former Delphi 1-7, 10.2 user
Re: Linking error: Unsupported target architecture
« Reply #5 on: January 15, 2022, 10:28:12 pm »
I had a similar issue rebuilding the IDE from within the IDE (to get a native aarch64 version):

Quote
    make[2]: *** [lazarus] Error 1
    make[1]: *** [idepkg] Error 2
    Error: make: *** [idepkg] Error 2
    Error: Unsupported target architecture -Paarch64, invoke the "fpc" compiler driver instead.

which was a little weird because the Preferences > Compiler executable was set to /usr/local/bin/fpc. The rather unintuitive solution (given the compiler error) was to change that to /usr/local/lib/fpc/3.2.2/ppca64 instead.
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 x86_64 Xcode 13.4
Lazarus 2.3, FPC 3.3.1 macOS 12.3.1 aarch64 Xcode 13.4

VTwin

  • Hero Member
  • *****
  • Posts: 1112
  • Former Turbo Pascal 3 user
Re: Linking error: Unsupported target architecture
« Reply #6 on: January 15, 2022, 11:35:48 pm »
To clarify my earlier response, note that there is a configuration folder ".lazarus" in your home folder. If you look inside you will see "environmentoptions.xml" that contains paths for the compiler, etc.

My guess is that the folder was created during your first (faulty) install, and retained the old settings when you reinstalled. As I recall, there is an option during installation to remove the old settings, instead of upgrading. Did you do that?

By the way, shift-command-period is a handy toggle for hidden file display, it can be easier than navigating in the terminal.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 10.13.6: Lazarus 2.2.0 (64 bit Cocoa)
macOS 12.0.1: Lazarus 2.2.0 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.0 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.0 (64 bit on VBox)

 

TinyPortal © 2005-2018