I am making a small Haskell game in Windows, where I would like to respond each time the user presses a key. Because getChar
behaves strangely on Windows, I use FFI to get access to getch
in conio.h
, as described here. The relevant code is:
foreign import ccall unsafe "conio.h getch" c_getch :: IO CInt
This works fine, when I run it in ghci, or compile it with ghc. I also want to try making a cabal package out of it, so extending from this question, I include the following in my cabal file:
...
executable noughts
Includes: conio.h
Extra-libraries conio
...
But when I run cabal configure
, it tells me:
cabal: Missing dependency on a foreign library:
* Missing C library: conio
It makes sense, because in my haskell platform directory, under ...\Haskell Platform\2012.4.0.0\mingw
there is a conio.h
file under the include
directory, but no other conio
file to provide the object code.
Am I doing this the right way, and if so, how can I find out which library to include in my cabal file?
Extra-Libraries: crtdll
orExtra-Libraries: msvcrt
? By the way, according to MSDN, you should use_getch
instead ofgetch
, but the header file might do that for you. – user824425Extra-libraries: msvcrt
andExtra-libraries: crtdll
alone and in combination. It didn't change the output ofcabal build
. I foundmsvcrt.lib
andcrtdll.c
under my visual studio installation, and copied them to my folder, but it didn't change anything. – BorisExtra-Libraries: NAME
, Cabal should be looking for...\Haskell Platform\2012.4.0.0\mingw\lib\libNAME.a
. I havelibcrtdll.a
in that directory, so a dependency oncrtdll
works fine for me. Have you tried supplying the--extra-lib-dirs
parameter tocabal
, pointing to that directory? – user824425Extra-libraries: crtdll
in my cabal file. I have the filelibcrtdll.a
under...\Haskell Platform\2012.4.0.0\mingw\lib
, and I have configured cabal with theextra-lib-dirs="(Path to lib dir)"
flag. I now get the error:parse error on input 'import
, so it's different. B.t.w., I thought cabal would include thelib
folder by default? – Boris