Add SQLiteCpp to wrapdb
https://github.com/mesonbuild/meson https://github.com/mesonbuild/meson/wiki
https://github.com/mesonbuild/meson/wiki/Adding%20new%20projects%20to%20wrapdb
http://wrapdb.mesonbuild.com/
Meson simplifies the entire build process for us, it would be great if SQLiteCpp is available there. Sqlite is already present in wrapdb, so you could probably use it as dependency. You are also not required to migrate from cmake to meson since it allows patching original sources with custom meson build file.
This seems like a good idea, but I am now lacking the time to do this, so no promise.
You don't even need to build your whole project and replicate every CMake property here to allow inclusion into other projects through meson. Also I'll be happy to help along the way :smile:
@SRombauts I've some free time across this week so I'm thinking to take a shot at this. Let's forget about tests for now and focus primarily on building this lib successfully.
I see 3 directories of interest here - src & sqlite3 & include/SQLiteCpp. If I take all *.cpp files from source and all *.h files from include and the sqlite3.c + sqlite3.h from sqlite3 directory, is that all which is required for building this project?
and ofcourse the system sqlite3 dependency.
Yes, that's it. Thanks
I have another question for you, in the original sources of sqlite, like this - https://www.sqlite.org/2016/sqlite-amalgamation-3140200.zip , there are two extra files apart from sqlite3.c and sqlite3.h, which are - shell.c and sqlite3ext.h. These two files aren't included inside this repo, can I assume neither are needed?
Also 3140200 is shown as latest version, so I've two options, either upload the newest version as well as the one you're including to meson lib-database (allows other projects to share dependencies) or I could use the one you pack with this repo. Which one do you recommend?
I've managed to almost build the whole project + gtest tests. However there is some kind of linker error occurring just after compilation of all units -
SQLiteCpp master ア mkdir build && cd build && meson ..
The Meson build system
Version: 0.33.0
Source dir: /home/agauniyal/projects/SQLiteCpp
Build dir: /home/agauniyal/projects/SQLiteCpp/build
Build type: native build
Build machine cpu family: x86_64
Build machine cpu: x86_64
Project name: isaac-core
Native cpp compiler: ccache c++ (gcc 6.2.1)
Native c compiler: ccache cc (gcc 6.2.1)
Dependency threads found: YES
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Native dependency sqlite3 found: YES 3.14.1
Dependency GTest found: YES (prebuilt)
Build targets in project: 3
build master ア ninja
[16/16] Linking target tests/sqlitecpp_tests
FAILED: tests/sqlitecpp_tests
ccache c++ -o tests/sqlitecpp_tests 'tests/sqlitecpp_tests@exe/Backup_test.cpp.o' 'tests/sqlitecpp_tests@exe/Column_test.cpp.o' 'tests/sqlitecpp_tests@exe/Database_test.cpp.o' 'tests/sqlitecpp_tests@exe/Statement_test.cpp.o' 'tests/sqlitecpp_tests@exe/Transaction_test.cpp.o' 'tests/sqlitecpp_tests@exe/VariadicBind_test.cpp.o' '-Wl,--no-undefined' 'src/libsqlitecpp_lib.a' 'sqlite3/libsql_lib.a' 'sqlite3/libsql_lib.a' '-pthread' '-lgtest' '-lgtest_main' '-lsqlite3' '-lsqlite3'
/usr/bin/ld: sqlite3/libsql_lib.a(sqlite3.c.o): undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/usr/lib/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Have you ever seen this happening with your lib before?
and if I don't build it as a static_library -
SQLiteCpp master ア mkdir build && cd build && LDFLAGS=-Wl,--no-as-needed meson ..
The Meson build system
Version: 0.33.0
Source dir: /home/agauniyal/projects/SQLiteCpp
Build dir: /home/agauniyal/projects/SQLiteCpp/build
Build type: native build
Build machine cpu family: x86_64
Build machine cpu: x86_64
Project name: isaac-core
Native cpp compiler: ccache c++ (gcc 6.2.1)
Native c compiler: ccache cc (gcc 6.2.1)
Dependency threads found: YES
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Native dependency sqlite3 found: YES 3.14.1
Dependency GTest found: YES (prebuilt)
Build targets in project: 3
build master ア ninja
[14/18] Linking target sqlite3/libsql_lib.so
FAILED: sqlite3/libsql_lib.so
ccache cc -o sqlite3/libsql_lib.so 'sqlite3/sql_lib@sha/sqlite3.c.o' '-Wl,--no-undefined' '-Wl,--no-as-needed' '-shared' '-fPIC' '-Wl,-soname,libsql_lib.so' '-pthread' '-lsqlite3' '-Wl,-rpath,/home/agauniyal/projects/SQLiteCpp/build/sqlite3'
sqlite3/sql_lib@sha/sqlite3.c.o: In function `unixDlOpen':
/home/agauniyal/projects/SQLiteCpp/build/../sqlite3/sqlite3.c:35185: undefined reference to `dlopen'
sqlite3/sql_lib@sha/sqlite3.c.o: In function `unixDlError':
/home/agauniyal/projects/SQLiteCpp/build/../sqlite3/sqlite3.c:35199: undefined reference to `dlerror'
sqlite3/sql_lib@sha/sqlite3.c.o: In function `unixDlSym':
/home/agauniyal/projects/SQLiteCpp/build/../sqlite3/sqlite3.c:35225: undefined reference to `dlsym'
sqlite3/sql_lib@sha/sqlite3.c.o: In function `unixDlClose':
/home/agauniyal/projects/SQLiteCpp/build/../sqlite3/sqlite3.c:35230: undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Okay, so here are some answers to your questions:
- sqlite3ext.h is for designing DLL to extend sqlite, that is, to create dynamic plugins. So it is useful only for very rare/specific use case. shell.c is the sqlite3 command line tool, so no usage for a library
- if you have a reliable recent sqlite3 lib package, use it, it's always better than to use the source files I've added to my source tree
- link error "dlclose": you need to link to Linux lib "dl" (and pthread) see https://github.com/SRombauts/SQLiteCpp/blob/master/CMakeLists.txt#L236 : target_link_libraries(SQLiteCpp_example1 dl)
@SRombauts thankyou for clearing my doubts, I was finally able to build it successfully :smile:
SQLiteCpp master ア mkdir build && cd build && meson .. && ninja
The Meson build system
Version: 0.33.0
Source dir: /home/agauniyal/projects/SQLiteCpp
Build dir: /home/agauniyal/projects/SQLiteCpp/build
Build type: native build
Build machine cpu family: x86_64
Build machine cpu: x86_64
Project name: isaac-core
Native cpp compiler: ccache c++ (gcc 6.2.1)
Native c compiler: ccache cc (gcc 6.2.1)
Dependency threads found: YES
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Native dependency sqlite3 found: YES 3.14.1
Dependency GTest found: YES (prebuilt)
Library dl found: YES
Build targets in project: 3
[18/18] Linking target tests/sqlitecpp_tests
build master ア ./tests/sqlitecpp_tests
Running main() from gtest_main.cc
[==========] Running 26 tests from 7 test cases.
[----------] Global test environment set-up.
[----------] 4 tests from Backup
[ RUN ] Backup.initException
[ OK ] Backup.initException (321 ms)
[ RUN ] Backup.executeStepOne
[ OK ] Backup.executeStepOne (404 ms)
[ RUN ] Backup.executeStepAll
[ OK ] Backup.executeStepAll (402 ms)
[ RUN ] Backup.executeStepException
[ OK ] Backup.executeStepException (480 ms)
[----------] 4 tests from Backup (1607 ms total)
[----------] 2 tests from Column
[ RUN ] Column.basis
[ OK ] Column.basis (1 ms)
[ RUN ] Column.getName
[ OK ] Column.getName (1 ms)
[----------] 2 tests from Column (2 ms total)
[----------] 1 test from SQLiteCpp
[ RUN ] SQLiteCpp.version
[ OK ] SQLiteCpp.version (0 ms)
[----------] 1 test from SQLiteCpp (0 ms total)
[----------] 7 tests from Database
[ RUN ] Database.ctorExecCreateDropExist
[ OK ] Database.ctorExecCreateDropExist (266 ms)
[ RUN ] Database.createCloseReopen
[ OK ] Database.createCloseReopen (114 ms)
[ RUN ] Database.inMemory
[ OK ] Database.inMemory (1 ms)
[ RUN ] Database.busyTimeout
[ OK ] Database.busyTimeout (0 ms)
[ RUN ] Database.exec
[ OK ] Database.exec (1 ms)
[ RUN ] Database.execAndGet
[ OK ] Database.execAndGet (1 ms)
[ RUN ] Database.execException
[ OK ] Database.execException (1 ms)
[----------] 7 tests from Database (384 ms total)
[----------] 10 tests from Statement
[ RUN ] Statement.invalid
[ OK ] Statement.invalid (0 ms)
[ RUN ] Statement.executeStep
[ OK ] Statement.executeStep (0 ms)
[ RUN ] Statement.bindings
[ OK ] Statement.bindings (1 ms)
[ RUN ] Statement.bindNoCopy
[ OK ] Statement.bindNoCopy (0 ms)
[ RUN ] Statement.bindByName
[ OK ] Statement.bindByName (1 ms)
[ RUN ] Statement.bindNoCopyByName
[ OK ] Statement.bindNoCopyByName (1 ms)
[ RUN ] Statement.isColumnNull
[ OK ] Statement.isColumnNull (0 ms)
[ RUN ] Statement.isColumnNullByName
[ OK ] Statement.isColumnNullByName (1 ms)
[ RUN ] Statement.getColumnByName
[ OK ] Statement.getColumnByName (1 ms)
[ RUN ] Statement.getName
[ OK ] Statement.getName (0 ms)
[----------] 10 tests from Statement (6 ms total)
[----------] 1 test from Transaction
[ RUN ] Transaction.commitRollback
SQLite exception: near "DesiredSyntaxError": syntax error
[ OK ] Transaction.commitRollback (1 ms)
[----------] 1 test from Transaction (1 ms total)
[----------] 1 test from VariadicBind
[ RUN ] VariadicBind.invalid
[ OK ] VariadicBind.invalid (1 ms)
[----------] 1 test from VariadicBind (1 ms total)
[----------] Global test environment tear-down
[==========] 26 tests from 7 test cases ran. (2001 ms total)
[ PASSED ] 26 tests.
There's just one error along the tests - SQLite exception: near "DesiredSyntaxError": syntax error , however the tests pass successfully!
Everything's finally resolved, just this is remaining - SQLite exception: near "DesiredSyntaxError": syntax error
@SRombauts if you could clarify how to resolve this, I'll upload sqlitecpp to meson build repository asap 👍
Hi @agauniyal, thank you very much and sorry about the lack of support...
The DesiredSyntaxError is a flawed SQL query written by design with a syntax error to test the error mechanism :)
as the support for windows is ready this should come once there is a new release
forgot to mention, but this was completed long ago, currently with the same release mesonbuild/wrapdb#1131