<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Hi Yotam,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Have you tried with cabal? If that gives the same error can you paste your cabal file somewhere and I can take a look for you.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Cheers,</p><p class=MsoNormal>Tamar</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='border:none;padding:0in'><b>From: </b><a href="mailto:lonetiger@gmail.com">Phyx</a><br><b>Sent: </b>Tuesday, September 11, 2018 08:50<br><b>To: </b><a href="mailto:yotam2206@gmail.com">Yotam Ohad</a><br><b>Cc: </b><a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a><br><b>Subject: </b>Re: [Haskell-cafe] Adding a custom lib to stack project</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='margin-bottom:12.0pt'>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. </p><div><div><p class=MsoNormal>On Tue, Sep 11, 2018, 08:32 Yotam Ohad <<a href="mailto:yotam2206@gmail.com">yotam2206@gmail.com</a>> wrote:</p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p class=MsoNormal>Thanks for the reply.</p></div><div><p class=MsoNormal>I've added extra-libraries to package.yaml.</p></div><div><p class=MsoNormal>Now though, I'm getting a missing C library error (although `stack path --extra-library-dirs` prints the directory of the .lib file)</p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Yotam</p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal dir=RTL style='text-align:right;direction:rtl;unicode-bidi:embed'><span dir=RTL></span><span dir=RTL></span><span lang=AR-SA style='font-family:"Times New Roman",serif'><span dir=RTL></span><span dir=RTL></span>‫</span><span lang=HE style='font-family:"Times New Roman",serif'>בתאריך יום ג׳, 11 בספט׳ 2018 ב-10:03 מאת ‪</span><span dir=LTR>Phyx</span><span dir=RTL></span><span dir=RTL></span><span lang=HE style='font-family:"Times New Roman",serif'><span dir=RTL></span><span dir=RTL></span>‏</span><span lang=AR-SA style='font-family:"Times New Roman",serif'> <‪<a href="mailto:lonetiger@gmail.com" target="_blank"><span lang=EN-US dir=LTR style='font-family:"Calibri",sans-serif'>lonetiger@gmail.com</span></a>‏>:</span></p></div></div><div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><p class=MsoNormal>Hi, <span lang=AR-SA dir=RTL style='font-family:"Times New Roman",serif'><o:p></o:p></span></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I assume CreateDebuggedProcess is defined in bindings.lib? You need to also add extra-libraries: bindings </p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>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. </p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>nm -g bindings.lib would show the actual name. </p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Tamar. </p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><div><div><p class=MsoNormal>On Tue, Sep 11, 2018, 07:51 Yotam Ohad <<a href="mailto:yotam2206@gmail.com" target="_blank">yotam2206@gmail.com</a>> wrote:</p></div></div></div><div><div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p class=MsoNormal>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 </p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>What am I doing wrong?</p></div><div><p class=MsoNormal>Yotam</p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div></blockquote></div></div></blockquote></div></blockquote></div><p class=MsoNormal style='margin-left:.2in'>_______________________________________________<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" 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.</p><p class=MsoNormal><o:p> </o:p></p></div></body></html>