Skip to content

Commit 43897c4

Browse files
committed
Document linking against libduckdb on macOS and Linux
[skip ci]
1 parent d2d84fa commit 43897c4

File tree

1 file changed

+52
-25
lines changed

1 file changed

+52
-25
lines changed

README.md

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -127,31 +127,58 @@ declarations for DuckDB's C API. By default, `libduckdb-sys` attempts to find a
127127

128128
You can adjust this behavior in a number of ways:
129129

130-
- If you use the `bundled` feature, `libduckdb-sys` will use the
131-
[cc](https://crates.io/crates/cc) crate to compile DuckDB from source and
132-
link against that. This source is embedded in the `libduckdb-sys` crate and
133-
as we are still in development, we will update it regularly. After we are more stable,
134-
we will use the stable released version from [duckdb](https://github.com/duckdb/duckdb/releases).
135-
This is probably the simplest solution to any build problems. You can enable this by adding the following in your `Cargo.toml` file:
136-
137-
```bash
138-
cargo add duckdb --features bundled
139-
```
140-
141-
`Cargo.toml` will be updated.
142-
143-
```toml
144-
[dependencies]
145-
# Assume that version DuckDB version 0.9.2 is used.
146-
duckdb = { version = "0.9.2", features = ["bundled"] }
147-
```
148-
149-
* When linking against a DuckDB library already on the system (so _not_ using any of the `bundled` features), you can set the `DUCKDB_LIB_DIR` environment variable to point to a directory containing the library. You can also set the `DUCKDB_INCLUDE_DIR` variable to point to the directory containing `duckdb.h`.
150-
* Installing the duckdb development packages will usually be all that is required, but
151-
the build helpers for [pkg-config](https://github.com/alexcrichton/pkg-config-rs)
152-
and [vcpkg](https://github.com/mcgoo/vcpkg-rs) have some additional configuration
153-
options. The default when using vcpkg is to dynamically link,
154-
which must be enabled by setting `VCPKGRS_DYNAMIC=1` environment variable before build.
130+
1. If you use the `bundled` feature, `libduckdb-sys` will use the
131+
[cc](https://crates.io/crates/cc) crate to compile DuckDB from source and
132+
link against that. This source is embedded in the `libduckdb-sys` crate and
133+
as we are still in development, we will update it regularly. After we are more stable,
134+
we will use the stable released version from [duckdb](https://github.com/duckdb/duckdb/releases).
135+
This is probably the simplest solution to any build problems. You can enable this by adding the following in your `Cargo.toml` file:
136+
137+
```bash
138+
cargo add duckdb --features bundled
139+
```
140+
141+
`Cargo.toml` will be updated.
142+
143+
```toml
144+
[dependencies]
145+
# Assume that version DuckDB version 0.9.2 is used.
146+
duckdb = { version = "0.9.2", features = ["bundled"] }
147+
```
148+
149+
2. When linking against a DuckDB library already on the system (so _not_ using any of the `bundled` features), you can set the `DUCKDB_LIB_DIR` environment variable to point to a directory containing the library. You can also set the `DUCKDB_INCLUDE_DIR` variable to point to the directory containing `duckdb.h`.
150+
151+
Linux example:
152+
153+
```shell
154+
wget https://github.com/duckdb/duckdb/releases/download/v1.3.2/libduckdb-linux-arm64.zip
155+
unzip libduckdb-linux-arm64.zip -d libduckdb
156+
157+
export DUCKDB_LIB_DIR=$PWD/libduckdb
158+
export DUCKDB_INCLUDE_DIR=$DUCKDB_LIB_DIR
159+
export LD_LIBRARY_PATH=$DUCKDB_LIB_DIR
160+
161+
cargo build --examples
162+
```
163+
164+
macOS example:
165+
166+
```shell
167+
wget https://github.com/duckdb/duckdb/releases/download/v1.3.2/libduckdb-osx-universal.zip
168+
unzip libduckdb-osx-universal.zip -d libduckdb
169+
170+
export DUCKDB_LIB_DIR=$PWD/libduckdb
171+
export DUCKDB_INCLUDE_DIR=$DUCKDB_LIB_DIR
172+
export DYLD_FALLBACK_LIBRARY_PATH=$DUCKDB_LIB_DIR
173+
174+
cargo build --examples
175+
```
176+
177+
3. Installing the duckdb development packages will usually be all that is required, but
178+
the build helpers for [pkg-config](https://github.com/alexcrichton/pkg-config-rs)
179+
and [vcpkg](https://github.com/mcgoo/vcpkg-rs) have some additional configuration
180+
options. The default when using vcpkg is to dynamically link,
181+
which must be enabled by setting `VCPKGRS_DYNAMIC=1` environment variable before build.
155182

156183
### Binding generation
157184

0 commit comments

Comments
 (0)