Background
When you execute make testnet
or make mainnet
with okc code, you may encounter the following error:
ld: library not found for -llz4
ld: library not found for -lsnappy
These errors are usually found on MacOS.
Solution
First make sure you have successfully executed make rocksdb
For MacOS, execute the following command:
brew update
brew install snappy
# or
brew install lz4
Retry make testnet
or make mainnet
. Usually the problem is solved.
Try this if it is still not working, and retry 3
:
export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix lz4)/lib/
export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix snappy)/lib/
In rare cases, you may encounter this error:
In file included from _cgo_export.c:4:
debugger.go:23:13: warning: unused function '_duk_debugger_attach' [-Wunused-function]
# github.com/okex/exchain/cmd/exchaind
/usr/local/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
ld: warning: ignoring file /usr/local/lib/librocksdb.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /usr/local/opt/snappy/lib//libsnappy.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /usr/local/opt/lz4/lib//liblz4.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"_rocksdb_approximate_memory_usage_create", referenced from:
__cgo_9c7e07974d9b_Cfunc_rocksdb_approximate_memory_usage_create in 000015.o
(maybe you meant: __cgo_9c7e07974d9b_Cfunc_rocksdb_approximate_memory_usage_create)
"_rocksdb_approximate_memory_usage_destroy", referenced from:
__cgo_9c7e07974d9b_Cfunc_rocksdb_approximate_memory_usage_destroy in 000015.o
This means you are on a arm64 system but have the x86 libraries installed。it happens when you install the wrong version brew. you need to reinstall the brew in the system terminal. then perform the above steps, but of course you need to uninstall the installed lz4 or snappy first.