Zig cc build leveldb failed

Hi guys, I try build leveldb using zig cc with following commands, but it failed on my macOS

export CC='zig cc'
export CXX='zig c++'

git clone --recurse-submodules https://github.com/google/leveldb.git

mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release .. && cmake --build .

Error message

[ 65%] Building CXX object CMakeFiles/leveldb_tests.dir/util/logging_test.cc.o
[ 66%] Linking CXX executable leveldb_tests
MachO Flush... error(link): entrypoint '_main' not found
error: MissingMainEntrypoint
make[2]: *** [leveldb_tests] Error 1
make[2]: *** Deleting file `leveldb_tests'
make[1]: *** [CMakeFiles/leveldb_tests.dir/all] Error 2
make: *** [all] Error 2

It seems that it failed in link stage, Did anyone have any clue?

Some software I’m using

  • Zig: 0.11.0-dev.669+bd5a8f86a
  • macOS: Darwin mbp-m1 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101 arm64