# Ziti -tunnel-sdk-c compilation steps

**URL:** <https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122>\
**Category:** Building/Development\
**Created:** [November 21, 2020, 4:07pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122 "2020-11-21T16:07:47Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![shikumar](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@shikumar](https://openziti.discourse.group/u/shikumar)\
**Post date:** [November 21, 2020, 4:07pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/1 "2020-11-21T16:07:47Z")

</div>

Hi Team,  
Can someone list all the steps to compile the code after cloning the repository from [GitHub - openziti/ziti-tunnel-sdk-c](https://github.com/openziti/ziti-tunnel-sdk-c.git)

Thanks.  
Shiv

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [November 21, 2020, 4:08pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/2 "2020-11-21T16:08:42Z")

</div>

Hi Shiv - you’re just trying to build? Are you familiar with cmake?

---

<div class="post-metadata">

**Author:** ![shikumar](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@shikumar](https://openziti.discourse.group/u/shikumar)\
**Post date:** [November 21, 2020, 4:11pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/3 "2020-11-21T16:11:51Z")

</div>

I have used it but not too familiar with setting it up.

---

<div class="post-metadata">

**Author:** ![smilindave26](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/smilindave26/32/185_2.png) [@smilindave26](https://openziti.discourse.group/u/smilindave26)\
**Post date:** [November 21, 2020, 4:14pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/4 "2020-11-21T16:14:17Z")

</div>

Assuming you’re not cross-compiling, give this a try after the clone:

```auto
$ mkdir ziti-tunnel-sdk-c/build
$ cd ziti-tunnel-sdk-c/build
$ cmake .. && make

```

---

<div class="post-metadata">

**Author:** ![shikumar](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@shikumar](https://openziti.discourse.group/u/shikumar)\
**Post date:** [November 21, 2020, 4:19pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/5 "2020-11-21T16:19:26Z")

</div>

Thanks @smilidave, build went through!

---

<div class="post-metadata">

**Author:** ![Danieleb](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@Danieleb](https://openziti.discourse.group/u/Danieleb)\
**Post date:** [May 19, 2022, 8:33am UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/6 "2022-05-19T08:33:52Z")

</div>

Hi Dave,

I have been trying to cross compile Ziti -tunnel-sdk-c for windows using Ubuntu and the following command:

cmake -DCMAKE\_SYSTEM\_NAME=Windows -DCMAKE\_C\_COMPILER=i686-w64-mingw32-gcc -DCMAKE\_CXX\_COMPILER=i686-w64-mingw32-g++ WIN32 … && make

but have got stuck and not sure what I need to do toresolve this. I have tried installing libsodium-dev but still get errors with regards to secretstream.

/usr/bin/i686-w64-mingw32-ld: CMakeFiles/ziti\_dll.dir/objects.a(connect.c.obj): in function `ziti_write_req': /home/daniel/ZITI/ziti-tunnel-sdk-c/build/_deps/ziti-sdk-c-src/library/connect.c:596: undefined reference to `crypto\_secretstream\_xchacha20poly1305\_abytes’  
/usr/bin/i686-w64-mingw32-ld: /home/daniel/ZITI/ziti-tunnel-sdk-c/build/\_deps/ziti-sdk-c-src/library/connect.c:598: undefined reference to `crypto_secretstream_xchacha20poly1305_push' /usr/bin/i686-w64-mingw32-ld: CMakeFiles/ziti_dll.dir/objects.a(connect.c.obj): in function `establish\_crypto’:  
/home/daniel/ZITI/ziti-tunnel-sdk-c/build/\_deps/ziti-sdk-c-src/library/connect.c:692: undefined reference to `crypto_kx_client_session_keys' /usr/bin/i686-w64-mingw32-ld: /home/daniel/ZITI/ziti-tunnel-sdk-c/build/_deps/ziti-sdk-c-src/library/connect.c:694: undefined reference to `crypto\_kx\_server\_session\_keys’  
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/ziti\_dll.dir/objects.a(connect.c.obj): in function `send_crypto_header': /home/daniel/ZITI/ziti-tunnel-sdk-c/build/_deps/ziti-sdk-c-src/library/connect.c:710: undefined reference to `crypto\_secretstream\_xchacha20poly1305\_headerbytes’  
/usr/bin/i686-w64-mingw32-ld: /home/daniel/ZITI/ziti-tunnel-sdk-c/build/\_deps/ziti-sdk-c-src/library/connect.c:714: undefined reference to `crypto_secretstream_xchacha20poly1305_init_push' /usr/bin/i686-w64-mingw32-ld: /home/daniel/ZITI/ziti-tunnel-sdk-c/build/_deps/ziti-sdk-c-src/library/connect.c:716: undefined reference to `crypto\_secretstream\_xchacha20poly1305\_headerbytes’  
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/ziti\_dll.dir/objects.a(connect.c.obj): in function `conn_inbound_data_msg': /home/daniel/ZITI/ziti-tunnel-sdk-c/build/_deps/ziti-sdk-c-src/library/connect.c:823: undefined reference to `crypto\_secretstream\_xchacha20poly1305\_init\_pull’  
/usr/bin/i686-w64-mingw32-ld: /home/daniel/ZITI/ziti-tunnel-sdk-c/build/\_deps/ziti-sdk-c-src/library/connect.c:832: undefined reference to `crypto_secretstream_xchacha20poly1305_pull' /usr/bin/i686-w64-mingw32-ld: CMakeFiles/ziti_dll.dir/objects.a(connect.c.obj): in function `ziti\_channel\_start\_connection’:  
/home/daniel/ZITI/ziti-tunnel-sdk-c/build/\_deps/ziti-sdk-c-src/library/connect.c:1040: undefined reference to `crypto_kx_keypair' /usr/bin/i686-w64-mingw32-ld: CMakeFiles/ziti_dll.dir/objects.a(posture.c.obj): in function `hash\_sha512’:  
/home/daniel/ZITI/ziti-tunnel-sdk-c/build/\_deps/ziti-sdk-c-src/library/posture.c:870: undefined reference to `crypto_hash_sha512_bytes' /usr/bin/i686-w64-mingw32-ld: /home/daniel/ZITI/ziti-tunnel-sdk-c/build/_deps/ziti-sdk-c-src/library/posture.c:886: undefined reference to `crypto\_hash\_sha512\_init’  
/usr/bin/i686-w64-mingw32-ld: /home/daniel/ZITI/ziti-tunnel-sdk-c/build/\_deps/ziti-sdk-c-src/library/posture.c:901: undefined reference to `crypto_hash_sha512_update' /usr/bin/i686-w64-mingw32-ld: /home/daniel/ZITI/ziti-tunnel-sdk-c/build/_deps/ziti-sdk-c-src/library/posture.c:904: undefined reference to `crypto\_hash\_sha512\_final’  
/usr/bin/i686-w64-mingw32-ld: CMakeFiles/ziti\_dll.dir/objects.a(posture.c.obj): in function `check_running': /home/daniel/ZITI/ziti-tunnel-sdk-c/build/_deps/ziti-sdk-c-src/library/posture.c:937: undefined reference to `QueryFullProcessImageNameA’  
collect2: error: ld returned 1 exit status  
make[2]: \*\*\* [\_deps/ziti-sdk-c-build/library/CMakeFiles/ziti\_dll.dir/build.make:417: \_deps/ziti-sdk-c-build/library/ziti.dll] Error 1  
make[1]: \*\*\* [CMakeFiles/Makefile2:1741: \_deps/ziti-sdk-c-build/library/CMakeFiles/ziti\_dll.dir/all] Error 2  
make: \*\*\* [Makefile:171: all] Error 2

thanks

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 19, 2022, 12:04pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/7 "2022-05-19T12:04:44Z")

</div>

I tried using the toolchains file and get a slightly different error

```bash
# install mingw-w64:
sudo apt install mingw-w64

# make/cd the build folder
mkdir build
cd build

# gen the project using cmake and the toolchain file
cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchains/Windows-x86.cmake

# cmake build
cmake --build .

```

Error I see is at

```auto
[69%] Generating zlib1rc.obj
/bin/sh: 1: windres: not found
make[2]: *** [_deps/zlib-build/CMakeFiles/zlib.dir/build.make:62: _deps/zlib-build/zlib1rc.obj] Error 127
make[1]: *** [CMakeFiles/Makefile2:1571: _deps/zlib-build/CMakeFiles/zlib.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

```

@ekoby - can you take a look?

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 19, 2022, 12:14pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/8 "2022-05-19T12:14:58Z")

</div>

Oh and I just noticed I was building the sdk-c not the tunneler-sdk-c - my bad.

---

<div class="post-metadata">

**Author:** ![Danieleb](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@Danieleb](https://openziti.discourse.group/u/Danieleb)\
**Post date:** [May 19, 2022, 12:28pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/9 "2022-05-19T12:28:05Z")

</div>

Thanks Clint, as a side note I have also had to fix following in order to be able to compile, not sure if it is something that needs to get fixed from your side or not:

In file included from /home/daniel/ZITI/ziti-tunnel-sdk-c/build/\_deps/ziti-sdk-c-src/library/ziti-socket.c:33:  
/home/daniel/ZITI/ziti-tunnel-sdk-c/build/\_deps/ziti-sdk-c-src/library/…/includes/ziti/socket.h:31:10: fatal error: WinSock2.h: No such file or directory  
31 | #include \<winSock2.h\>  
| ^ ~~~~~~~~~~~

Edited:  
vi /home/daniel/ZITI/ziti-tunnel-sdk-c/build/\_deps/ziti-sdk-c-src/library/…/includes/ziti/socket.h

Changed:  
#include \<WinSock2.h\>  
to read  
#include \<winsock2.h\>

also have had to copy

cp \_deps/wintun-src/bin/x86/wintun.dll \_deps/wintun-src/bin/

as wintun was missing

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 19, 2022, 12:29pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/10 "2022-05-19T12:29:27Z")

</div>

I can’t replicate the issue you’re seeing @Danieleb . On my Ubuntu 20 install with cmake 3.16.3 i can generate the project fine with:

```auto
cmake -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ WIN32 ..

```

However running just `make` or `cmake --build .` both produce the same error for me:

```auto
ziti-tunneler-sdk-c/build$ make
make: *** No targets specified and no makefile found. Stop.

ziti-tunneler-sdk-c/build$ cmake --build .
make: *** No targets specified and no makefile found. Stop.

```

I ended up being able to build using:

```auto
cmake -DCMAKE_SYSTEM_NAME=Windows --build .

```

I was going to ask you the wintun dll question too 🙂 We only build using a windows build machine in GitHub actions. I don’t know if anyone has tried crosscompiling from Ubuntu for windows yet.

I’ll do what you have tried as well and see if i can get to the same place you’re at

---

<div class="post-metadata">

**Author:** ![ekoby](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/ekoby/32/14_2.png) [@ekoby](https://openziti.discourse.group/u/ekoby)\
**Post date:** [May 19, 2022, 1:33pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/11 "2022-05-19T13:33:48Z")

</div>

I added an issue to ziti-sdk-c: [cross compile from Linux to Win32 fails (using toolchains/Window-x86.cmake) · Issue #390 · openziti/ziti-sdk-c · GitHub](https://github.com/openziti/ziti-sdk-c/issues/390)  
feel free to add additional details

---

<div class="post-metadata">

**Author:** ![Danieleb](https://avatars.discourse-cdn.com/v4/letter/d/9f8e36/32.png) [@Danieleb](https://openziti.discourse.group/u/Danieleb)\
**Post date:** [May 19, 2022, 1:38pm UTC](https://openziti.discourse.group/t/ziti-tunnel-sdk-c-compilation-steps/122/12 "2022-05-19T13:38:46Z")

</div>

Problem manifests while using

Ubuntu 21.0.4 64bit  
cmake version 3.18.4
