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

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


Hi,

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-0.1.0.0: build (lib + exe)
Preprocessing library for tape-0.1.0.0..
Building library for tape-0.1.0.0..
ignoring (possibly broken) abi-depends field for packages
Preprocessing executable 'tape-exe' for tape-0.1.0.0..
Building executable 'tape-exe' for tape-0.1.0.0..
Linking .stack-work\dist\7d103d30\build\tape-exe\tape-exe.exe ...
.stack-work\dist\7d103d30\build\tape-exe\tape-exe-tmp\Main.o:fake:(.text+0x102):
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-0.1.0.0 using:

C:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_Z6RU0evB_2.2.0.1_ghc-8.4.3.exe
--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?
Yotam
-------------- 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