Skip to content

Commit a6fd0c9

Browse files
committed
fix(Makefile): use platform-specific LDLIBS for system libraries
Move -ldl -lm to LDLIBS variable set per-platform: - Linux/Darwin: -ldl -lm (dynamic loading and math) - Windows: empty (Win32 API for dyn load, math linked by default) This fixes the Windows CI build which failed with "cannot find -ldl".
1 parent ce73744 commit a6fd0c9

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,19 @@ LOADABLE_EXTENSION=dylib
3232
# Let unresolved SQLite symbols resolve against host at load time
3333
# This is standard for SQLite loadable extensions on macOS.
3434
CFLAGS += -undefined dynamic_lookup
35+
# System libraries for linking (libdl for dynamic loading, libm for math)
36+
LDLIBS += -ldl -lm
3537
endif
3638

3739
ifdef CONFIG_LINUX
3840
LOADABLE_EXTENSION=so
39-
LDLIBS += -lm
41+
# System libraries for linking (libdl for dynamic loading, libm for math)
42+
LDLIBS += -ldl -lm
4043
endif
4144

4245
ifdef CONFIG_WINDOWS
4346
LOADABLE_EXTENSION=dll
47+
# Windows doesn't need -ldl (uses Win32 API) and math is linked by default
4448
endif
4549

4650

@@ -161,7 +165,7 @@ $(TARGET_CLI): sqlite-vec.h $(LIBS_DIR)/sqlite-vec.a $(LIBS_DIR)/shell.a $(LIBS_
161165
$(CFLAGS) $(EXT_CFLAGS) \
162166
$(EXT_LDFLAGS) \
163167
examples/sqlite3-cli/core_init.c $(LIBS_DIR)/shell.a $(LIBS_DIR)/sqlite3.a $(LIBS_DIR)/sqlite-vec.a -o $@ \
164-
-ldl -lm
168+
$(LDLIBS)
165169

166170

167171
sqlite-vec.h: sqlite-vec.h.tmpl VERSION
@@ -251,7 +255,7 @@ $(prefix)/memory-test: tests/memory-test.c sqlite-vec.c vendor/sqlite3.c | $(pre
251255
-DSQLITE_THREADSAFE=0 \
252256
$(CFLAGS) $(EXT_CFLAGS) \
253257
tests/memory-test.c sqlite-vec.c vendor/sqlite3.c -o $@ \
254-
$(EXT_LDFLAGS) -ldl -lm
258+
$(EXT_LDFLAGS) $(LDLIBS)
255259

256260
# Run valgrind memory leak tests
257261
test-valgrind: $(prefix)/memory-test

0 commit comments

Comments
 (0)