Suckless ST failed
I cloned the Suckless st repo with git clone git://git.suckless.org/st and changed directory to st. (For me $HOME/workspace/st. I made the customary changes to config.mk needed for NetBSD.
$ cat config.mk [18:35:26]
# st version
VERSION = 0.9.3
# Customize below to fit your system
# paths
PREFIX = /usr/pkg
MANPREFIX = $(PREFIX)/share/man
X11INC = /usr/X11R7/include
X11LIB = /usr/X11R7/lib
PKG_CONFIG = pkg-config
# includes and libs
INCS = -I$(X11INC) \
`$(PKG_CONFIG) --cflags fontconfig` \
`$(PKG_CONFIG) --cflags freetype2`
LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
`$(PKG_CONFIG) --libs fontconfig` \
`$(PKG_CONFIG) --libs freetype2`
# flags
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
STLDFLAGS = $(LIBS) $(LDFLAGS)
# OpenBSD:
#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
# `$(PKG_CONFIG) --libs fontconfig` \
# `$(PKG_CONFIG) --libs freetype2`
MANPREFIX = ${PREFIX}/man
LIBS += -R${X11LIB}
# compiler and linker
# CC = c99
Here is the git diff for some context:
$ git diff config.mk [18:35:29]
diff --git a/config.mk b/config.mk
index 2fc854e..4e11ee9 100644
--- a/config.mk
+++ b/config.mk
@@ -4,11 +4,11 @@ VERSION = 0.9.3
# Customize below to fit your system
# paths
-PREFIX = /usr/local
+PREFIX = /usr/pkg
MANPREFIX = $(PREFIX)/share/man
-X11INC = /usr/X11R6/include
-X11LIB = /usr/X11R6/lib
+X11INC = /usr/X11R7/include
+X11LIB = /usr/X11R7/lib
PKG_CONFIG = pkg-config
@@ -30,7 +30,8 @@ STLDFLAGS = $(LIBS) $(LDFLAGS)
#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
# `$(PKG_CONFIG) --libs fontconfig` \
# `$(PKG_CONFIG) --libs freetype2`
-#MANPREFIX = ${PREFIX}/man
+MANPREFIX = ${PREFIX}/man
+LIBS += -R${X11LIB}
# compiler and linker
# CC = c99
Adding the fix
Did some digging and found a solution on Redit. Adding this LIBS += -R${X11LIB} did the trick. Now doas make install works.
$ ldd st [18:52:07]
st:
-lm.0 => /usr/lib/libm.so.0
-lc.12 => /usr/lib/libc.so.12
-lrt.1 => /usr/lib/librt.so.1
-lX11.7 => /usr/X11R7/lib/libX11.so.7
-lxcb.2 => /usr/X11R7/lib/libxcb.so.2
-lXau.7 => /usr/X11R7/lib/libXau.so.7
-lXdmcp.7 => /usr/X11R7/lib/libXdmcp.so.7
-lgcc_s.1 => /usr/lib/libgcc_s.so.1
-lutil.7 => /usr/lib/libutil.so.7
-lXft.3 => /usr/X11R7/lib/libXft.so.3
-lfontconfig.2 => /usr/X11R7/lib/libfontconfig.so.2
-lexpat.2 => /usr/lib/libexpat.so.2
-lfreetype.19 => /usr/X11R7/lib/libfreetype.so.19
-lz.1 => /usr/lib/libz.so.1
-lbz2.1 => /usr/lib/libbz2.so.1
-lXrandr.3 => /usr/X11R7/lib/libXrandr.so.3
-lXrender.2 => /usr/X11R7/lib/libXrender.so.2
-lXext.7 => /usr/X11R7/lib/libXext.so.7
Another solution
Another solution was to create a /etc/ld.so.conf file and add /usr/X11R7/lib to the file. If you omit the LIBS += -R${X11LIB} and add this file, compile and run also works.
$ cat /etc/ld.so.conf [18:54:12]
# This is here because after compiling st, launching st fails to
# find a shared lib file. Shared object "libX11.so.7" not found
/usr/X11R7/lib
I am not sure if adding /etc/ld.so.conf to /etc will affect anything else, so I commented out the last line.