Recent

Author Topic: ld: library not found for -lc  (Read 7160 times)

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1066
Re: ld: library not found for -lc
« Reply #15 on: December 15, 2022, 10:06:52 pm »
It means "pass this parameter to the compiler". See e.g. the first post in this thread, where TomAylesworth executes fpc SphericalHouses.pas in a Terminal window to compile a program. Passing an extra parameter would entail adding that string at the end of this invocation.

If you are using Lazarus to compile programs, you can add extra parameters in Project -> Project Options… -> Compiler Options -> Custom Options

Cavender

  • New Member
  • *
  • Posts: 12
Re: ld: library not found for -lc
« Reply #16 on: December 16, 2022, 10:16:35 pm »
Thank you!  That works.

jamescavender@jamescadersimac RainGauge % fpc iterator.pas -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
Free Pascal Compiler version 3.2.2 [2021/05/16] for aarch64
Copyright (c) 1993-2021 by Florian Klaempfl and others
Target OS: Darwin for AArch64
Compiling iterator.pas
Assembling iterator
Linking iterator
29 lines compiled, 0.1 sec
jamescavender@jamescadersimac RainGauge %

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1066
Re: ld: library not found for -lc
« Reply #17 on: December 16, 2022, 10:44:50 pm »
You can create a file called ".fpc.cfg" in your home directory (note the leading dot) with the following contents. Then you don't have to add that parameter manually every time.
Code: Pascal  [Select][+][-]
  1. #include /etc/fpc.cfg
  2. -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
  3.  

csukuangfj

  • New Member
  • *
  • Posts: 16
Re: ld: library not found for -lc
« Reply #18 on: August 14, 2024, 06:41:12 am »
In the worst case, you should be able to work around it by passing -XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk to the compiler, but it really should not be necessary.

The issue is not the assembler or the linker. The assembler works (FPC uses clang for that), otherwise you would not get to the stage where it looks for the C library. And the linker itself (ld) also works, since it's trying to link but it cannot find the C library. The fact that it cannot find the C library means the macOS SDK is not installed in the default location by the Xcode command line tools installer (in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk). FPC uses that one by default because in principle you can move the Xcode application around, but if it's in the default location, the above -XR parameter should also work.

Thanks!

Passing

```
-XR/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
```

to the compiler `fpc` indeed works!
« Last Edit: August 14, 2024, 07:25:36 am by csukuangfj »

 

TinyPortal © 2005-2018