Static binary¶
A static binary does not need any library on the target system, so you can build it once and copy it to a minimal system, a container or a device without a package manager.
With the system compiler¶
make ENDFLAG=-static
This needs the static C library (on Debian and Ubuntu it is in libc6-dev, on other systems look for glibc-static). Check the result:
file build/uFTP # ... statically linked
ldd build/uFTP # not a dynamic executable
With musl¶
musl gives smaller and more portable static binaries. Install musl-gcc from your distribution, or build a cross compiler with
musl-cross-make for another architecture (for example ARM), then:
make CC=musl-gcc ENDFLAG=-static
# for another architecture, use the compiler of the cross toolchain, for example:
make CC=arm-linux-musleabihf-gcc ENDFLAG=-static
TLS¶
A static binary with TLS needs the static OpenSSL libraries (libssl.a, libcrypto.a) built for the same compiler. Without them, build without TLS:
the server works as a plain FTP server.
Copy the binary and uftpd.cfg to the target, and start it as described in Installation.