Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to link libduckdb statically #618

Merged
merged 4 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ else
DUCKDB_BUILD_TYPE = release
endif

DUCKDB_LIB = libduckdb$(DLSUFFIX)
DUCKDB_STATIC ?= 0
PG_DUCKDB_LINK_FLAGS = -Wl,-rpath,$(PG_LIB)/ -lpq -Lthird_party/duckdb/build/$(DUCKDB_BUILD_TYPE)/src -L$(PG_LIB) -lstdc++ -llz4
ifeq ($(DUCKDB_STATIC), 1)
DUCKDB_LIB = libduckdb_static.a
PG_DUCKDB_LINK_FLAGS += -l:$(DUCKDB_LIB)
else
DUCKDB_LIB = libduckdb$(DLSUFFIX)
PG_DUCKDB_LINK_FLAGS += -lduckdb
endif

FULL_DUCKDB_LIB = third_party/duckdb/build/$(DUCKDB_BUILD_TYPE)/src/$(DUCKDB_LIB)

ERROR_ON_WARNING ?=
Expand All @@ -54,7 +63,7 @@ override PG_CXXFLAGS += -std=c++17 ${DUCKDB_BUILD_CXX_FLAGS} ${COMPILER_FLAGS} -
# changes to the vendored code in one place.
override PG_CFLAGS += -Wno-declaration-after-statement

SHLIB_LINK += -Wl,-rpath,$(PG_LIB)/ -lpq -Lthird_party/duckdb/build/$(DUCKDB_BUILD_TYPE)/src -L$(PG_LIB) -lduckdb -lstdc++ -llz4
SHLIB_LINK += $(PG_DUCKDB_LINK_FLAGS)

include Makefile.global

Expand Down
2 changes: 2 additions & 0 deletions docs/compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ To build and install, run:
make install
```

If you want to link `libduckdb` statically, set `DUCKDB_STATIC=1` when interacting with `make(1)`.

Add `pg_duckdb` to the `shared_preload_libraries` in your `postgresql.conf` file:

```ini
Expand Down