openziti / ziti-openwrt

Ziti package feed for OpenWRT
Apache License 2.0
3 stars 0 forks source link

Compilation issue #2

Closed dovholuknf closed 3 years ago

dovholuknf commented 3 years ago

User reports:

I am trying to cross compile https://github.com/openziti/ziti-tunnel-sdk-c/ against openwrt toolchain provided by Teltonika RUT SDK https://wiki.teltonika-networks.com/view/Software_Development_Kit. We got the steps to cross-compile from ticket https://openziti.discourse.group/t/ziti-tunnel-sdk-c-cmake-install-failure/118 I was able to compile previously with older version of ziti tunnel (v.0.8.6) but now i need to use latest version (v0.16.2). Post compilation i am getting the following error.

[100%] Linking C executable ziti-edge-tunnel mips-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined mips-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined CMakeFiles/ziti-edge-tunnel.dir/netif_driver/linux/tun.c.o: In function run_command_va': /home/username/ziti-tunnel-sdk-c/programs/ziti-edge-tunnel/netif_driver/linux/tun.c:94: undefined reference toWEXITSTATUS' collect2: error: ld returned 1 exit status programs/ziti-edge-tunnel/CMakeFiles/ziti-edge-tunnel.dir/build.make:146: recipe for target 'programs/ziti-edge-tunnel/ziti-edge-tunnel' failed make[2]: [programs/ziti-edge-tunnel/ziti-edge-tunnel] Error 1 CMakeFiles/Makefile2:1793: recipe for target 'programs/ziti-edge-tunnel/CMakeFiles/ziti-edge-tunnel.dir/all' failed make[1]: [programs/ziti-edge-tunnel/CMakeFiles/ziti-edge-tunnel.dir/all] Error 2 Makefile:170: recipe for target 'all' failed make: *** [all] Error 2

export TOOLCHAIN=~/RUT2XX_R_GPL_00.01.14/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/

Also could you tell me, what should be configured for STAGING_DIR. If it is effecting the outcome of the above cross-compile.

sameersarkar-tcl commented 3 years ago

Hi Team, I could fix the above error by doing below steps Open ziti-tunnel-sdk-c/programs/ziti-edge-tunnel/netif_driver/linux/tun.c Add #included <sys/wait.h> execute "make clean" and "make" again.

But now thou the binary gets created, it isn't executing on openwrt env.

root@Teltonika-RUT240:/etc/ziti# mv /tmp/ziti-edge-tunnel_14SDK_v0.16.2 /tmp/ziti-edge-tunnel root@Teltonika-RUT240:/etc/ziti# chmod +x /tmp/ziti-edge-tunnel root@Teltonika-RUT240:/etc/ziti# /etc/init.d/ziti start ziti: enrollment /etc/ziti/id.json exists ziti: adding interface trigger wan root@Teltonika-RUT240:/etc/ziti# root@Teltonika-RUT240:/etc/ziti# root@Teltonika-RUT240:/etc/ziti# ps | grep ziti 27318 root 1520 S grep ziti root@Teltonika-RUT240:/etc/ziti# root@Teltonika-RUT240:/etc/ziti# ls -ltr -rw-r--r-- 1 root root 551 Apr 23 11:48 demo_rut240_endpoint_3.jwt -rw-r--r-- 1 root root 6153 Apr 23 11:49 id.json -rw-r--r-- 1 root root 4455 Apr 23 11:50 ca.jwt -rw-r--r-- 1 root root 1377 Apr 23 11:50 id.crt -rw-r--r-- 1 root root 233 Apr 23 11:51 id.key

I need urgent help on it

scareything commented 3 years ago

Hello,

Thanks for sharing what you've done to fix the build! We will incorporate that into the next release.

Regarding the failure to start; there is a chance that the issue could be with the init.d script rather than the ziti-edge-tunnel binary. Could you please:

  1. Share your /etc/init.d/ziti script here?
  2. d\Does your init.d script capture the ziti-edge-tunnel output in a log file? If so could you share that log here? If not, could you run ziti-edge-tunnel directly and share the output here?

Thanks, -Shawn

sameersarkar-tcl commented 3 years ago

Hi Shawn, I have used the init script which is mentioned here https://github.com/openziti/ziti-tunnel-sdk-c/blob/main/docs/openwrt/ziti.init. The content is copy paste of the same. Using this script i couldn't get where it creates a log file. Please share the path. Using this init script i use the command "/etc/init.d/ziti start" to start and "/etc/init.d/ziti stop" to stop the tunnel.

Regards, Sameer Sarkar

scareything commented 3 years ago

Hi Sameer.

Thanks for pointing me to the script that you are using. Apparently the script was not updated when the ziti-edge-tunnel command line options were changed recently. I think the offending line in the init script is this:

procd_append_param command -c ${idfile}

Could you edit the script so the line above uses -i instead of -c?

Thanks, -Shawn

sameersarkar-tcl commented 3 years ago

Hi Shawn, Thanks for suggesting the change. I was about to message back the same. When you suggested the idea of running the binary directly, then i realized about starting the tunnel in such way. And i observed that new binary requires -i option rather than -c.

I believe now you have to fix this change in https://github.com/openziti/ziti-tunnel-sdk-c/blob/main/docs/openwrt/ziti.init in github.

Thank you, Sameer Sarkar

sameersarkar-tcl commented 3 years ago

Hi Shawn, Please close this ticket. Thanks Sameer Sarkar

scareything commented 3 years ago

Thanks Sameer! I'll get the changes that we discussed here into the next release!