<div dir="ltr"><div><div><div>Hi all,</div><div><br></div><div>I fear I might be unaware of something I should be.  Say I have a file objc_util.m with the following contents:</div><div><br></div><div>    #include <Foundation/Foundation.h></div><div><br></div><div>    void ns_log(const char *s) {</div><div>      NSString *str = [NSString stringWithUTF8String:s];</div><div>      NSLog(@"%@", str);</div><div>    }</div><div><br></div><div>I also have a file Main.hs with contents:</div><div><br></div><div>    {-# LANGUAGE ForeignFunctionInterface #-}</div><div>    module Main where</div><div><br></div><div>    import Foreign.C.Types</div><div>    import Foreign.C.String</div><div><br></div><div>    foreign import ccall "ns_log" cNSLog :: CString -> IO ()</div><div><br></div><div>    nsLog s = withCString s cNSLog</div><div><br></div><div>I compile objc_util.m with:</div><div><br></div><div>    gcc -c objc_util.m</div><div><br></div><div>And then I try to open it up in GHCi.</div><div><br></div><div>    ghci objc_util.o Main.hs -framework Foundation</div><div><br></div><div>I add the flag '-frame Foundation' in the hopes that symbols in objc_util.o will get resolved</div><div>dynamically.</div><div><br></div><div>However I get:</div><div><br></div><div>    GHCi, version 7.8.3: <a href="http://www.haskell.org/ghc/">http://www.haskell.org/ghc/</a>  :? for help</div><div>    Loading package ghc-prim ... linking ... done.</div><div>    Loading package integer-gmp ... linking ... done.</div><div>    Loading package base ... linking ... done.</div><div>    Loading object (static) objc_util.o ... ghc: panic! (the 'impossible' happened)</div><div>      (GHC version 7.8.3 for x86_64-apple-darwin):</div><div>      Loading temp shared object failed: dlopen(/var/folders/pv/pfxcyy117v31vt6lsshtgr_w0000gn/T/ghc33546_0/ghc33546_1.dylib, 9):     Symbol not found: _OBJC_CLASS_$_NSString</div><div>      Referenced from: /var/folders/pv/pfxcyy1    17v31vt6lsshtgr_w0000gn/T/ghc33546_0/ghc33546_1.dylib</div><div>      Expected in: flat namespace</div><div>     in /var/folders/pv/pfxcyy117v31vt6lsshtgr_w0000gn/T/ghc33546_0/ghc33546_1.dylib</div><div><br></div><div>    Please report this as a GHC bug:  <a href="http://www.haskell.org/ghc/reportabug">http://www.haskell.org/ghc/reportabug</a></div><div><br></div><div>However, I have found a work around to this. If I do this:</div><div><br></div><div>    ln -s /System/Library/Frameworks/Foundation.framework/Foundation Foundation.o</div><div><br></div><div>and then run</div><div><br></div><div>    ghci Foundation.o objc_util.o Main.hs</div><div><br></div><div>I get this:</div><div><br></div><div>    GHCi, version 7.8.3: <a href="http://www.haskell.org/ghc/">http://www.haskell.org/ghc/</a>  :? for help</div><div>    Loading package ghc-prim ... linking ... done.</div><div>    Loading package integer-gmp ... linking ... done.</div><div>    Loading package base ... linking ... done.</div><div>    Loading object (static) Foundation.o ... done</div><div>    Loading object (static) objc_util.o ... done</div><div>    final link ... done</div><div><br></div><div>Everything has worked! And I can happily run 'nsLog' from GHCi and have it appear in the</div><div>'Console' app.</div><div><br></div><div>However, it doesn't seem like I should have to do this. Where am I going wrong?</div><div><br></div><div>Sean</div></div></div></div>