Getting error while building node from source

On a step
make install
getting the error

# github.com/algorand/go-algorand/crypto
crypto/batchverifier.go:33:11: fatal error: 'sodium.h' file not found
 #include "sodium.h"
          ^~~~~~~~~~
1 error generated.
make: *** [buildsrc] Error 2

Even though the file exists under crypto/libs/darwin/arm64/include/sodium.h

I am using MacOS Monterey 12.1 with Apple chip

1 Like

Did you follow the README.md instructions ?

Yes I did follow the README.md instructions

Are there any suggestions ?

I explicitly created symlinks from

/usr/local/include/ to crypto/libs/darwin/arm64/include/sodium/ 
and crypto/libs/darwin/arm64/include/sodium.h

and the error has gone. But now I am facing a new error

# github.com/algorand/go-algorand/crypto
clang: error: no such file or directory: ...go-algorand/crypto/libs/darwin/amd64/lib/libsodium.a'
clang: error: no such file or directory: '...go-algorand/crypto/libs/darwin/amd64/lib/libsodium.a'

Why is it trying to use amd64 if my arch is arm64

Manually replacing all occurrences with

// #cgo darwin,arm64 CFLAGS: -I${SRCDIR}/libs/darwin/arm64/include
// #cgo darwin,arm64 LDFLAGS: ${SRCDIR}/libs/darwin/arm64/lib/libsodium.a

results in

# github.com/algorand/go-algorand/crypto
Undefined symbols for architecture x86_64:
  "_crypto_sign_ed25519_bv_compatible_verify_detached", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_bv_compatible_verify_detached in _x003.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_bv_compatible_verify_detached)
  "_crypto_sign_ed25519_detached", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_detached in _x003.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_detached)
  "_crypto_sign_ed25519_open_batch", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_open_batch in _x002.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_open_batch)
  "_crypto_sign_ed25519_seed_keypair", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_seed_keypair in _x003.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_seed_keypair)
  "_crypto_sign_ed25519_sk_to_pk", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_sk_to_pk in _x003.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_sk_to_pk)
  "_crypto_sign_ed25519_sk_to_seed", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_sk_to_seed in _x003.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_sk_to_seed)
  "_crypto_sign_ed25519_verify_detached", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_verify_detached in _x003.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_sign_ed25519_verify_detached)
  "_crypto_vrf_keypair", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_vrf_keypair in _x004.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_vrf_keypair_from_seed, __cgo_6c86a93ba422_Cfunc_crypto_vrf_keypair )
  "_crypto_vrf_keypair_from_seed", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_vrf_keypair_from_seed in _x004.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_vrf_keypair_from_seed)
  "_crypto_vrf_proof_to_hash", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_vrf_proof_to_hash in _x004.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_vrf_proof_to_hash)
  "_crypto_vrf_prove", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_vrf_prove in _x004.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_vrf_prove)
  "_crypto_vrf_sk_to_pk", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_vrf_sk_to_pk in _x004.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_vrf_sk_to_pk)
  "_crypto_vrf_verify", referenced from:
      __cgo_6c86a93ba422_Cfunc_crypto_vrf_verify in _x004.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_crypto_vrf_verify)
  "_sodium_init", referenced from:
      __cgo_6c86a93ba422_Cfunc_sodium_init in _x003.o
     (maybe you meant: __cgo_6c86a93ba422_Cfunc_sodium_init)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [buildsrc] Error 2

Solved the issue! I had a wrong go version for amd64 instead of arm64
Reinstalled go, started from the beginning building process and then needed to add one more workaround symlink (like in this thread Can't build node from source)
/usr/local/include/boost -> homebrew/include/boost
After this make install finished

1 Like

The amd64 go got me…
but for the symlink, I did it with

export CPLUS_INCLUDE_PATH="$(brew --prefix)/include"