[Haskell-cafe] Adding a custom lib to stack project

Yotam Ohad yotam2206 at gmail.com
Tue Sep 11 06:50:42 UTC 2018


I made a lib from a  cpp project with one function: BOOL Foo(LPCSTR bar)
In the stack project I added the .lib file's folder to the
extra-lib-dirs/extra-include-dirs and then, in main:

{-# LANGUAGE ForeignFunctionInterface #-}

module Main where

import System.Win32.Types
import Foreign.C.String

main :: IO ()
main = do
    withCString "bar" c_Foo
    putStrLn "success"

foreign import ccall "bindings.lib Foo"
    c_Foo :: LPCSTR -> IO BOOL

When building I get the following error
Building all executables for `tape' once. After a successful build of all
of them, only specified executables will be rebuilt.
tape- build (lib + exe)
Preprocessing library for tape-
Building library for tape-
ignoring (possibly broken) abi-depends field for packages
Preprocessing executable 'tape-exe' for tape-
Building executable 'tape-exe' for tape-
Linking .stack-work\dist\7d103d30\build\tape-exe\tape-exe.exe ...
undefined reference to `CreateDebuggedProcess'
collect2.exe: error: ld returned 1 exit status
`gcc.exe' failed in phase `Linker'. (Exit code: 1)

--  While building custom Setup.hs for package tape- using:

--builddir=.stack-work\dist\7d103d30 build lib:tape exe:tape-exe
--ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
    Process exited with code: ExitFailure

What am I doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180911/2d7fa172/attachment.html>

More information about the Haskell-Cafe mailing list