Build failure with C SDK

Hi, I’m trying to build ziti-sdk-c (standalone) but am facing a linker error. To build, I followed the instructions in BUILD.md.

[125/131] Linking CXX executable tests/Debug/all_tests
FAILED: [code=1] tests/Debug/all_tests
: && /bin/c++ -g -pthread -Wl,--dependency-file=tests/CMakeFiles/all_tests.dir/Debug/link.d tests/CMakeFiles/all_tests.dir/Debug/test_ziti_model.cpp.o tests/CMakeFiles/all_tests.dir/Debug/test_jwt.cpp.o tests/CMakeFiles/all_tests.dir/Debug/model_tests.cpp.o tests/CMakeFiles/all_tests.dir/Debug/test_metrics.cpp.o tests/CMakeFiles/all_tests.dir/Debug/enum_tests.cpp.o tests/CMakeFiles/all_tests.dir/Debug/collections_tests.cpp.o tests/CMakeFiles/all_tests.dir/Debug/buffer_tests.cpp.o tests/CMakeFiles/all_tests.dir/Debug/pool_tests.cpp.o tests/CMakeFiles/all_tests.dir/Debug/ziti_src_tests.cpp.o tests/CMakeFiles/all_tests.dir/Debug/message_tests.cpp.o tests/CMakeFiles/all_tests.dir/Debug/util_tests.cpp.o -o tests/Debug/all_tests -L/home/ben/code/openziti/ziti-sdk-c/build/lib -Wl,-rpath,/home/ben/code/openziti/ziti-sdk-c/build/lib  library/Debug/libziti.a  vcpkg_installed/x64-linux/debug/lib/libCatch2d.a  vcpkg_installed/x64-linux/debug/lib/manual-link/libCatch2Maind.a  _deps/tlsuv-build/Debug/libtlsuv.a  /usr/lib/libssl.so  /usr/lib/libcrypto.so  vcpkg_installed/x64-linux/debug/lib/libuv.a  -lpthread  -ldl  -lrt  vcpkg_installed/x64-linux/debug/lib/libz.a  vcpkg_installed/x64-linux/debug/lib/libllhttp.a  vcpkg_installed/x64-linux/lib/libsodium.a  /usr/lib/libpthread.a  vcpkg_installed/x64-linux/debug/lib/libjson-c.a  vcpkg_installed/x64-linux/lib/libprotobuf-c.a  vcpkg_installed/x64-linux/lib/libstc.a  -lm  -latomic  -lm  vcpkg_installed/x64-linux/debug/lib/libCatch2d.a && :
/usr/bin/ld: tests/CMakeFiles/all_tests.dir/Debug/test_jwt.cpp.o: in function `cstr_with_n(char const*, long)':
/home/ben/code/openziti/ziti-sdk-c/build/vcpkg_installed/x64-linux/include/stc/priv/cstr_prv.h:102:(.text+0x196): undefined reference to `_cstr_init(cstr*, long, long)'
/usr/bin/ld: tests/CMakeFiles/all_tests.dir/Debug/util_tests.cpp.o: in function `cstr_with_n(char const*, long)':
/home/ben/code/openziti/ziti-sdk-c/build/vcpkg_installed/x64-linux/include/stc/priv/cstr_prv.h:102:(.text+0x14c): undefined reference to `_cstr_init(cstr*, long, long)'
collect2: error: ld returned 1 exit status
[129/131] Building CXX object programs/auth-samples/CMakeFiles/jwt-auth.dir/Debug/jwt_auth.cpp.o
ninja: build stopped: subcommand failed.

I’m building on Arch Linux. I also tried building in a debian trixie docker container, and I got the same error.

Context: my eventual goal is to call the C SDK via Rust FFI. I figured I’d start by just building the C SDK.

Thanks in advance for any help.

Please share the complete build logs (via pastebin service).

Complete build log: ziti-sdk-c build log - Pastebin.com

If there is any extra verbosity I should enable, please just let me know. I’m not the most familiar with CMake.

this may be related to you using gcc-15 for your build

if you just want to build SDK and do not care about ziti-sdk internal tests you can turn off building tests using ziti_DEVELOPER_MODE=OFF on your cmake command:
cmake --preset=ci-linux-x64 -Dziti_DEVELOPER_MODE=OFF ..

1 Like