How to build mksqlite MEX file mksqlite.mexa64 in Linux?

2 views (last 30 days)
Here is the build procedure:
Download and unzip source code for the latest release, for example at:
http://prdownload.berlios.de/mksqlite/mksqlite-1.12.zip
In mksqlite.cpp fix 'isprint' compile error at line 830:
Added:
#include <ctype.h>
After:
#include <string.h>
Find library implementing DLL utility functions dlopen, dlclose, dlsym, dlerror
-bash-4.0$ find /usr -name 'libdl.*'
/usr/lib64/libdl.so
Verify Matlab utility "mex" and Gnu C++ are available:
-bash-4.0$ which mex
/usr/local/MATLAB/R2012a/bin/mex
-bash-4.0$ which g++
/usr/lib64/ccache/g++
Build as follows, with working directory set to location of code:
-bash-4.0$ mex CXX=g++ CXX=g++ LD=g++ -lm -ldl -L /usr/lib64/libdl.a -output mksqlite.mexa64 mksqlite.cpp sqlite3.c
I was able to figure this out thanks to the tutorial:
"Creating, compiling and linking MATLAB executables (MEX files): a tutorial" by Peter Carbonetto
http://www.cs.ubc.ca/~pcarbo/mex-tutorial/index.html
  2 Comments
Kaustubha Govind
Kaustubha Govind on 9 Sep 2013
It looks like you posted the solution as part of your question. Please separate it out and post as an answer and accept it, so that it is clear to the users of the forum that this question has been resolved.
Andreas Martin
Andreas Martin on 5 Feb 2014
...or contact the developers, when get into trouble... :-)

Sign in to comment.

Answers (1)

Frank Zalkow
Frank Zalkow on 10 Aug 2016
Is anyone getting it compiled in mksqlite version 2.3? (I am running Matlab R2016a under Ubuntu 16.04).
When doing your steps I still get this error message:
$ mex CXX=gcc CXX=gcc LD=gcc -lm -ldl -L/usr/lib/x86_64-linux-gnu/libdl.a -output mksqlite.mexa64 mksqlite.cpp sqlite/sqlite3.c
Building with 'g++'.
In file included from /home/username/dev/mksqlite/mksqlite.cpp:28:0:
/home/username/dev/mksqlite/sql_interface.hpp: In static member function ‘static void SQLiface::mexFcnWrapper(sqlite3_context*, int, sqlite3_value**, int)’:
/home/username/dev/mksqlite/sql_interface.hpp:870:67: warning: comparison between ‘enum mxClassID’ and ‘enum ValueMex::<anonymous>’ [-Wenum-compare]
/home/username/dev/mksqlite/sql_interface.hpp: In member function ‘bool SQLiface::bindParameter(int, ValueMex&, bool)’:
/home/username/dev/mksqlite/sql_interface.hpp:1129:47: warning: comparison between ‘enum mxClassID’ and ‘enum ValueMex::<anonymous>’ [-Wenum-compare]
/home/username/dev/mksqlite/mksqlite.cpp: In member function ‘bool Mksqlite::cmdTryHandleCreateFunction(const char*)’:
/home/username/dev/mksqlite/mksqlite.cpp:1065:33: error: strlwrwas not declared in this scope
/home/username/dev/mksqlite/mksqlite.cpp: In member function ‘bool Mksqlite::cmdTryHandleCreateAggregation(const char*)’:
/home/username/dev/mksqlite/mksqlite.cpp:1137:33: error: strlwrwas not declared in this scope
/home/username/dev/mksqlite/mksqlite.cpp: In member function ‘bool Mksqlite::cmdHandleSQLStatement()’:
/home/username/dev/mksqlite/mksqlite.cpp:2324:101: error: no matching function for call to ‘SQLiface::bindParameter(int, ValueMex, bool)’
/home/username/dev/mksqlite/mksqlite.cpp:2324:101: note: candidate is:
In file included from /home/username/dev/mksqlite/mksqlite.cpp:28:0:
/home/username/dev/mksqlite/sql_interface.hpp:1093:8: note: bool SQLiface::bindParameter(int, ValueMex&, bool)
/home/username/dev/mksqlite/sql_interface.hpp:1093:8: note: no known conversion for argument 2 from ‘ValueMex’ to ‘ValueMex&’
In file included from /home/username/dev/mksqlite/sql_builtin_functions.hpp:28:0,
from /home/username/dev/mksqlite/sql_interface.hpp:23,
from /home/username/dev/mksqlite/mksqlite.cpp:28:
/home/username/dev/mksqlite/deelx/deelx.h: In instantiation of ‘CHART* CRegexpT<CHART>::Replace(const CHART*, int, const CHART*, int, int&, int, int, MatchResult*, CContext*) const [with CHART = char; MatchResult = MatchResultT<0>]:
/home/username/dev/mksqlite/deelx/deelx.h:3814:166: required from ‘CHART* CRegexpT<CHART>::Replace(const CHART*, const CHART*, int, int, MatchResult*, CContext*) const [with CHART = char; MatchResult = MatchResultT<0>]
/home/username/dev/mksqlite/sql_builtin_functions.hpp:291:57: required from here
/home/username/dev/mksqlite/deelx/deelx.h:3962:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/username/dev/mksqlite/deelx/deelx.h:3974:17: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/username/dev/mksqlite/deelx/deelx.h:4032:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/username/dev/mksqlite/deelx/deelx.h:4044:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/home/username/dev/mksqlite/deelx/deelx.h:4052:13: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Manually including a function definition for strlwr, like proposed here, leads to even more errors...

Categories

Find more on C Shared Library Integration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!