Skip to content

Commit 803459f

Browse files
authored
Document linking against libduckdb on macOS and Linux (#563)
refs #538 refs #461
2 parents d2d84fa + 8e50096 commit 803459f

File tree

1 file changed

+51
-25
lines changed

1 file changed

+51
-25
lines changed

README.md

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -127,31 +127,57 @@ 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+
duckdb = { version = "1.3.2", features = ["bundled"] }
146+
```
147+
148+
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`.
149+
150+
Linux example:
151+
152+
```shell
153+
wget https://github.com/duckdb/duckdb/releases/download/v1.3.2/libduckdb-linux-arm64.zip
154+
unzip libduckdb-linux-arm64.zip -d libduckdb
155+
156+
export DUCKDB_LIB_DIR=$PWD/libduckdb
157+
export DUCKDB_INCLUDE_DIR=$DUCKDB_LIB_DIR
158+
export LD_LIBRARY_PATH=$DUCKDB_LIB_DIR
159+
160+
cargo build --examples
161+
```
162+
163+
macOS example:
164+
165+
```shell
166+
wget https://github.com/duckdb/duckdb/releases/download/v1.3.2/libduckdb-osx-universal.zip
167+
unzip libduckdb-osx-universal.zip -d libduckdb
168+
169+
export DUCKDB_LIB_DIR=$PWD/libduckdb
170+
export DUCKDB_INCLUDE_DIR=$DUCKDB_LIB_DIR
171+
export DYLD_FALLBACK_LIBRARY_PATH=$DUCKDB_LIB_DIR
172+
173+
cargo build --examples
174+
```
175+
176+
3. Installing the duckdb development packages will usually be all that is required, but
177+
the build helpers for [pkg-config](https://github.com/alexcrichton/pkg-config-rs)
178+
and [vcpkg](https://github.com/mcgoo/vcpkg-rs) have some additional configuration
179+
options. The default when using vcpkg is to dynamically link,
180+
which must be enabled by setting `VCPKGRS_DYNAMIC=1` environment variable before build.
155181

156182
### Binding generation
157183

0 commit comments

Comments
 (0)