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

Phyx lonetiger at gmail.com
Tue Sep 11 07:03:03 UTC 2018


Hi,

I assume CreateDebuggedProcess is defined in bindings.lib? You need to also
add extra-libraries: bindings

Also keep in mind that C++ has a different name mangling than C, so if your
function is in a class you'll need to use the proper name for it.

nm -g bindings.lib would show the actual name.

Tamar.

On Tue, Sep 11, 2018, 07:51 Yotam Ohad <yotam2206 at gmail.com> wrote:

> 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
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20180911/da05e5e2/attachment.html>


More information about the Haskell-Cafe mailing list