# 2023-10-15 I've been hacking on klib (renamed to scsl), getting packaging working, and getting my desktop switched over to Ubuntu. ## Debugging a build failure I went through a whole adventure where I thought my C++ setup on the desktop was broken. I was trying to build kutils from the Makefile, and linking kept failing due to not being able to find symbols. It worked when I built it under CLion / cmake, so it was kind of strange. The Makefile specifically builds using clang, so I went through a bunch of trying to track down library depdencies, tooling, etc. I probably spent a few hours trying to figure it out. Finally, I cloned it on the macbook, and ran into the same errors. The difference this time was noticing the following: kyle@midgard:~/src/kutil$ make clang++ -c -o KeyValueConfig.o -std=c++17 -g -Werror -Wall -Wextra -pedantic KeyValueConfig.cc clang++ -c -o khmgr.o -std=c++17 -g -Werror -Wall -Wextra -pedantic khmgr.cc clang++ -c -o StringUtil.o -std=c++17 -g -Werror -Wall -Wextra -pedantic StringUtil.cc cc khmgr.o -o khmgr /usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x23 khmgr.o: in function`KeyValueConfig::Load(std::__cxx11::basic_string, std::allocator >)': khmgr.cc:(.text+0x27): undefined reference to >`std::basic_ifstream >::basic_ifstream(std::__cxx11::basic_string, std::allocator > const&, std::_Ios_Openmode)' /usr/bin/ld: khmgr.cc:(.text+0x3f): undefined reference to / `std::basic_ios >::good() const' /usr/bin/ld: khmgr.cc:(.text+0x8e): undefined reference to / `std::basic_ifstream / >::~basic_ifstream()' The output followed for many pages. The Makefile looks like this: CXX := clang++ SOURCES := $(wildcard *.cc) HEADERS := $(wildcard *.h) OBJS := $(patsubst %.cc,%.o,$(SOURCES)) TARGETS := khmgr CXXFLAGS := -std=c++17 -g CXXFLAGS += -Werror -Wall -Wextra -pedantic all: $(OBJS) $(TARGETS) .PHONY: clean: rm -f *.o $(TARGET) tags: $(SOURCES) ctags -o $@ $(SOURCES) $(TARGET): khmgr.o KeyValue.o StringUtil.o $(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) print-%: ; @echo '$(subst ','\'',$*=$($*))' %.o:%.cc $(CXX) -c -o $@ $(CXXFLAGS) $< Do you spot the error? It took me an embarassingly long time to notice the transition from clang++ to cc, even though the TARGET spec specifically uses clang. I'd defined TARGETS and then made a build rule for TARGET. Once I renamed TARGETS to TARGET, it built just fine.