Compiling sqlite Levenshtein function for System.Data.SQLite - 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.

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.

Qt DirectX fxc.exe compilation line

I was compiling Qt, then saw in the log "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Utilities\bin\x86\fxc.exe" /nologo /E VS_Passthrough2D /T vs_4_0_level_9_3 /Fh libANGLE/renderer/d3d/d3d11/shaders/compiled/passthrough2d11vs.h ../../../3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/shaders/Passthrough2D11.hlsl
It gave error Too many files specified ('E:/' was the last one), use /? to get usage information
it shows in the help that /E<name> entrypoint name
It seems to me that it is treating the /E option as the path E:/ (its unfortunate I have a drive E, and many data residing in it). Is there anyway around this? is my analogy correct? some suggestions would be really appreciated.
Having had the same problem recently, I asked colleagues about it and was advised to use MS's cmd.exe command prompt instead of MinGW's Git Bash prompt. For some reason that worked ! I won't pretend to understand how choice of command shell can help, but apparently it does.
See also discussion of this on Qt's own forum:
https://forum.qt.io/topic/73114/building-with-mingw64-on-windows-8

table_editors-moc.ads not found

I'm using gcc (GCC) 4.5.4 20120510 for GNAT GPL 2012 (20120509)
and qtada from qtada-gpl-3.2.0-20120708-3871-qt4.8.2-2.exe installer.
I'm trying to compile example from "..\GNAT\2012\examples\qtada\sql\cached_table", but it say "table_editors-moc.ads not found",
The error came from statement :
with Table_Editors.MOC; pragma Warnings (Off, Table_Editors.MOC);
-- Child package MOC must be included in the executable.
Where can i found the "Child package MOC" that contains "table_editors-moc.ads" and another moc file??
I don't know Qt or QtAda, but a quick search indicates that Qt uses a Meta Object Compiler (MOC) to auto-generate source code from macros. Could it be that your Table_Editor.MOC is supposed to be generated?
I'm surprised that QtAda has installed its examples at \GNAT\2012\examples; judging by the way GNAT is set up on this Mac, I'd have expected \GNAT\2012\share\examples.
However .. I suspect that QtAda's file system layout is complicated enough that you'll need to use a "GNAT Project file" to do the build. I hope there's a .gpr file in the same directory as your example code (if not, I can't help); if so, and assuming it's called cached_table.gpr, then in a command window say
gnatmake -p -P cached_table.gpr
or (following the documentation for QtAda 3.1)
gprbuild -p -P cached_table.gpr

Cant use shared libraries in Qt project

I created a C++ library project in Qt creator. After building the project I have the libMylib.so, .so.1, .so.1.0, .so.1.0.0, Makefile and mylib.o files. I added the library headers to my other project and added the path to my .pro file like this:
LIBS += "/home/peter/Workspace/build-Libtester-Desktop-Release/libMyLib.so"
When building the application I don't get no such file error, but when running it I get this:
/home/peter/Workspace/build-Libtester-Desktop-Debug/Libtester: error while loading shared libraries: libMyLib.so.1: cannot open shared object file: No such file or directory
which I can't understand, because it's right there next to the .so which it seem to find, because when the path is wrong I get a no such file or directory error when trying to build the project.
Could someone explain what I'm missing here?
Thanks for your time.
Fortunately, your problem has nothing to do with both Qt and Qt Creator. The error simply boils down to how shared libraries are searched by LD for dynamic linking on Unix OS family.
Today, I've answered similar question, have a look, please. This question was asked in regard to Mac OS X. However, Linux and Mac OS X are the same in the context of your problem. I've provided additional explanation for Linux at the bottom, so pay attention to it. "it's right there next to the .so" - you seem to have Windows background if you make this assumption, but it is wrong for Unix OS family altogether (as stated in the answer too). If you have further questions, just ask.
You are adding the library incorrectly. You are doing:
LIBS += "/home/peter/Workspace/build-Libtester-Desktop-Release/libMyLib.so"
instead of:
LIBS += -L"/home/peter/Workspace/build-Libtester-Desktop-Release" -lMyLib
The first version works on windows, but not linux.
Basically, you create a library, which will be named "libMyLib.so", and then you specify the path to its folder, prepended by "-L" and then do "-lMyLib" at the end, note that it's not "-llibMyLib", but just "-lMyLib", despite the fact that the .so name is "libMyLib".
Look here: https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application for more info.

Cross Compiling Qt for Embedded Arm: libpthread.so.0 not found

I am trying to cross compile Qt with WebKit for an embedded arm device (freescale processor). I have a arm-none-linux-gnueabi toolchain.
Qt actually compiled, but I have run into problems when trying to compile the demos, in particular the WebKit ones, which is really what I am after.
The first problem I was having was that libjscore was not found, which was an error due to the way Qt handles static builds. Turns out you can copy the library and it works, see here.
Now compilation breaks again saying it can not find libpthread.so.0, which would seem to be a toolchain problem rather than a Qt problem.
Searching the directory tree in my toolchain, there are several libpthreads. A copy of the find | grep libpthread command's output is below for reference.
./arm-none-linux-gnueabi/sysroot/vfp/lib/libpthread-2.5.so
./arm-none-linux-gnueabi/sysroot/vfp/usr/lib/libpthread_nonshared.a
./arm-none-linux-gnueabi/sysroot/vfp/usr/lib/libpthread.a
./arm-none-linux-gnueabi/sysroot/vfp/usr/lib/libpthread.so_orig
./arm-none-linux-gnueabi/sysroot/vfp/usr/lib/libpthread.so
./arm-none-linux-gnueabi/sysroot/lib/libpthread-2.5.so
./arm-none-linux-gnueabi/sysroot/usr/lib/libpthread_nonshared.a
./arm-none-linux-gnueabi/sysroot/usr/lib/libpthread.a
./arm-none-linux-gnueabi/sysroot/usr/lib/libpthread.so_orig
./arm-none-linux-gnueabi/sysroot/usr/lib/libpthread.so
So it seems that there is something weird with the linker? Also, what needs to be symlinked to create the libpthread.so.0?
Note: the _libpthread.so_orig_ and libpthread.so follow this fix.
Any help or suggestions are much appreciated. I've been banging my head against a wall for two days now.
Thanks
In general, you should make sure that the toolchain you built (or has been built for you) is in the same exact path it was built at. The libraries (*.so *.a) should also be in the same original path. It should look like this:
<path>/bin
<path>/usr/lib
<path>/lib
Those folders should not be moved. The toolchain executables are in "bin" and the libraries it looks for are in "../usr/lib and ../lib". Also, <path> may be hard-coded into your gcc binaries in some fashion. Moving it around seems to break things.
Target is a raspberry PI
I copy target lib directory to myuserdirectory
target /usr/lib to my crosscompiler /usr/lib/ directorie
target /lib my crosscompiler /lib/ directorie
I create two symbolic link:
ln -s /yourcrosscompilerusrlibdirectory /usr/lib/arm-linux-gnueabihf
ln -s /yourcrosscompilerusrdirectory /lib/arm-linux-gnueabihf
and it's work for me
libpthread are in /yourcrosscompilerusrlibdirectory

Resources