Makefile.openbsd
(1) By Vetelko (vetelko) on 2019-04-25 19:52:01
Tested on OpenBSD 6.5 #!/usr/bin/make CC = cc -Os -static TCLLIB = /usr/local/lib/libtcl85.a -lm -lz -lpthread TCLINC = /usr/local/include/tcl8.5 TCLSH = tclsh all: wapptclsh wapptclsh: wapptclsh.c $(CC) -I. -I$(TCLINC) -o $@ wapptclsh.c $(TCLLIB) wapptclsh.c: wapptclsh.c.in wapp.tcl wapptclsh.tcl tclsqlite3.c mkccode.tcl $(TCLSH) mkccode.tcl wapptclsh.c.in >$@ clean: rm wapptclsh wapptclsh.c
(2) By ATK (akoroma) on 2020-09-29 03:17:59 in reply to 1 [link]
I picked up Tcl is compiles with this default parameter --enable-shared=on. For that reason I didn't have a libtcl8.6.a file in my lib directory. When I used libtcl8.6.so it failed to compile wapptclsh and I know it was for obvious reasons. I recompiled Tcl8.6 as follows; $ ./configure --prefix=/export/apps/tcl868 --enable-shared=off --enable-64bit $ make && make install Then tried to compile wapptclsh as follows; xxx@hostname:/export/apps/wapp$ cat Makefile #!/usr/bin/make CC = gcc -Os -static OPTS = -DSQLITE_ENABLE_DESERIALIZE TCLLIB = /export/apps/tcl861/lib/libtcl8.6.a -lm -lz -lpthread -ldl TCLINC = /export/apps/tcl861/include TCLSH = tclsh all: wapptclsh wapptclsh: wapptclsh.c $(CC) -I. -I$(TCLINC) -o $@ $(OPTS) wapptclsh.c $(TCLLIB) wapptclsh.c: wapptclsh.c.in wapp.tcl wapptclsh.tcl tclsqlite3.c mkccode.tcl $(TCLSH) mkccode.tcl wapptclsh.c.in >$@ clean: rm wapptclsh wapptclsh.c xxx@ohstname:/export/apps/wapp$ make gcc -Os -static -I. -I/export/apps/tcl861/include -o wapptclsh -DSQLITE_ENABLE_DESERIALIZE wapptclsh.c /export/apps/tcl861/lib/libtcl8.6.a -lm -lz -lpthread -ldl /export/apps/tcl861/lib/libtcl8.6.a(tclLoadDl.o): In function `TclpDlopen': tclLoadDl.c:(.text+0x1de): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /export/apps/tcl861/lib/libtcl8.6.a(tclUnixCompat.o): In function `TclpGetGrGid': tclUnixCompat.c:(.text+0x41c): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /export/apps/tcl861/lib/libtcl8.6.a(tclUnixCompat.o): In function `TclpGetGrNam': tclUnixCompat.c:(.text+0x31c): warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /export/apps/tcl861/lib/libtcl8.6.a(tclUnixCompat.o): In function `TclpGetPwNam': tclUnixCompat.c:(.text+0x114): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /export/apps/tcl861/lib/libtcl8.6.a(tclUnixCompat.o): In function `TclpGetPwUid': tclUnixCompat.c:(.text+0x214): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /export/apps/tcl861/lib/libtcl8.6.a(tclIOSock.o): In function `TclCreateSocketAddress': tclIOSock.c:(.text+0x2c9): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /export/apps/tcl861/lib/libtcl8.6.a(tclUnixCompat.o): In function `TclpGetHostByAddr': tclUnixCompat.c:(.text+0x593): warning: Using 'gethostbyaddr_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /export/apps/tcl861/lib/libtcl8.6.a(tclUnixCompat.o): In function `TclpGetHostByName': tclUnixCompat.c:(.text+0x4f4): warning: Using 'gethostbyname_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /export/apps/tcl861/lib/libtcl8.6.a(tclIOSock.o): In function `TclSockGetPort': tclIOSock.c:(.text+0x55): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking xxx@hostname:/export/apps/wapp$ ls -la total 31252 drwxr-xr-x 7 bwaan bwaan 4096 Sep 28 17:37 . drwxr-xr-x 21 bwaan bwaan 4096 Sep 24 07:52 .. drwxr-xr-x 2 bwaan bwaan 4096 Sep 22 19:26 docs -rw-r--r-- 1 bwaan bwaan 611 Sep 22 19:26 encode-binary-file.tcl drwxr-xr-x 2 bwaan bwaan 4096 Sep 22 19:26 examples -rw-r--r-- 1 bwaan bwaan 444 Sep 28 17:31 Makefile -rw-r--r-- 1 bwaan bwaan 431 Sep 22 19:26 Makefile.macos -rw-r--r-- 1 bwaan bwaan 432 Sep 23 06:08 Makefile.orig -rwxr-xr-x 1 bwaan bwaan 3002 Sep 22 19:26 mkccode.tcl drwxrwxr-x 2 bwaan bwaan 4096 Sep 23 05:56 proj -rw-r--r-- 1 bwaan bwaan 1528 Sep 22 19:26 README.md -rw-r--r-- 1 bwaan bwaan 8264893 Sep 22 19:26 tclsqlite3.c drwxr-xr-x 2 bwaan bwaan 4096 Sep 22 19:26 tests -rw-r--r-- 1 bwaan bwaan 31464 Sep 22 19:26 wapp.tcl -rwxrwxr-x 1 bwaan bwaan 5009208 Sep 28 17:35 wapptclsh -rw-rw-r-- 1 bwaan bwaan 8303748 Sep 24 08:11 wapptclsh.c -rw-r--r-- 1 bwaan bwaan 1670 Sep 22 19:26 wapptclsh.c.in -rw-r--r-- 1 bwaan bwaan 361 Sep 22 19:26 wapptclsh.tcl It works but my compilation had errors, not sure what i could have missed.
(3) By anonymous on 2022-08-29 13:22:55 in reply to 2 [link]
Those warnings are not errors as such. The same warnings occur under Linux, using gcc with glibc. It is just warning that the static binary does have dependencies. To get a truly static binary without external dependencies, you need a different libc, such as musl libc, which is found on Alpine Linux. This can be most easily used in Linux via an Alpine Docker container. The resulting small and truly static binary can then be run on any Linux system. However, whether something comparable is available on OpenBSD, I do not know.