Please place a warning somewhere that sqlite does not work on windows. A day's sordid story below:
I started to write this out as an issue, but it may or may not be a
"documentation bug." I'd like to gather enough information to make this
simpler.
The motivation for using Sqlite is that it is much
easier to give example code that has an sqlite database than asking for
someone to install and configure postgres. However, I've run into some
problems getting an example running on windows.
The first error was an inability to find "cl.exe".
C:\work\hello_phoenix>mix ecto.build
==> esqlite (compile)
Compiling c_src/esqlite3_nif.c
'cl.exe'
is not recognized as an internal or external command, operable program
or batch
file.
ERROR: compile failed while processing C:/work/hello_phoenix/deps/esqlite:
rebar_abort
** (Mix) Could not compile dependency :esqlite, "escript.exe
"c:/Users/eric/.mix/rebar" compile skip_deps=true
deps_dir=C:/work/hello_phoenix/_build/dev/lib""
command failed. You can recompile this dependency with "mix
deps.compile esqlite", update it with "mix deps.update esqlite" or clean
it with "mix deps.clean
esqlite"
Now Later, I
find that rebar can point to GCC instead: see
http://stackoverflow.com/questions/15043040/compiling-project-with-nifs-with-rebar-cl-exe-not-found?rq=1
-- this is likely a more stable option, but I don't know the opinons of
the core team, and it's not immediately obvious how to point to gcc from mix. However, I went the Visual Studio route. After
installing Visual Studio and downloading the universal installer -- I
believe that's the package that finally installed cl.exe -- and placing
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin in the path:
mix
ecto.build ==> esqlite
(compile)
Compiling c_src/esqlite3_nif.c
Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86
Copyright
(C) Microsoft Corporation. All rights
reserved.
cl : Command line warning D9024 : unrecognized source file type
'Files/erl7.2/lib/erl_interface-3.8.1/include', object file
assumed
cl : Command line warning D9027 : source file 'Files/erl7.2/lib/erl_interface-3.8.1/include' ignored
cl : Command line warning D9024 : unrecognized source file type 'Files/erl7.2/erts-7.2/include', object file assumed
cl : Command line warning D9027 : source file 'Files/erl7.2/erts-7.2/include' ignored
esqlite3_nif.c
c_src/esqlite3_nif.c(21): fatal error C1083: Cannot open include file: 'erl_nif.h': No such file or directory
ERROR:
compile failed while processing C:/work/hello_phoenix/deps/esqlite:
rebar_abort
** (Mix) Could not compile dependency :esqlite, "escript.exe
"c:/Users/eric/.mix/rebar" compile skip_deps=true
deps_dir="C:/work/hello_phoenix/_build/dev/lib""
command failed. You can recompile this dependency with "mix
deps.compile esqlite", update it with "mix deps.update esqlite" or clean
it with "mix deps.clean
esqlite"
More investigation finds this:
http://stackoverflow.com/questions/7132598/erl-nif-h-not-found -
however, the "source file ignored" leads me to believe it can't find
erl_nif.h due to a space between Program and Files. I reinstall erlang
and elixir and get past that message to:
esqlite3_nif.c
c:\erl7.2\erts-7.2\include\erl_nif.h(68): fatal error C1083: Cannot
open include file: 'stdlib.h': No such file or
directory
ERROR: compile failed while processingC:/work/hello_phoenix/deps/esqlite:
rebar_abort
...
And this is where I throw my hands up in frustration. Then, I see this on the esqlite page:
https://github.com/mmzeeman/esqlite/issues/29 Considering it's a path issue, I don't know if it would or wouldn't work if I get through the next obstacle. Has anyone else had success? I could also pair with someone to solve this if windows machines aren't available.