using sqlite3 with lua
Question: I'm trying to use sqlite3 with lua (am already using c++, but I'm a n00b with
lua- I read [this](http://stackoverflow.com/questions/356160/which-game-
scripting-language-is-better-to-use-lua-or-python/358583#358583)) but I'm
getting the following when trying to build the library or whatever:

    
    
    C:\lib\lsqlite3-7>mingw32-make
    process_begin: CreateProcess(NULL, pkg-config --version, ...) failed.
    makefile:53: *** windows32.  Stop.
    

I'm not at all surprised at a makefile failing but I can't do them (is it
spaces or tabs? where is it they have to go?), I would have thought there was
a binary for windows?

Any simple answers appreciated. I haven't got the time to learn make or
install cygwin or whatever.


Answer: You might consider using LuaSQL as your wrapper instead, since it is already
included in the [Lua for Windows](http://code.google.com/p/luaforwindows/)
package and so it is likely already on your system. It includes support for
SQLite3 among other databases.

It does look like you are trying to build the latest release of lsqlite3, but
that this release was not packaged to be easily built on or for Windows. I
didn't attempt to track down a binary since LuaForge only has a source
package. It looks like building it successfully will require manually editing
the Makefile, and then running the Makefile under either MSYS or Cygwin so
that the *nix utilities it assumes exist are available to it.

**Update: June, 2012**

Since writing this answer, I've had occasion to consider using `lsqlite3`
myself for a project that will not require the flexibility of binding to many
distinct database providers, so building in a tight dependency on SQLite makes
sense. Given that, the `lsqlite3` wrapper is a good fit due to its small size
and clean implementation of a lot of the important bits of the SQLite C API.

To build it, I used [MSYS](http://www.mingw.org/wiki/msys) which provides a
minimal unix-like command prompt and supporting utilities for use with the
MinGW port of GCC. In that environment, I had to make a small modification to
the Makefile to force it to use manual configuration, and to provide the
configuration details identifying where `lua.h`, `lua51.dll`, `sqlite3.h`, and
`sqlite3.dll` were hiding on my system.

The only real trick to that is to correctly map Windows path names to MSYS
path names by changing `C:` to `/c/`, and to avoid using any folder names with
spaces in them. So with Lua for Windows on `C:\Program Files (x86)\Lua\5.1`,
that maps to `/c/PROGRA~2/Lua/5.1`, using the Windows 8.3 short name to avoid
the spaces.

A key point to recommend MSYS over other unix-like build environments on
Windows is that it is specifically intended for this purpose. The programs and
DLLs build from it are free of any unexpected dependencies. Specifically, this
is unlike Cygwin which is intended to provide a complete unix-like experience
layered on top of Windows.

With `lsqlite3.dll` freshly built, all I had to do was install it somewhere on
my Lua `package.cpath` along with `sqlite3.dll` and the examples and test
cases all appear to work.

