LoginSignup
4

More than 5 years have passed since last update.

Windows版stackでもHDBC-sqlite3をビルドする

Last updated at Posted at 2016-11-05

試した環境:

  • Windows 10 Home 64bit (ver. 1607)
  • stack v1.0.4
  • LTSHaskell 7.5

(Bash for Windowsは使ってません)

うまくいかなかった方法

MSYS2を使っているので、

とりあえず、

pacman -S sqlite

したうえで、
cabalファイルにHDBC-sqlite3を書いたプロジェクトで

stack install

するも

Process exited with code: ExitFailure 1
Logs have been written to: C:\Users\Yuji\Dropbox\prg\prj\shioyaki\.stack-work\logs\HDBC-sqlite3-2.3.3.1.log
Configuring HDBC-sqlite3-2.3.3.1...
setup-Simple-Cabal-1.24.0.0-ghc-8.0.1.exe: Missing dependency on a foreign
library:
* Missing C library: sqlite3
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.

と怒られる。
上記のメッセージの通り
--extra-include-dirs=--extra-lib-dirs=なるオプションがあるそうなので、msys2のインストールディレクトリーをあさるも、それらしいDLLやヘッダーファイルが見当たらない。

うまくいった方法

やむを得ずProgramming Notes: WindowsにHaskell HDBC-sqlite3のインストールを参考にSQLite本家のサイトからWindows用のDLL(sqlite-dll-win64-x64-3150100.zip)とヘッダーファイル(sqlite-amalgamation-3150100.zip)をとってきて、それぞれをC:\sqliteディレクトリーに展開。

その上で

stack build --extra-include-dirs="C:\sqlite" --extra-lib-dirs="C:\sqlite"

と実行したらインストールできた模様。

TODO

stack buildするたびに毎回上記のオプションを指定するのはかったるいので、方法を別途検討する。

追記: よく見たら stack.yaml に同名の項目があった。stack newなどしたら出てくるデフォルトのstack.yamlにも、次のようにコメントアウトされて書いてあるはず。

# Extra directories used by stack for building
# extra-include-dirs: [/path/to/dir]
# extra-lib-dirs: [/path/to/dir]

ただしこれはフルパスでないといけないので、プロジェクトディレクトリーのどこかに置きたい、みたいなケースではやっぱりstack buildをラップしたコマンドを作る必要があるだろう。
まぁ、作ればいいだけの話だけど。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4