Compilation failed in Linux

Hello,

As per the title, compiling the C-SDK in Linux failed (ArchLinux, kernel 5.15.24-1-lts x86_64).

I also tried with cmake --build . but got the same result.

You can find the trace below. Thanks!

#( 02/17/22@ 6:20PM )( fernando@animal ):~/Documents/vortex/ziti/ziti-sdk-c/build@main✔
   make
[  0%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/fs-poll.c.o
[  1%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/idna.c.o
[  1%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/inet.c.o
[  2%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/random.c.o
[  2%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/strscpy.c.o
[  2%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/threadpool.c.o
[  3%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/timer.c.o
[  3%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/uv-common.c.o
[  4%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/uv-data-getter-setters.c.o
[  4%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/version.c.o
[  4%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/async.c.o
[  5%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/core.c.o
[  5%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/dl.c.o
[  6%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/fs.c.o
[  6%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/getaddrinfo.c.o
[  6%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/getnameinfo.c.o
[  7%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/loop-watcher.c.o
[  7%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/loop.c.o
[  8%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/pipe.c.o
[  8%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/poll.c.o
[  8%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/process.c.o
[  9%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/random-devurandom.c.o
[  9%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/signal.c.o
[ 10%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/stream.c.o
[ 10%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/tcp.c.o
[ 11%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/thread.c.o
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/libuv-src/src/unix/thread.c: In function 'thread_stack_size':
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/libuv-src/src/unix/thread.c:194:24: warning: comparison of integer expressions of different signedness: 'rlim_t' {aka 'long unsigned int'} and 'long int' [-Wsign-compare]
  194 |       if (lim.rlim_cur >= PTHREAD_STACK_MIN)
      |                        ^~
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/libuv-src/src/unix/thread.c: In function 'uv_thread_create_ex':
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/libuv-src/src/unix/thread.c:242:20: warning: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'long int' [-Wsign-compare]
  242 |     if (stack_size < PTHREAD_STACK_MIN)
      |                    ^
[ 11%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/tty.c.o
[ 11%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/udp.c.o
[ 12%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/proctitle.c.o
[ 12%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/linux-core.c.o
[ 13%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/linux-inotify.c.o
[ 13%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/linux-syscalls.c.o
[ 13%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/procfs-exepath.c.o
[ 14%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/random-getrandom.c.o
[ 14%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/random-sysctl-linux.c.o
[ 15%] Building C object _deps/libuv-build/CMakeFiles/uv_a.dir/src/unix/sysinfo-loadavg.c.o
[ 15%] Linking C static library libuv_a.a
[ 15%] Built target uv_a
[ 16%] Building C object _deps/uv-mbed-build/deps/CMakeFiles/http-parser.dir/__/__/http_parser-src/http_parser.c.o
[ 16%] Built target http-parser
[ 16%] Building C object _deps/uv-mbed-build/deps/CMakeFiles/uv_link.dir/__/__/uv_link-src/src/uv_link_t.c.o
[ 17%] Building C object _deps/uv-mbed-build/deps/CMakeFiles/uv_link.dir/__/__/uv_link-src/src/uv_link_source_t.c.o
[ 17%] Building C object _deps/uv-mbed-build/deps/CMakeFiles/uv_link.dir/__/__/uv_link-src/src/uv_link_observer_t.c.o
[ 18%] Building C object _deps/uv-mbed-build/deps/CMakeFiles/uv_link.dir/__/__/uv_link-src/src/defaults.c.o
[ 18%] Built target uv_link
[ 18%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/aes.c.o
[ 19%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/aesni.c.o
[ 19%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/arc4.c.o
[ 19%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/aria.c.o
[ 20%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/asn1parse.c.o
[ 20%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/asn1write.c.o
[ 21%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/base64.c.o
[ 21%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/bignum.c.o
[ 21%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/blowfish.c.o
[ 22%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/camellia.c.o
[ 22%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/ccm.c.o
[ 23%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/chacha20.c.o
[ 23%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/chachapoly.c.o
[ 24%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/cipher.c.o
[ 24%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/cipher_wrap.c.o
[ 24%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/cmac.c.o
[ 25%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/ctr_drbg.c.o
[ 25%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/des.c.o
[ 26%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/dhm.c.o
[ 26%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/ecdh.c.o
[ 26%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/ecdsa.c.o
[ 27%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/ecjpake.c.o
[ 27%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/ecp.c.o
[ 28%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/ecp_curves.c.o
[ 28%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/entropy.c.o
[ 28%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/entropy_poll.c.o
[ 29%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/error.c.o
[ 29%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/gcm.c.o
[ 30%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/havege.c.o
[ 30%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/hkdf.c.o
[ 30%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/hmac_drbg.c.o
[ 31%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/md.c.o
[ 31%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/md2.c.o
[ 32%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/md4.c.o
[ 32%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/md5.c.o
[ 33%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/memory_buffer_alloc.c.o
[ 33%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/nist_kw.c.o
[ 33%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/oid.c.o
[ 34%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/padlock.c.o
[ 34%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/pem.c.o
[ 35%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/pk.c.o
[ 35%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/pk_wrap.c.o
[ 35%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/pkcs12.c.o
[ 36%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/pkcs5.c.o
[ 36%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/pkparse.c.o
[ 37%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/pkwrite.c.o
[ 37%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/platform.c.o
[ 37%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/platform_util.c.o
[ 38%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/poly1305.c.o
[ 38%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/psa_crypto.c.o
[ 39%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/psa_crypto_se.c.o
[ 39%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/psa_crypto_slot_management.c.o
[ 39%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/psa_crypto_storage.c.o
[ 40%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/psa_its_file.c.o
[ 40%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/ripemd160.c.o
[ 41%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/rsa.c.o
[ 41%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/rsa_internal.c.o
[ 41%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/sha1.c.o
[ 42%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/sha256.c.o
[ 42%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/sha512.c.o
[ 43%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/threading.c.o
[ 43%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/timing.c.o
[ 44%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/version.c.o
[ 44%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/version_features.c.o
[ 44%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/xtea.c.o
[ 45%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/__/3rdparty/everest/library/everest.c.o
[ 45%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/__/3rdparty/everest/library/x25519.c.o
[ 46%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedcrypto.dir/__/3rdparty/everest/library/Hacl_Curve25519_joined.c.o
[ 46%] Linking C static library libmbedcrypto.a
[ 46%] Built target mbedcrypto
[ 47%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedx509.dir/certs.c.o
[ 47%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedx509.dir/pkcs11.c.o
[ 48%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedx509.dir/x509.c.o
[ 48%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedx509.dir/x509_create.c.o
[ 49%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedx509.dir/x509_crl.c.o
[ 49%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedx509.dir/x509_crt.c.o
[ 49%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedx509.dir/x509_csr.c.o
[ 50%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedx509.dir/x509write_crt.c.o
[ 50%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedx509.dir/x509write_csr.c.o
[ 51%] Linking C static library libmbedx509.a
[ 51%] Built target mbedx509
[ 51%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/debug.c.o
[ 52%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/net_sockets.c.o
[ 52%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/ssl_cache.c.o
[ 53%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/ssl_ciphersuites.c.o
[ 53%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/ssl_cli.c.o
[ 53%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/ssl_cookie.c.o
[ 54%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/ssl_msg.c.o
[ 54%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/ssl_srv.c.o
[ 55%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/ssl_ticket.c.o
[ 55%] Building C object _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/ssl_tls.c.o
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:1730:41: error: argument 2 of type 'unsigned char[36]' with mismatched bound [-Werror=array-parameter=]
 1730 |                           unsigned char hash[36],
      |                           ~~~~~~~~~~~~~~^~~~~~~~
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:690:63: note: previously declared as 'unsigned char *'
  690 | static void ssl_calc_verify_tls( const mbedtls_ssl_context *, unsigned char *, size_t * );
      |                                                               ^~~~~~~~~~~~~~~
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:1762:48: error: argument 2 of type 'unsigned char[32]' with mismatched bound [-Werror=array-parameter=]
 1762 |                                  unsigned char hash[32],
      |                                  ~~~~~~~~~~~~~~^~~~~~~~
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:697:69: note: previously declared as 'unsigned char *'
  697 | static void ssl_calc_verify_tls_sha256( const mbedtls_ssl_context *,unsigned char *, size_t * );
      |                                                                     ^~~~~~~~~~~~~~~
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:1811:48: error: argument 2 of type 'unsigned char[48]' with mismatched bound [-Werror=array-parameter=]
 1811 |                                  unsigned char hash[48],
      |                                  ~~~~~~~~~~~~~~^~~~~~~~
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:703:70: note: previously declared as 'unsigned char *'
  703 | static void ssl_calc_verify_tls_sha384( const mbedtls_ssl_context *, unsigned char *, size_t * );
      |                                                                      ^~~~~~~~~~~~~~~
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c: In function 'ssl_calc_verify_tls_sha384':
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:1845:5: error: 'mbedtls_sha512_finish_ret' accessing 64 bytes in a region of size 48 [-Werror=stringop-overflow=]
 1845 |     mbedtls_sha512_finish_ret( &sha512, hash );
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:1845:5: note: referencing argument 2 of type 'unsigned char *'
In file included from /home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/include/mbedtls/ssl_internal.h:53,
                 from /home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:47:
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/include/mbedtls/sha512.h:147:5: note: in a call to function 'mbedtls_sha512_finish_ret'
  147 | int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c: In function 'ssl_calc_finished_tls_sha384':
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:3266:5: error: 'mbedtls_sha512_finish_ret' accessing 64 bytes in a region of size 48 [-Werror=stringop-overflow=]
 3266 |     mbedtls_sha512_finish_ret( &sha512, padbuf );
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:3266:5: note: referencing argument 2 of type 'unsigned char *'
In file included from /home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/include/mbedtls/ssl_internal.h:53,
                 from /home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/library/ssl_tls.c:47:
/home/fernando/Documents/vortex/ziti/ziti-sdk-c/build/_deps/mbedtls-src/include/mbedtls/sha512.h:147:5: note: in a call to function 'mbedtls_sha512_finish_ret'
  147 | int mbedtls_sha512_finish_ret( mbedtls_sha512_context *ctx,
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [_deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/build.make:202: _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/ssl_tls.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:611: _deps/mbedtls-build/library/CMakeFiles/mbedtls.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Out of curiosity, are you on the latest main branch and have you issued a pull lately? Also, what version of GCC do you have?

I just tried it myself in a clean ubuntu image and also had a compilation error but for me it was just past where you were. Mine ended up failing on the newest stuff added recently which is just past where yours failed.

I have:

gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

Failure for me below (but not relevant to you yet)

[ 58%] Building C object _deps/uv-mbed-build/CMakeFiles/uv_mbed.dir/src/base64.c.o
[ 59%] Building C object _deps/uv-mbed-build/CMakeFiles/uv_mbed.dir/src/tls_engine.c.o
[ 59%] Building C object _deps/uv-mbed-build/CMakeFiles/uv_mbed.dir/src/compression.c.o
/tmp/ziti-sdk-c/linux/_deps/uv-mbed-src/src/compression.c:3:10: fatal error: zlib.h: No such file or directory
    3 | #include <zlib.h>
      |          ^~~~~~~~
compilation terminated.
make[2]: *** [_deps/uv-mbed-build/CMakeFiles/uv_mbed.dir/build.make:193: _deps/uv-mbed-build/CMakeFiles/uv_mbed.dir/src/compression.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:504: _deps/uv-mbed-build/CMakeFiles/uv_mbed.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

Yes and yesterday.

gcc --version
gcc (GCC) 11.2.0

it appears that the version of mbedTLS we are using by default is not supporting gcc-11 yet

on option – maybe even preferred, depending on your circumstances – is to use OpenSSL instead.
to use OpenSSL specify -DUSE_OPENSSL=on to your cmake configuration step

you need to apt install zlib1g-dev to get that header

Can you guide to me which file to edit and with what please?

not a file.

When you run CMake the first time, you’d add that option, something like this (in your build directory):

$ cmake -G Ninja -DUSE_OPENSSL=on <path to source>

I did as asked, got a different error on a fresh build: #( 02/18/22@ 5:08PM )( fernando@animal ):~/Documents/vortex/ziti/ziti-sdk-c/buil - Pastebin.com

Hi and thanks for getting back to us. We’ve been using older gcc versions in our linux build systems so you are finding a few bumps related to the newer compiler version. Can you try a clean build from a branch that pulls in gcc11-compatible dependencies - GitHub - openziti/ziti-sdk-c at uv-mbed.13.10 ?

1 Like

Hi @falves, fyi the branch that I mentioned in my previous no longer exists, because it has been merged to main. Please pull the changes and let us know how it goes!

1 Like

It was built successfully. Many thanks!

Now that it was built, any suggestions on how to use it? I see no install or use instructions.

The primary artifact of the ziti-sdk-c project is a library that you can use to connect your own c/c++ applications over a ziti network.

Have a look at Overview | Ziti for some background on what a ziti network is and how to set one up.

You can install the ziti library and its includes with cmake:

$ cmake --install . --prefix /wherever/you/want

Then you can #include "ziti/ziti.h" in your application and use the Ziti API to initiate or accept connections. The best documentation that we currently have for using the ziti-sdk-c is the sample applications at ziti-sdk-c/programs at main · openziti/ziti-sdk-c · GitHub. Most of these applications are simple clients that connect to a ziti service. sample-host is an example of a server application (that accepts connections from ziti clients).

Finally ziti-prox-c is a simple proxy that makes it possible for existing tcp/ip client apps to connect through a ziti network.

1 Like

Given the output of cmake --install:

.
|-- include
|   |-- uv
|   |-- uv.h
|   |-- uv_mbed
|   `-- ziti
|-- lib
|   |-- libuv.so -> libuv.so.1
|   |-- libuv.so.1 -> libuv.so.1.0.0
|   |-- libuv.so.1.0.0
|   |-- libuv_a.a
|   |-- libuv_mbed.a
|   |-- libziti.a
|   |-- libziti.so
|   `-- pkgconfig
`-- share
    `-- doc

I assume the intended install point is /usr so as to use the ziti libs as any other system lib:

$ cmake --install . --prefix /usr

I installed in /usr as I mentioned in the previous post, and I got this output compiling one of your git examples:

   gcc -o host host.c
host.c: In function 'on_signal':
host.c:155:20: warning: passing argument 2 of 'ziti_dump' from incompatible pointer type [-Wincompatible-pointer-types]
  155 |     ziti_dump(ztx, fprintf, stdout);
      |                    ^~~~~~~
      |                    |
      |                    int (*)(FILE * restrict,  const char * restrict, ...)
In file included from host.c:18:
/usr/include/ziti/ziti.h:579:47: note: expected 'int (*)(void *, const char *, ...)' but argument is of type 'int (*)(FILE * restrict,  const char * restrict, ...)'
  579 | extern void ziti_dump(ziti_context ztx, int (*printer)(void *ctx, const char *fmt, ...), void *ctx);
      |                                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccdv9wiz.o: warning: relocation against `ZITI_EOF' in read-only section `.text'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `on_client_data':
host.c:(.text+0xb2): undefined reference to `ziti_write'
/usr/bin/ld: host.c:(.text+0xba): undefined reference to `ZITI_EOF'
/usr/bin/ld: host.c:(.text+0xe2): undefined reference to `ziti_close'
/usr/bin/ld: host.c:(.text+0xef): undefined reference to `ziti_errorstr'
/usr/bin/ld: host.c:(.text+0x122): undefined reference to `ziti_close'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `on_client_connect':
host.c:(.text+0x13d): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x17f): undefined reference to `ziti_write'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `on_client':
host.c:(.text+0x19f): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x25d): undefined reference to `ziti_accept'
/usr/bin/ld: host.c:(.text+0x269): undefined reference to `ziti_errorstr'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `listen_cb':
host.c:(.text+0x2a7): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x2b6): undefined reference to `ziti_errorstr'
/usr/bin/ld: host.c:(.text+0x2de): undefined reference to `ziti_errorstr'
/usr/bin/ld: host.c:(.text+0x30b): undefined reference to `ziti_close'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `on_write':
host.c:(.text+0x334): undefined reference to `ziti_errorstr'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `input_read':
host.c:(.text+0x41c): undefined reference to `ziti_write'
/usr/bin/ld: host.c:(.text+0x425): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x434): undefined reference to `ziti_errorstr'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `on_connect':
host.c:(.text+0x487): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x496): undefined reference to `ziti_errorstr'
/usr/bin/ld: host.c:(.text+0x4cd): undefined reference to `ziti_conn_context'
/usr/bin/ld: host.c:(.text+0x4d5): undefined reference to `ziti_app_ctx'
/usr/bin/ld: host.c:(.text+0x504): undefined reference to `uv_pipe_init'
/usr/bin/ld: host.c:(.text+0x520): undefined reference to `uv_pipe_open'
/usr/bin/ld: host.c:(.text+0x529): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x538): undefined reference to `ziti_errorstr'
/usr/bin/ld: host.c:(.text+0x580): undefined reference to `uv_read_start'
/usr/bin/ld: host.c:(.text+0x589): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x598): undefined reference to `ziti_errorstr'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `on_data':
host.c:(.text+0x5e0): undefined reference to `ZITI_EOF'
/usr/bin/ld: host.c:(.text+0x5f3): undefined reference to `ziti_errorstr'
/usr/bin/ld: host.c:(.text+0x61b): undefined reference to `ziti_close'
/usr/bin/ld: host.c:(.text+0x62a): undefined reference to `ziti_shutdown'
/usr/bin/ld: host.c:(.text+0x641): undefined reference to `ziti_errorstr'
/usr/bin/ld: host.c:(.text+0x673): undefined reference to `ziti_close'
/usr/bin/ld: host.c:(.text+0x682): undefined reference to `ziti_shutdown'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `on_signal':
host.c:(.text+0x6f9): undefined reference to `ziti_dump'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `on_ziti_init':
host.c:(.text+0x737): undefined reference to `ZITI_PARTIALLY_AUTHENTICATED'
/usr/bin/ld: host.c:(.text+0x74c): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x760): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x773): undefined reference to `ziti_errorstr'
/usr/bin/ld: host.c:(.text+0x7c7): undefined reference to `uv_signal_start'
/usr/bin/ld: host.c:(.text+0x7ed): undefined reference to `ziti_conn_init'
/usr/bin/ld: host.c:(.text+0x834): undefined reference to `ziti_listen_with_options'
/usr/bin/ld: host.c:(.text+0x8a5): undefined reference to `ziti_dial_with_options'
/usr/bin/ld: host.c:(.text+0x8ae): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x8bd): undefined reference to `ziti_errorstr'
/usr/bin/ld: /tmp/ccdv9wiz.o: in function `main':
host.c:(.text+0x94e): undefined reference to `uv_default_loop'
/usr/bin/ld: host.c:(.text+0x9d6): undefined reference to `ziti_init'
/usr/bin/ld: host.c:(.text+0x9df): undefined reference to `ZITI_OK'
/usr/bin/ld: host.c:(.text+0x9ee): undefined reference to `ziti_errorstr'
/usr/bin/ld: host.c:(.text+0xa2f): undefined reference to `uv_signal_init'
/usr/bin/ld: host.c:(.text+0xa40): undefined reference to `uv_run'
/usr/bin/ld: host.c:(.text+0xa5e): undefined reference to `ziti_shutdown'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status

Am I doing something dumb or…?

You just need to tell the linker about libziti.so:

$ gcc -I /home/scarey/ziti-install/include -L /home/scarey/ziti-install/lib64 sample-host.c -l ziti
sample-host.c: In function ‘on_signal’:
sample-host.c:155:20: warning: passing argument 2 of ‘ziti_dump’ from incompatible pointer type [-Wincompatible-pointer-types]
  155 |     ziti_dump(ztx, fprintf, stdout);
      |                    ^~~~~~~
      |                    |
      |                    int (*)(FILE * restrict,  const char * restrict, ...)
In file included from sample-host.c:18:
/home/scarey/ziti-install/include/ziti/ziti.h:579:47: note: expected ‘int (*)(void *, const char *, ...)’ but argument is of type ‘int (*)(FILE * restrict,  const char * restrict, ...)’
  579 | extern void ziti_dump(ziti_context ztx, int (*printer)(void *ctx, const char *fmt, ...), void *ctx);
      |                                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ ./host
Usage: ./host <client|server> <config-file> <service-name>

Pointing to the lib worked, but shouldn’t that be handled by the include statements?

Some compilers do support so-called auto-linking, where the linked libraries can be specified by pragmas in the include files. To my knowledge gcc does not support this.

1 Like