1

I'm programing ADA with GPS. The problem is that when I compile any code with GPS I get this error:

ld: library not found for -lSystem collect2: error: ld returned 1 exit status

I have updated and reinstalled everything (xcode, gcc), reinstalled GPS, and installed comand line tools.

That's what GPS show to me by terminal:

gprbuild -d -P/Users/pedromarti/Desktop/helloWorld/default.gpr /Users/pedromarti/Desktop/helloWorld/src/main.adb Bind [gprbind] main.bexch [Ada] main.ali Link [link] main.adb ld: library not found for -lSystem collect2: error: ld returned 1 exit status gprbuild: link of main.adb failed gprbuild: failed command was: /users/pedromarti/opt/gnat/2019/bin/gcc main.o b__main.o -L/Users/pedromarti/Desktop/helloWorld/obj/ -L/Users/pedromarti/Desktop/helloWorld/obj/ -L/users/pedromarti/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/ /users/pedromarti/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/libgnat.a -Wl,-rpath,@executable_path/ -Wl,-rpath,@executable_path/../../..//opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib -o main [2021-03-18 13:38:56] process exited with status 4, elapsed time: 02.57s

I don't know what more I can do. If anyone knows a solution, you are welcome!

Sir_Peter
  • 56
  • 5

2 Answers2

5

You’re using GNAT Community Edition 2019. I can’t tell which OS release you’re running on, and in this case I don’t think it makes a difference.

The README from the download site says

== Mac OS: Xcode is now needed ==

On Mac OS, GNAT Community 2019 requires Xcode version 10 or above to be
installed. Once you do have Xcode installed, if you still observe an error
of the form:

  ld: library not found for -lSystem

then you might have to execute the following:

  xcode-select -s /Applications/Xcode.app/Contents/Developer

Xcode is large but free, and takes a while to download from the App Store (go to the Develop tab).

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
-1

If your building system has a cache system, you need to clear the cache.

For example, if you are using cmake, remember to delete cmake build directory to avoid the cmakecache take it to the wrong link.

junka
  • 11
  • 2