Not able to build a project because of this issue:

error: linking with `cc` failed: exit status: 1
  = note: "cc" "-arch" "arm64" "/var/folders/5w/j2mkxftx2xz55c696xp23gzh0000gn/T/rustciwy51y/symbols.o" "/Users/elioprifti/dkg-substrate/target/debug/deps/dkg_standalone_node-3e72bef5f25657ad.10sw7xj1rkq1p2nk.rcgu.o" "/Users/elioprifti/dkg-substrate/target/debug/deps/dkg_standalone_node-3e72bef5f25657ad.10ut9rvejkcsmvr1.rcgu.o" "/Users/elioprifti/dkg-substrate/target/debug/deps/dkg_standalone_node-3e72bef5f25657ad.112iyrdupdm8w5vw.rcgu.o" "/Users/elioprifti/dkg-substrate/target/debug/deps/elioprifti/.rustup/toolchains/nightly-2022-05-15-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-d0e3d0b2f5dc30fb.rlib" "/Users/elioprifti/.rustup/toolchains/nightly-2022-05-15-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunwind-12083e42f9a7d1fc.rlib" "/Users/elioprifti/.rustup/toolchains/nightly-2022-05-15-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-def158ba03cb504e.rlib" "/Users/elioprifti/.rustup/toolchains/nightly-2022-05-15-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liblibc-e83dd9bd71bd52bd.rlib" "/Users/elioprifti/.rustup/toolchains/nightly-2022-05-15-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-a149d8756e403a5c.rlib" "/Users/elioprifti/.rustup/toolchains/nightly-2022-05-15-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-95a7e52c78a3fba1.rlib" "/Users/elioprifti/.rustup/toolchains/nightly-2022-05-15-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-dd6de681850a671c.rlib" "/Users/elioprifti/.rustup/toolchains/nightly-2022-05-15-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-ec608688b97371b8.rlib" "-lgmp" "-framework" "Security" "-framework" "Security" "-lc++" "-framework" "SystemConfiguration" "-framework" "Security" "-framework" "CoreFoundation" "-liconv" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" "-L" "/Users/elioprifti/.rustup/toolchains/nightly-2022-05-15-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "-o" "/Users/elioprifti/dkg-substrate/target/debug/deps/dkg_standalone_node-3e72bef5f25657ad" "-Wl,-dead_strip" "-nodefaultlibs"
  = note: ld: library not found for -lgmp
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: could not compile `dkg-standalone-node` due to previous error
warning: build failed, waiting for other jobs to finish...
elioprifti@pc-193-62 dkg-substrate % 

I can build other projects but not this one. Any idea?

  • Have you run xcode-select --install?
    – Bruno
    Nov 23, 2022 at 17:36
  • I have run it but still the same.
    – P.E
    Nov 23, 2022 at 18:04
  • If you're using stable-aarch64-apple-darwin toolchain, you could try switching to stable-x86_64-apple-darwin and see if that resolves the issue.
    – Bruno
    Nov 23, 2022 at 18:12
  • I tried. Still the same!
    – P.E
    Nov 23, 2022 at 19:21
  • If you search for ld: library not found for you will get lots of similar errors which may help in troubleshooting this issue.
    – Bruno
    Nov 23, 2022 at 21:02

2 Answers 2


I assume you are trying to build dkg-substrate, not substrate or the node template.
In your case the GMP library seems to be missing.
Their CI file indicates some libs that are needed here, eg libgmp3-dev. There is also tutorial for building it here.

  • I was able to install the GMP library but still have the same issue!
    – P.E
    Nov 23, 2022 at 17:07
  • 1
    Then open an issue in their GitHub or ask in chat first if mac is supported. Nov 23, 2022 at 17:40
  • Already did, they do not know how to fix it.
    – P.E
    Nov 23, 2022 at 20:37

It is likely because your machine didn't have the minimum required RAM or Swap space free to run Substrate.

On macOS you can show CPU and memory usage in the terminal by running top -l 1 | grep -E "^CPU|^Phys":

> top -l 1 | grep -E "^CPU|^Phys"

CPU usage: 15.61% user, 26.72% sys, 57.66% idle 
PhysMem: 7935M used (2256M wired), 255M unused.

Since you they say you need at least 4 Gb RAM to run Substrate, you would want the output to say you have at least 4000M unused since that corresponds with ~4 Gb.

On macOS you can show Swap space usage in the terminal by running sysctl vm.swapusage:

> sysctl vm.swapusage

vm.swapusage: total = 5120.00M  used = 4269.50M  free = 850.50M  (encrypted)

What does those commands output for you?

I recently got the same error on an Ubuntu 22.04.2 LTS machine. I had accidentally used a less performant "Linode 4 GB" machine, which has only 2 CPUs, 4 Gb RAM. When I entered lscpu it output AMD EPYC 7601 32-Core Processor, so the CPU speed was 2.2 GHz. I had at least 36 Gb SSD hard disk space available. I had cloned the latest commit of Substrate's 'master' branch dated 9th March 2023. I had followed the official documentation instructions to install Substrate here and all relevant dependencies on Ubuntu. I tried building with cargo build, but during the installaion I got the error during the build:

   Compiling node-cli v3.0.0-dev (/root/substrate/bin/node/cli)
error: linking with `cc` failed: exit status: 1
  = note: "cc" "-m64"
  = note: collect2: fatal error: ld terminated with signal 9 [Killed]
          compilation terminated.

error: could not compile `node-cli` due to previous error

I checked how much hard disk space i had with df -H and it showed I still had 20 Gb free I checked how much swap space i had with free -h, which showed I only had 1.4 Gb RAM free and only 150Mb of swap space free:

free -h
               total        used        free      shared  buff/cache   available
Mem:           3.8Gi       2.2Gi       1.4Gi        10Mi       271Mi       1.4Gi
Swap:          511Mi       359Mi       152Mi

I think the reason so much memory was already being used was because I was running also running a full node to support a Substrate-based chain on that machine. So I increased my swap space to 10 Gb (10240) (since I had plenty of hard disk space free) by running:

sudo dd if=/dev/zero of=/swap_file bs=10240 count=1M
sudo chmod 600 /swap_file
sudo mkswap /swap_file
sudo swapon /swap_file

Then I checked how much memory I had again with free -h, which showed that whilst I only had 110 Mb RAM Memory free, I now had 10 Gb Swap space free:

               total        used        free      shared  buff/cache   available
Mem:           3.8Gi       2.2Gi       110Mi        10Mi       1.5Gi       1.4Gi
Swap:           10Gi       362Mi        10Gi

I then tried continuing with the installation by running cargo build again, and this time it fully build successfully, likely because it had almost finished building previously, and because it was now using the extra Swap space I had added for when it ran out of RAM (Mem).

So the reason for the error was primarily because the machine I was using didn't have enough RAM (memory), since I only had 4 Gb and most of it was already being used up. I got around it by increasing the Swap space.

It says here in the official macOS instructions that on macOS you need a machine with at least 2 Ghz CPU (processor), and at least 8 Gb RAM (memory), and at least 10 Gb of hard disk space available (I think you need might need more hard disk space than that). Those minimum specifications should actually be shown on https://docs.substrate.io/install/, since it applies to all operating systems, and it doesn't mention the minimum system that you need on the official Linux instructions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.