sqlite3 can't loading extension - sqlite

I am trying to load an extension in sqlite3.
I managed to compile the extension using:
clang -bundle -fPIC -Isqlite3 -o <desired extension name>.sqlext <filename>.c
However, I cannot seem to load the extension.
.load <path to extension file>
Error: unknown command or invalid arguments: "load". Enter ".help" for help
And when I type .help, I cannot see .load.
I have also tried to enable extensions.
int sqlite3_enable_load_extension(sqlite3 *db, int onoff==1);
Error: near "int": syntax error
I would really appreciate a step-by-step instruction on how to enable extensions in SQLite?
Thanks!

Most likely your sqlite compiled with SQLITE_OMIT_LOAD_EXTENSION. Get the one build without this flag, or build it yourself.
You cannot use sqlite3_enable_load_extension from SQL, it is sqlite's C API.

For many vendors, the default provided sqlite3 does not have a load extension enabled. (keltar clarified)
I would really appreciate a step-by-step instruction on how to enable extensions in SQLite?
Go to Sqlite Downloads
Get the appropriate build. It has the load extension enabled.
Use it directly or replace /usr/bin/sqlite3 with the newer one.

Related

Compiling SQLite RTREE in MSVC?

I need to compile the rtree extension for SQLite from source code. The readme includes these instructions:
The easiest way to compile and use the RTREE extension is to build
and use it as a dynamically loadable SQLite extension. To do this
using gcc on *nix:
gcc -shared rtree.c -o libSqliteRtree.so
You may need to add "-I" flags so that gcc can find sqlite3ext.h
and sqlite3.h. The resulting shared lib, libSqliteRtree.so, may be
loaded into sqlite in the same way as any other dynamicly loadable
extension.
Problem I'm having is that I'm on Windows, not Linux, and so need to use MSVC. I tried:
cl rtree.c -link -out:libSqliteRtree.so
This gave cannot open include file errors until I found the various .h files it was complaining about and moved them into the same directory. Now, however, it's gotten to:
/out:rtree.exe
-out:libSqliteRtree.so
rtree.obj
Creating library libSqliteRtree.lib and object libSqliteRtree.exp
LINK : fatal error LNK1561: entry point must be defined
I admit I have pretty much zero clue what I'm doing in a compiler, and I'm not sure where to go from here to resolve its problem. Am I "translating" the compiler flags correctly from GCC to MSVC? What else can I tweak to try to get the SQLite extension out of the source code? Should I beg a favor from a developer on ateam with a Linux server and ask them to do it for me?
Thanks to Shawn for commenting to look at the SQLite Run-Time Loadable Extensions documentation, which had more information in it:
To compile on Windows using MSVC, a command similar to the following will usually work:
cl YourCode.c -link -dll -out:YourCode.dll
So for my situation: cl rtree.c -link -dll -out:libSqliteRtree.dll worked.

Add coverity scan to Qt app

I'm trying to add Coverity Scan static analysis to my Qt project but I'm not able to get the result.
I download the coverity scan build tools and use the following command line:
cov-build --dir cov-int make
Which produces the following log:
...
my build log
...
[WARNING] No files were emitted. This may be due to a problem with your configuration
or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
For more details, please look at:
/Users/martin/dev/builds/ConsoleTest01-Desktop_Qt_5_3_clang_64bit-Debug/cov-int/build-log.txt
How can I go further?
I'm using Qt 5.3.2 under MacOS 10.9.
I didn't read the docs carefully enough: https://scan.coverity.com/download?tab=cxx
I had to configure coverity first by running:
cov-configure --comptype clangcxx --compiler clang++ --template
You need to run qmake first, then you can run the cov-int command with make.
I found it easiest to run cov-int in my build- folder created by Qt-Creator.

Sqlite 3.7.15 Crosss compilation for ARM

I am using SQLite 3 for Database management in my ARM9 based microprocessor.
I want to cross compile the latest version of the SQLite 3 for my project in Linux (Ubuntu 10.04). I am using the arm-none-linux-gnueabi-gcc compiler for development.
I tried to cross compile using following commands,
Downloaded the sqlite-amalgamation-3.7.0.tar
I extract it and then write the following command on Terminal,
sudo ./configure --exec-prefix=/media/8CCC8E9BCC8E7F68/SQLIte3/sqliteinstall/ --host=arm --target=arm CC=/opt/arm-2011.03/bin/arm-none-linux-gnueabi-gcc AR=/opt/arm-2011.03/bin/arm-none-linux-gnueabi-ar STRIP=/opt/arm-2011.03/bin/arm-none-linux-gnueabi-strip RANLIB=/opt/arm-2011.03/bin/arm-none-linux-gnueabi-ranlib CFLAGS="-Os"
It successfully cross compiled the SQLite.
Then,
sudo make command.
It successfully run.
Now "make install " command.
It did not give me an error but when i went to the config.log file i found there is some sentences as following,
1.conftest.c:17:7: error: size of array 'off_t_is_large' is negative
2.conftest.c:12:28: fatal error: ac_nonexistent.h: No such file or directory
compilation terminated.
3.conftest.cpp:23:28: error: ac_nonexistent.h: No such file or directory
4.conftest.c:67:13: error: invalid type argument of unary '*' (have 'int')
I doubt that weather it has been cross compiled properly or not.
I can not understand.
I inserted the library on my board it works fine but the problem is that the speed got very slow. I think there is some problem that i have not set any flags for the GCC compiler.
I could not find any options.How I can set the particular flags for the GCC compiler so that unnecessary features can be omitted.
You probably shouldn't try to do cross-compilation manually. Instead, use an embedded Linux build system that will do that for you, and automate the cross-compilation process entirely. My favourite is of course Buildroot (http://buildroot.org), but there are plenty of others (with varying levels of quality, complexity and features) : OpenEmbedded, Yocto, PTXdist, etc.

Compiling sqlite Levenshtein function for System.Data.SQLite

OK, I'm new to compiling programs, and I have literally tried everything.
I downloaded System.Data.SQLite from here:
http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
This allowed me to get sqlite functionality into my C# application. Now I'm looking to add a Levenshtein function so that I can do a search to find similar results in my c# application.
I stumbled upon:
https://github.com/mateusza/SQLite-Levenshtein
But I honestly have no clue how to compile it and load it as an extension. I read about the sqlite extensions on sqlite's main website.
I have an idea about how to load my extension: Run select load_extension('path to .dll'), but I don't know how to turn that SQLite-Levenshtein into a dll file that can be loaded from sqlite. I would appreciate any help you can give. (Please bear with me, I'm slowly diving into wide world of compiling).
That's how I compiled this extension with mingw GCC:
gcc -s -O4 -I /path/to/sqlite/headers/ -shared -o levenshtein.dll levenshtein.c
/path/to/sqlite/headers/ is the place where sqlite3ext.h file is located.
If your platform is x86 (32-bit), you may take http://www.siftsoft.com/misc/levenshtein.dll -- that's what I built from git HEAD right now.

Trouble building sqlite 3.7.4 on CentOS 5.5 to include readline support

The readline library allows the CLI for sqlite to accept arrow keys to recall previously typed commands. I can build without this and sqlite works, it's just a hassle not having this nice capability. I've installed readline-devel from yum and /usr/lib64/libreadline.so.5 is present as well as it's header files. When I run ./configure to build sqlite, I see these lines:
checking for library containing readline... no
checking for readline... no
The library path is set to the correct path:
LD_LIBRARY_PATH="/usr/lib64:/usr/local/lib:/lib:/usr/lib"
By default, ./configure does try to include readline support so there are no special "--with-XXXX" options needed.
Anyone every seen this problem? I need to use this newer version to get latest foreign key support. It's hassle running on CentOS as is bundles pretty old versions of apps but we don't have a choice right now and I cannot find an updated RPM with newer version of sqlite.
=== UPDATE ===
Ok, I found a solution but I don't completely like it...
First, I tried with this option:
./configure CPPFLAGS="-I/usr/include/ -DHAVE_READLINE"
That causes the readline functionality to get compiled into shell.c which is what is needed for starters. But, the linking fails because it cannot find libreadline. The only 'kludgy' way I could figure out to get it to link was to manually edit the Makefile after running the above ./configure command. I changed this line:
LIBS = -ldl -lpthread
to this:
LIBS = -ldl -lpthread -lreadline -ltermcap
Then I ran "make clean all" and "make install" and the readline functionality works in the CLI.
I tried every way I could think of to pass in the extra libraries including exporting using LIBS, exporting using READLINE_LIBS, exporting using LDFLAGS, nothing would work. If you set LIBS to anything, like "export LIBS="-lreadline", it causes configure to fail. The --help on configure about using LIBS seems to contradict what happens when you actually set it to any value.
Anyway, this works so I can live with it - but I don't particularly like it! :(
==== THE RIGHT SOLUTION ====
Well, wouldn't you know it. Spend hours trying to figure it out, then stumble onto the right tip on Google. Just needed to install ncurses-devel first. So, to summarize all that is needed to built it 'unkludgily':
yum install ncurses ncurses-devel
yum install readline readline-devel
yum install libtermcap libtermcap-devel
./configure
make
make install
No special command line options or exports or Makefile edits needed! Readline support is automatically built in by default now.

Resources