Git Product home page Git Product logo

sqlite-amalgamation's Introduction

sqlite-amalgamation

This repository mirrors the SQLite amalgamation, which is the recommended method of building SQLite into larger projects. It also supports cmake for building, installing and exporting.

SQLite includes more than 100 files in *.c / *.h, but

The amalgamation contains everything you need to integrate SQLite into a larger project. Just copy the amalgamation into your source directory and compile it along with the other C code files in your project. (A more detailed discussion of the compilation process is available.) You may also want to make use of the "sqlite3.h" header file that defines the programming API for SQLite. The sqlite3.h header file is available separately. The sqlite3.h file is also contained within the amalgamation, in the first few thousand lines. So if you have a copy of sqlite3.c but cannot seem to locate sqlite3.h, you can always regenerate the sqlite3.h by copying and pasting from the amalgamation.

SQLite3

build / install

A static lib (libsqlite3) and the sqlite3 shell will be generated by the build system.

$> mkdir .build
$> cd .build
$> cmake /path/to/this/repo  # or cmake .. -G Ninja
$> ccmake .                  # for build options or cmake-gui .
$> make -j 2                 # or ninja

$> make install

usage

to integrate this library into your project simply add these lines to your project cmake:

find_package(SQLite3 REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} SQLite::SQLite3)

the include directory and link library will be automatically added to your target. If you need to switch your project to use "standard" SQLite remove CONFIG option in find_package function call.

SQLite3 build options

SQLite3 comes with plenty of compile options

following cmake build options control some of those compile options:

options default
SQLITE_ENABLE_COLUMN_METADATA off
SQLITE_ENABLE_DBSTAT_VTAB off
SQLITE_ENABLE_FTS3 off
SQLITE_ENABLE_FTS4 off
SQLITE_ENABLE_FTS5 off
SQLITE_ENABLE_GEOPOLY off
SQLITE_ENABLE_ICU off
SQLITE_ENABLE_MATH_FUNCTIONS on
SQLITE_ENABLE_RBU off
SQLITE_ENABLE_RTREE off
SQLITE_ENABLE_STAT4 off
SQLITE_OMIT_DECLTYPE on
SQLITE_OMIT_JSON off
SQLITE_USE_URI off

these recommended compile options are also passed to the compiler by SQLITE_RECOMMENDED_OPTIONS (on by default):

options
SQLITE_DEFAULT_MEMSTATUS = 0
SQLITE_DEFAULT_WAL_SYNCHRONOUS = 1
SQLITE_DQS = 0
SQLITE_LIKE_DOESNT_MATCH_BLOBS
SQLITE_MAX_EXPR_DEPTH = 0
SQLITE_OMIT_DECLTYPE
SQLITE_OMIT_DEPRECATED
SQLITE_OMIT_PROGRESS_CALLBACK
SQLITE_OMIT_SHARED_CACHE
SQLITE_USE_ALLOCA

all compile-time options will go into sqlite3_config.h, you may use this file to check these options when building your application.

the SQLite3 shell (executable) is disabled by default, to build it just activate the BUILD_SHELL option.

sqlite-amalgamation's People

Contributors

azadkuh avatar integrallee avatar jschueller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sqlite-amalgamation's Issues

sqlite-almagamation with embedded python3

This is more a question than an issue.

Python3 can be embedded in a C/C++ code and so forth can execute python3 code which use sqlite3.

In case we have a C/C++ code using SQLite3-almagamation and at the same time we have python3 calling SQLite via the shared library is the code safe ?

In other words don't we have a risk of conflict between the 2 same code ?

cl : Command line warning D9025 : overriding '/MDd' with '/MTd'

Hi,

when using your cmake there is a problem with Debug version

Following command

cmake .. -G %Platform% -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=%LIB_DEST%

caused that this C_FLAGS are generated (flags.make file)

# CMAKE generated file: DO NOT EDIT!
# Generated by "NMake Makefiles" Generator, CMake Version 3.7

# compile C with C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/cl.exe
C_FLAGS = /DWIN32 /D_WINDOWS /W3 /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1 -MTd  
C_DEFINES = 
C_INCLUDES = 

As you can see, there is /MDd together with -MTd. This is problem only with Debug, release is correctly configured to use only one flag.

shell_app build error in ubuntu20

[cmake] -- sqlite-amalgamation-3.38.2 configure success
[cmake] [1/5] Building C object CMakeFiles/shell_app.dir/shell.c.o
[cmake] [2/5] Building C object CMakeFiles/SQLite3.dir/sqlite3.c.o
[cmake] [3/5] Linking C static library libsqlite3.a
[cmake] [4/5] Linking C executable sqlite3
[cmake] FAILED: sqlite3
[cmake] : && /usr/bin/cc -O3 -DNDEBUG CMakeFiles/shell_app.dir/shell.c.o -o sqlite3 libsqlite3.a -lpthread -ldl && cd /home/ubuntu/Documents/sqlite-amalgamation-3.38.2/build && /usr/bin/strip sqlite3
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o): in function logFunc': [cmake] sqlite3.c:(.text+0x196ed): undefined reference to log'
[cmake] /usr/bin/ld: sqlite3.c:(.text+0x1971d): undefined reference to log' [cmake] /usr/bin/ld: sqlite3.c:(.text+0x19781): undefined reference to log'
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1370): undefined reference to trunc' [cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1520): undefined reference to exp'
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1568): undefined reference to pow' [cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x15b0): undefined reference to pow'
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x15f8): undefined reference to fmod' [cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1640): undefined reference to acos'
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1688): undefined reference to asin' [cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x16d0): undefined reference to atan'
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1718): undefined reference to atan2' [cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1760): undefined reference to cos'
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x17a8): undefined reference to sin' [cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x17f0): undefined reference to tan'
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1838): undefined reference to cosh' [cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1880): undefined reference to sinh'
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x18c8): undefined reference to tanh' [cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1910): undefined reference to acosh'
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x1958): undefined reference to asinh' [cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x19a0): undefined reference to atanh'
[cmake] /usr/bin/ld: libsqlite3.a(sqlite3.c.o):(.data.rel+0x19e8): undefined reference to `sqrt'
[cmake] collect2: error: ld returned 1 exit status
[cmake] ninja: build stopped: subcommand failed.
[cmake] -- Configuring incomplete, errors occurred!

fd4f85218e7c46289d38d6fc154fe0d6

need add -lm in target_link_libraries function.
if(UNIX)
target_link_libraries(shell_app PRIVATE -lm)
endif()

"Could NOT find SQLite3" error when building project depending on sqlite

Hi Amir,

First of all thank you for your project, it's great to be able to use sqlite as a regular CMake project.

However, I had problems using it. I hope you are able to answer my few questions, as it could be useful for others.

I have built and installed the sqlite-amalgamation project.

To integrate the sqlite3 library to my project, I have used the way recommended in https://github.com/azadkuh/sqlite-amalgamation/blob/master/README.md:

find_package(Sqlite3)
target_link_libraries(myProjectName sqlite3::sqlite3)

Unfortunately, I have an error message when trying to build my project with cmake:

-- Could NOT find SQLite3 (missing: SQLite3_INCLUDE_DIR SQLite3_LIBRARY)

I am using CMake 3.15.4. I have seen that it contains a share\cmake-3.15\Modules\FindSQLite3.cmake file.

Is your project intended to be found with it?

I supposed those two variables SQLite3_INCLUDE_DIR and SQLite3_LIBRARY are hints for CMake's find_package to find the include dir and library file. If so, it should be mentionned in the README.md that the user needs to pass those to cmake.

Another question, why do I have to provide the sqlite library file path ? Wouldn't I have to provide the library directory instead?

Last question, once I have provided both, I have to do #include sqlite3.h instead of #include sqlite3/sqlite3.h. Is it normal?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.