
Hello, I'm using the following cabal file to build a shared library with ghc: Build-Type: Simple Executable libmylibrary.dll If os(windows) CPP-Options: -DWIN32 Extensions: ForeignFunctionInterface Build-Depends: ... Main-Is: libmylibrary.hs Ghc-Options: -W --make -no-hs-main -optl-shared -optl-s -O2 The resulting library is called from a C++ graphical user interface (using Qt), which worked great so far on Windows and Linux. However, the compilation fails on MacOS X: Undefined symbols: "_ZCMain_main_closure", referenced from: _ZCMain_main_closure$non_lazy_ptr in libHSrts.a(Main.o) "___stginit_ZCMain", referenced from: ___stginit_ZCMain$non_lazy_ptr in libHSrts.a(Main.o) ld: symbol(s) not found collect2: ld returned 1 exit status I don't know much about shared libraries, even less about them on MacOS X :( Any idea ? Jean-Denis Koeck

According to the manual, I have to use the -shared flag to compile a
library.
But I get the following error:
link: GHC not built to link this way: LinkDynLib
Guess I have to recompile ghc !
2010/1/3 Jean-Denis Koeck
Hello, I'm using the following cabal file to build a shared library with ghc:
Build-Type: Simple Executable libmylibrary.dll If os(windows) CPP-Options: -DWIN32 Extensions: ForeignFunctionInterface Build-Depends: ... Main-Is: libmylibrary.hs Ghc-Options: -W --make -no-hs-main -optl-shared -optl-s -O2
The resulting library is called from a C++ graphical user interface (using Qt), which worked great so far on Windows and Linux.
However, the compilation fails on MacOS X:
Undefined symbols: "_ZCMain_main_closure", referenced from: _ZCMain_main_closure$non_lazy_ptr in libHSrts.a(Main.o) "___stginit_ZCMain", referenced from: ___stginit_ZCMain$non_lazy_ptr in libHSrts.a(Main.o) ld: symbol(s) not found collect2: ld returned 1 exit status
I don't know much about shared libraries, even less about them on MacOS X :( Any idea ?
Jean-Denis Koeck

On Jan 3, 2010, at 09:28 , Jean-Denis Koeck wrote:
I'm using the following cabal file to build a shared library with ghc:
I don't know if any released GHC knows how to do that yet. In any case it's still experimental. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

If I recall correctly, dynamic linking/shared library support is not
yet available for OSX, as the Industrial Haskell Group does not have
any knowledge of OSX (but is willing to pay someone who does to do the
work).
2010/1/4 Jean-Denis Koeck
Hello, I'm using the following cabal file to build a shared library with ghc:
Build-Type: Simple Executable libmylibrary.dll If os(windows) CPP-Options: -DWIN32 Extensions: ForeignFunctionInterface Build-Depends: ... Main-Is: libmylibrary.hs Ghc-Options: -W --make -no-hs-main -optl-shared -optl-s -O2
The resulting library is called from a C++ graphical user interface (using Qt), which worked great so far on Windows and Linux.
However, the compilation fails on MacOS X:
Undefined symbols: "_ZCMain_main_closure", referenced from: _ZCMain_main_closure$non_lazy_ptr in libHSrts.a(Main.o) "___stginit_ZCMain", referenced from: ___stginit_ZCMain$non_lazy_ptr in libHSrts.a(Main.o) ld: symbol(s) not found collect2: ld returned 1 exit status
I don't know much about shared libraries, even less about them on MacOS X :( Any idea ?
Jean-Denis Koeck
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Joan Crawford - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend." - http://www.brainyquote.com/quotes/authors/j/joan_crawford.html

I'm not sure if it is of any help, but at the haskell-wiki there's an article about how to communicate between Haskell and Objective-C using XCode: http://haskell.org/haskellwiki/Using_Haskell_in_an_Xcode_Cocoa_project -chris On 4 jan 2010, at 00:36, Ivan Miljenovic wrote:
If I recall correctly, dynamic linking/shared library support is not yet available for OSX, as the Industrial Haskell Group does not have any knowledge of OSX (but is willing to pay someone who does to do the work).
2010/1/4 Jean-Denis Koeck
: Hello, I'm using the following cabal file to build a shared library with ghc:
Build-Type: Simple Executable libmylibrary.dll If os(windows) CPP-Options: -DWIN32 Extensions: ForeignFunctionInterface Build-Depends: ... Main-Is: libmylibrary.hs Ghc-Options: -W --make -no-hs-main -optl-shared -optl-s -O2
The resulting library is called from a C++ graphical user interface (using Qt), which worked great so far on Windows and Linux.
However, the compilation fails on MacOS X:
Undefined symbols: "_ZCMain_main_closure", referenced from: _ZCMain_main_closure$non_lazy_ptr in libHSrts.a(Main.o) "___stginit_ZCMain", referenced from: ___stginit_ZCMain$non_lazy_ptr in libHSrts.a(Main.o) ld: symbol(s) not found collect2: ld returned 1 exit status
I don't know much about shared libraries, even less about them on MacOS X :( Any idea ?
Jean-Denis Koeck
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Joan Crawford - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend." - http://www.brainyquote.com/quotes/authors/j/joan_crawford.html _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

There's a patch for it in GHC HEAD by Stephen Blackheath and me, and
an accompanying patch for Cabal.
http://hackage.haskell.org/trac/ghc/ticket/3550
http://hackage.haskell.org/trac/hackage/ticket/591
has the details.
mark
On Mon, Jan 4, 2010 at 10:36 AM, Ivan Miljenovic
If I recall correctly, dynamic linking/shared library support is not yet available for OSX, as the Industrial Haskell Group does not have any knowledge of OSX (but is willing to pay someone who does to do the work).
2010/1/4 Jean-Denis Koeck
: Hello, I'm using the following cabal file to build a shared library with ghc:
Build-Type: Simple Executable libmylibrary.dll If os(windows) CPP-Options: -DWIN32 Extensions: ForeignFunctionInterface Build-Depends: ... Main-Is: libmylibrary.hs Ghc-Options: -W --make -no-hs-main -optl-shared -optl-s -O2
The resulting library is called from a C++ graphical user interface (using Qt), which worked great so far on Windows and Linux.
However, the compilation fails on MacOS X:
Undefined symbols: "_ZCMain_main_closure", referenced from: _ZCMain_main_closure$non_lazy_ptr in libHSrts.a(Main.o) "___stginit_ZCMain", referenced from: ___stginit_ZCMain$non_lazy_ptr in libHSrts.a(Main.o) ld: symbol(s) not found collect2: ld returned 1 exit status
I don't know much about shared libraries, even less about them on MacOS X :( Any idea ?
Jean-Denis Koeck
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com Joan Crawford - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend." - http://www.brainyquote.com/quotes/authors/j/joan_crawford.html _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- A UNIX signature isn't a return address, it's the ASCII equivalent of a black velvet clown painting. It's a rectangle of carets surrounding a quote from a literary giant of weeniedom like Heinlein or Dr. Who. -- Chris Maeda
participants (5)
-
Brandon S. Allbery KF8NH
-
Chris Eidhof
-
Ivan Miljenovic
-
Jean-Denis Koeck
-
Mark Wotton