Skip to content

Commit 51bd39e

Browse files
quaesitor-scientiamPythonWillRuleclaude
authored
db.sqlite: fix thirdparty amalgamation not found on Linux (#26724)
* db.sqlite: fix thirdparty amalgamation not found on Linux Make the thirdparty sqlite include path apply on all platforms, not just Windows. On Linux, use pkg-config when the system library is available, otherwise fall back to compiling the thirdparty amalgamation. Update docs to reflect cross-platform support. Closes #26723 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * db.sqlite: preserve -lsqlite3 fallback for systems without pkg-config Keep the original -lsqlite3 fallback when pkg-config metadata is missing, so environments with SQLite installed but no sqlite3.pc file (e.g. default macOS SDK, some Linux/BSD setups) continue to work without requiring the thirdparty amalgamation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * db.sqlite: prefer system sqlite via pkgconfig before thirdparty fallback Restructure the flag chain so pkgconfig is checked first, then Windows thirdparty, then -lsqlite3 fallback. This ensures the system install is preferred when available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Richard Wheeler <18647491+PythonWillRule@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e2a5e2e commit 51bd39e

3 files changed

Lines changed: 31 additions & 20 deletions

File tree

doc/docs.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5622,9 +5622,22 @@ sql db {
56225622

56235623
For more examples and the docs, see [vlib/orm](https://github.com/vlang/v/tree/master/vlib/orm).
56245624

5625-
### Troubleshooting compilation problems with SQLite on Windows
5626-
On Windows, if you get a compilation error, about a missing sqlite3.h file, you have to run:
5627-
`v vlib/db/sqlite/install_thirdparty_sqlite.vsh` once, then retry your compilation.
5625+
### Troubleshooting compilation problems with SQLite
5626+
5627+
On **any platform** (Windows, Linux, macOS), you can run:
5628+
5629+
`v vlib/db/sqlite/install_thirdparty_sqlite.vsh`
5630+
5631+
This downloads the SQLite amalgamation source and places it in
5632+
`v/thirdparty/sqlite`. V will then compile it automatically
5633+
during your build.
5634+
5635+
On **Linux**, you can also install the system development package
5636+
instead:
5637+
5638+
- Debian/Ubuntu: `sudo apt install -y libsqlite3-dev`
5639+
- Fedora/RHEL: `sudo dnf -y install sqlite-devel`
5640+
- Arch: `sudo pacman -S sqlite`
56285641

56295642
### Using the self contained SQLite module
56305643
V also maintains a separate `sqlite` module, that wraps an SQLite amalgamation, but otherwise

vlib/db/sqlite/README.md

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,20 @@ high-reliability, full-featured, SQL database engine."
66

77
# Install SQLite Dependency
88

9-
Before you can use this module, you must first have the SQLite development
10-
library installed on your system.
9+
On **any platform** (Windows, Linux, macOS), you can run:
1110

12-
**Fedora 31**:
11+
`v vlib/db/sqlite/install_thirdparty_sqlite.vsh`
1312

14-
`sudo dnf -y install sqlite-devel`
13+
This downloads the SQLite amalgamation source and places it in
14+
`v/thirdparty/sqlite`. V will then compile it automatically
15+
during your build.
1516

17+
On **Linux**, you can also install the system development package
18+
instead:
1619

17-
**Ubuntu 20.04**:
18-
19-
`sudo apt install -y libsqlite3-dev`
20-
21-
22-
**Windows**:
23-
- Download the source zip from [SQLite Downloads](https://sqlite.org/download.html)
24-
- Create a new `sqlite` subfolder inside `v/thirdparty`
25-
- Extract the zip into that folder
20+
- Debian/Ubuntu: `sudo apt install -y libsqlite3-dev`
21+
- Fedora/RHEL: `sudo dnf -y install sqlite-devel`
22+
- Arch: `sudo pacman -S sqlite`
2623

2724
# Performance Tips
2825

vlib/db/sqlite/sqlite.c.v

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ $if freebsd || openbsd {
44
#flag -I/usr/local/include
55
#flag -L/usr/local/lib
66
}
7-
$if windows {
8-
#flag windows -I@VEXEROOT/thirdparty/sqlite
7+
#flag -I@VEXEROOT/thirdparty/sqlite
8+
$if $pkgconfig('sqlite3') {
9+
#pkgconfig sqlite3
10+
} $else $if windows {
911
#flag windows -L@VEXEROOT/thirdparty/sqlite
1012
#flag windows @VEXEROOT/thirdparty/sqlite/sqlite3.o
11-
#include "sqlite3.h" # The SQLite header file is missing. Please run vlib/db/sqlite/install_thirdparty_sqlite.vsh to download an SQLite amalgamation.
1213
} $else {
1314
#flag -lsqlite3
14-
#include "sqlite3.h" # The SQLite header file is missing. Please install its development package first.
1515
}
16+
#include "sqlite3.h" # The SQLite header file is missing. Please run vlib/db/sqlite/install_thirdparty_sqlite.vsh to download an SQLite amalgamation, or install its development package.
1617

1718
// https://www.sqlite.org/rescode.html
1819
pub const sqlite_ok = 0

0 commit comments

Comments
 (0)