
Thanks for the reply. I've added extra-libraries to package.yaml. Now though, I'm getting a missing C library error (although `stack path --extra-library-dirs` prints the directory of the .lib file) Yotam בתאריך יום ג׳, 11 בספט׳ 2018 ב-10:03 מאת Phyx <lonetiger@gmail.com>:
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
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.