I don't use stack so can't help you much there. If you can get it to put ghc in verbose mode you can see what it's passing to the compiler. If the error is coming from stack itself then you'll need to figure out how stack tests for the library. <br><br><div class="gmail_quote"><div dir="ltr">On Tue, Sep 11, 2018, 08:32 Yotam Ohad <<a href="mailto:yotam2206@gmail.com">yotam2206@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><div dir="ltr">Thanks for the reply.</div><div dir="ltr">I've added extra-libraries to package.yaml.</div><div dir="ltr">Now though, I'm getting a missing C library error (although `stack path --extra-library-dirs` prints the directory of the .lib file)</div><div dir="ltr"><br></div><div dir="ltr">Yotam<br></div></div><br><div class="gmail_quote"><div dir="rtl">בתאריך יום ג׳, 11 בספט׳ 2018 ב-10:03 מאת Phyx <<a href="mailto:lonetiger@gmail.com" target="_blank">lonetiger@gmail.com</a>>:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, <div><br></div><div>I assume CreateDebuggedProcess is defined in bindings.lib? You need to also add extra-libraries: bindings </div><div><br></div><div>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. </div><div><br></div><div>nm -g bindings.lib would show the actual name. </div><div><br></div><div>Tamar. </div><div><br><div class="gmail_quote"></div></div><div><div class="gmail_quote"><div dir="ltr">On Tue, Sep 11, 2018, 07:51 Yotam Ohad <<a href="mailto:yotam2206@gmail.com" target="_blank">yotam2206@gmail.com</a>> wrote:<br></div></div></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="rtl"><div dir="ltr"></div><div dir="ltr">Hi,<br><br>I made a lib from a cpp project with one function: BOOL Foo(LPCSTR bar)<br>In the stack project I added the .lib file's folder to the extra-lib-dirs/extra-include-dirs and then, in main:<br><br>{-# LANGUAGE ForeignFunctionInterface #-}<br><br>module Main where<br><br>import System.Win32.Types<br>import Foreign.C.String<br><br>main :: IO ()<br>main = do<br> withCString "bar" c_Foo<br> putStrLn "success"<br><br>foreign import ccall "bindings.lib Foo"<br> c_Foo :: LPCSTR -> IO BOOL<br><br>When building I get the following error<br>Building all executables for `tape' once. After a successful build of all of them, only specified executables will be rebuilt.<br>tape-0.1.0.0: build (lib + exe)<br>Preprocessing library for tape-0.1.0.0..<br>Building library for tape-0.1.0.0..<br>ignoring (possibly broken) abi-depends field for packages<br>Preprocessing executable 'tape-exe' for tape-0.1.0.0..<br>Building executable 'tape-exe' for tape-0.1.0.0..<br>Linking .stack-work\dist\7d103d30\build\tape-exe\tape-exe.exe ...<br>.stack-work\dist\7d103d30\build\tape-exe\tape-exe-tmp\Main.o:fake:(.text+0x102): undefined reference to `CreateDebuggedProcess'<br>collect2.exe: error: ld returned 1 exit status<br>`gcc.exe' failed in phase `Linker'. (Exit code: 1)<br><br>-- While building custom Setup.hs for package tape-0.1.0.0 using:<br> 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"<br> Process exited with code: ExitFailure <br></div><div dir="ltr"><br></div><div dir="ltr">What am I doing wrong?</div><div dir="ltr">Yotam<br></div><div dir="ltr"> <br></div></div></blockquote></div></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div></div>
</blockquote></div>
</blockquote></div>