Re: [Haskell-cafe] FFI link failing due to no main?

2009-08-27 Thread phil

I'm not really sure, but does the linking step really need to be given
the --make flag? I would try linking without that in the first
instance.


I think so - it's not just a link step, it does the following:

Compile:
CInterface.c - CInterface.o

Link:
CInterface.o HaskellFuncs_stub.o Hasnkell.Funcs.o - libCInterface.so


I'll take a look at the full -v output and see if that reveals anything.

Thanks,

Phil.


On 27 Aug 2009, at 04:38, Bernie Pope wrote:


Hi Phil,


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] FFI link failing due to no main?

2009-08-26 Thread phil

Thanks for the reply!

I think this might be a Mac OS X issue.  I've stripped my rather  
longwinded example down to the simplest case (one Haskell source file  
to create a single shared library containing a single exported  
function) and this compiles (and ultimately runs) fine on Linux.  So  
I'm either doing something wrong which shouldn't really work on Linux  
(and I'm getting lucky!)... or something screwy is happening on Mac  
version:


This exports a single function which is then #included in CInterface.c  
to create a new pure-C wrapper to the function.


ghc -O2 -c HaskellFuncs.hs
ghc -O2 -no-hs-main --make -optl '-shared' CInterface.c  
HaskellFuncs_stub.o HaskellFuncs.o -o libCInterface.so


One Mac OS X I get the following error - but it works fine on Ubuntu.   
I'm using 6.10.4 on both machines:


Linking libCInterface.so ...
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

Could anyone comment if I'm doing anything wrong, or is this a case of  
unsupported functionality on (PPC/Leopard) Mac OS X?  Has anyone  
succeeded in getting a similar example to work on Mac OS X?


I notice on Linux it is still very temperamental, if I play around  
with the arguments even slightly I get the same error there.



Cheers,

Phil.

On 26 Aug 2009, at 06:51, Yusaku Hashimoto wrote:


Missing -c option?

And -v option to see what's going on.

On Wed, Aug 26, 2009 at 10:37 AM, p...@beadling.co.uk wrote:

Hi,

After creating my stub objects etc using GHC, I'm trying to create  
a library
with a C interface to some Haskell functions.  I'm explicitly  
passing in

-no-hs-main yet the linker still fails due to missing main?

I'm sure I've had this working before with a slightly simpler  
example, but

can't work out what is wrong here.

If I give it a main (to humor it - it's not a solution), then it  
links and
produces an executable - so it looks to me like I'm not telling the  
linker

what I want correctly?

Any ideas?

Cheers,

Phil.


ghc -O2 --make -no-hs-main -package mtl   -package array -optl '- 
shared'

FFI/Octave/MyInterface.c FFI/Octave/OptionInterface_stub.o
FFI/Octave/OptionInterface.o ./FrameworkInterface.o ./Maths/Prime.o
./MonteCarlo/DataStructures.o ./MonteCarlo/European.o
./MonteCarlo/Framework.o ./MonteCarlo/Interface.o ./MonteCarlo/ 
Lookback.o

./Normal/Acklam.o ./Normal/BoxMuller.o ./Normal/Framework.o
./Normal/Interface.o ./Random/Framework.o ./Random/Halton.o
./Random/Interface.o ./Random/Ranq1.o   -o FFI/Octave/ 
libMyInterface.so

Linking FFI/Octave/libMyInterface.so ...
Undefined symbols:
 ___stginit_ZCMain, referenced from:
 ___stginit_ZCMain$non_lazy_ptr in libHSrts.a(Main.o)
 _ZCMain_main_closure, referenced from:
 _ZCMain_main_closure$non_lazy_ptr in libHSrts.a(Main.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe



___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] FFI link failing due to no main?

2009-08-25 Thread phil

Hi,

After creating my stub objects etc using GHC, I'm trying to create a  
library with a C interface to some Haskell functions.  I'm explicitly  
passing in -no-hs-main yet the linker still fails due to missing main?


I'm sure I've had this working before with a slightly simpler example,  
but can't work out what is wrong here.


If I give it a main (to humor it - it's not a solution), then it links  
and produces an executable - so it looks to me like I'm not telling  
the linker what I want correctly?


Any ideas?

Cheers,

Phil.


ghc -O2 --make -no-hs-main -package mtl   -package array -optl '- 
shared' FFI/Octave/MyInterface.c FFI/Octave/OptionInterface_stub.o FFI/ 
Octave/OptionInterface.o ./FrameworkInterface.o ./Maths/Prime.o ./ 
MonteCarlo/DataStructures.o ./MonteCarlo/European.o ./MonteCarlo/ 
Framework.o ./MonteCarlo/Interface.o ./MonteCarlo/Lookback.o ./Normal/ 
Acklam.o ./Normal/BoxMuller.o ./Normal/Framework.o ./Normal/ 
Interface.o ./Random/Framework.o ./Random/Halton.o ./Random/ 
Interface.o ./Random/Ranq1.o   -o FFI/Octave/libMyInterface.so

Linking FFI/Octave/libMyInterface.so ...
Undefined symbols:
  ___stginit_ZCMain, referenced from:
  ___stginit_ZCMain$non_lazy_ptr in libHSrts.a(Main.o)
  _ZCMain_main_closure, referenced from:
  _ZCMain_main_closure$non_lazy_ptr in libHSrts.a(Main.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe