<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><font face="Courier New" class="">I've been trying to get the example in</font></div><div class=""><font face="Courier New" class=""><a href="https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ffi-chap.html?highlight=foreign#using-foreign-export-and-foreign-import-ccall-wrapper-with-ghc" class="">https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/ffi-chap.html?highlight=foreign#using-foreign-export-and-foreign-import-ccall-wrapper-with-ghc</a></font></div><div class=""><font face="Courier New" class="">working.</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">I have a cabal file</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">name: test-via-c</font></div><div class=""><font face="Courier New" class="">version: 0.1.0.0</font></div><div class=""><font face="Courier New" class="">homepage: TBD</font></div><div class=""><font face="Courier New" class="">license: MIT</font></div><div class=""><font face="Courier New" class="">author: Dominic Steinitz</font></div><div class=""><font face="Courier New" class="">maintainer: <a href="mailto:idontgetoutmuch@gmail.com" class="">idontgetoutmuch@gmail.com</a></font></div><div class=""><font face="Courier New" class="">category: System</font></div><div class=""><font face="Courier New" class="">build-type: Simple</font></div><div class=""><font face="Courier New" class="">cabal-version: >=1.10</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">executable Foo.dylib</font></div><div class=""><font face="Courier New" class=""> main-is: Foo.hs</font></div><div class=""><font face="Courier New" class=""> other-extensions: ForeignFunctionInterface</font></div><div class=""><font face="Courier New" class=""> build-depends: base >=4.7 && <4.10,</font></div><div class=""><font face="Courier New" class=""> primitive >=0.6 && <0.7</font></div><div class=""><font face="Courier New" class=""> hs-source-dirs: src</font></div><div class=""><font face="Courier New" class=""> default-language: Haskell2010</font></div><div class=""><font face="Courier New" class=""> include-dirs: src</font></div><div class=""><font face="Courier New" class=""> ghc-options: -O2 -shared -fPIC -dynamic</font></div><div class=""><font face="Courier New" class=""> extra-libraries: HSrts-ghc8.0.1</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">which installs</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">/Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin/Foo.dylib</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">I then compile the C with</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">gcc-6 Bar.c</font></div><div class=""><font face="Courier New" class="">/Users/dom/Library/Haskell/ghc-8.0.1/lib/test-via-c-0.1.0.0/bin/Foo.dylib</font></div><div class=""><font face="Courier New" class="">-I/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/include</font></div><div class=""><font face="Courier New" class="">-L/Library/Frameworks/GHC.framework/Versions/8.0.1-x86_64/usr/lib/ghc-8.0.1/rts</font></div><div class=""><font face="Courier New" class="">-lHSrts-ghc8.0.1</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">Sadly when I try to run the executable I get</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">~/Dropbox/Private/TestU01-1.2.3/examples/src $ ./a.out</font></div><div class=""><font face="Courier New" class="">dyld: Library not loaded: @rpath/Foo.dylib</font></div><div class=""><font face="Courier New" class=""> Referenced from: /Users/dom/Dropbox/Private/TestU01-1.2.3/examples/src/./a.out</font></div><div class=""><font face="Courier New" class=""> Reason: image not found</font></div><div class=""><font face="Courier New" class="">Trace/BPT trap: 5</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">I am guessing the executable is looking for the dynamic library. I</font></div><div class=""><font face="Courier New" class="">copied Foo.dylib to the current directory but still get the same</font></div><div class=""><font face="Courier New" class="">error.</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><font face="Courier New" class="">I know this is really an OS X question but I am hoping someone who has</font></div><div class=""><font face="Courier New" class="">done before will be able to help.</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class="">
<div class="">Dominic Steinitz</div><div class=""><a href="mailto:dominic@steinitz.org" class="">dominic@steinitz.org</a></div><div class=""><a href="http://idontgetoutmuch.wordpress.com" class="">http://idontgetoutmuch.wordpress.com</a></div>
</div>
<br class=""></body></html>