Using GHC and FFI

Bayley, Alistair Alistair_Bayley at ldn.invesco.com
Fri Jul 16 03:21:20 EDT 2004


> After that I wrote ghc -fffi -c test.lhs. But when I call 
> blah from ghci I get the error message: "test.o unknown symbol '_test'
> 
> I think ghc doen't link test.o to projekt.obj. What do I have to do? 


I don't know about linking object files I've created myself, but to link an
existing library (a .dll on my Windows system) I use these options:
  -L/path/to/library/file -lprojekt
-I/path/to/header/include/directory/if/it/exists

If the object file is in the same dir as test.lhs then you might get away
with just the -l option. Also, you might have to rename projekt.obj to
projekt.o (I don't know if this matters or not).


See GHC Users Guide "4.10.7. Options affecting linking", for -L and -l:
 
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#
OPTIONS-LINKER

And see "4.10.3 Options affecting the C pre-processor", for -I:
 
http://www.haskell.org/ghc/docs/latest/html/users_guide/options-phases.html#
C-PRE-PROCESSOR

I believe you only need to use -I if you're compiling via-c (which happens
if you use -O).

-----------------------------------------
*****************************************************************
Confidentiality Note: The information contained in this 
message, and any attachments, may contain confidential 
and/or privileged material. It is intended solely for the 
person(s) or entity to which it is addressed. Any review, 
retransmission, dissemination, or taking of any action in 
reliance upon this information by persons or entities other 
than the intended recipient(s) is prohibited. If you received
this in error, please contact the sender and delete the 
material from any computer.
*****************************************************************



More information about the Glasgow-haskell-users mailing list