Hani Goc
Hani Goc

Reputation: 2441

How to add sqlite extension Library to cmake in order to use spellfix1

I downloaded and compiled the following sqlite extension library: SQLITE in order to use spellfix1.


Compile and install

    $ ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" \
        LDFLAGS="-lcrypto"
    $ sudo make
    $ sudo make install

Output

Libraries have been installed in:
   /usr/share/tcltk/tcl8.6/sqlite3

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.

rm -f /usr/share/tcltk/tcl8.6/sqlite3/libtclsqlite3.la /usr/share/tcltk/tcl8.6/sqlite3/libtclsqlite3.a
/usr/bin/install -c -m 0644 pkgIndex.tcl /usr/share/tcltk/tcl8.6/sqlite3
/usr/bin/install -c -d /usr/local/bin
./libtool --mode=install /usr/bin/install -c sqlcipher /usr/local/bin
libtool: install: /usr/bin/install -c .libs/sqlcipher /usr/local/bin/sqlcipher
/usr/bin/install -c -d /usr/local/include/sqlcipher
/usr/bin/install -c -m 0644 sqlite3.h /usr/local/include/sqlcipher
/usr/bin/install -c -m 0644 /home/hani/Documents/articles/Architecture/Modules/sqlcipher/src/sqlite3ext.h /usr/local/include/sqlcipher
/usr/bin/install -c -d /usr/local/lib/pkgconfig
/usr/bin/install -c -m 0644 sqlcipher.pc /usr/local/lib/pkgconfig"

Question

I want to add this library to my project to in order to use spellfix1. For this I am using CMake. Are the steps that I following correct?


First I exported the Environment variables:

  $export SQLITE_EXT=/usr/local/include
  $export SQLITE_LIB=/usr/share/tcltk/tcl8.6

Second I added the following lines to my CMakelist file.

link_directories($ENV{SQLITE_LIB}/sqlite3)
include_directories($ENV{SQLITE_EXT}/sqlcipher)
target_link_libraries(MyProgram tclsqlite3)

Compilation error

I included #include<sqlite3ext.h>

sqlite_modern_cpp.h is an extra layer for sqlite3. error:

/MyProgram/3rdparty/sqlite_modern_cpp.h:160:8: error: ‘sqlite3_api’ was not declared in this scope

Update 1

I have no CMake error. I added SQLITE_EXTENSION_INIT1 based on what was provided in the answer. No compilate error. Right now I have a runtime error which I am going to solve.

#include <sqlite3ext.h>
SQLITE_EXTENSION_INIT1

Upvotes: 1

Views: 2585

Answers (1)

douyw
douyw

Reputation: 4074

In official site, there is an example extension: half. Recently, I used it with a success. Please check it out first to find out how the extension works. And if in trouble, check out this.

Upvotes: 1

Related Questions