[Fwd: Re: Foreign import]

Gustavo Villavicencio gustavov at ucse.edu.ar
Wed Mar 5 16:18:04 EST 2003

I have continued reading the bibliography on ffi but I
cannot find the solution. Please, can anyone help me?.

-------- Original Message --------
Subject: Re: Foreign import
From: "Gustavo Villavicencio" <gustavov at ucse.edu.ar>
Date: Tue, March 4, 2003 8:35 pm
To: <chak at cse.unsw.edu.au>

Thanks Manuel

The error message is as follows

CallIncr.o: In function `sWM_entry':
CallIncr.o:(.text+0xc5): undefined reference to `incr'
collect2: ld returned 1 exit status

where 'incr' is a toy function defined in 'mylib.h'.
Obviously, in the foreign declaration I have changed
'myfun' by 'incr'.
The compilation command is the typical

ghc -ffi -c CallIncr.hs

followed by

ghc -ffi CallIncr.o

which generate the previous error.
Thanks again,

Manuel M T Chakravarty said:
> "Gustavo Villavicencio" <gustavov at ucse.edu.ar> wrote,
>> I'm a new ffi user and I have some problems with foreign import
>> declaration. I'm don't have any problem to access C standard
>> functions. However, I cannot access to my own functions in mylib.h by
>> means of
>> foreign import "mylib.h myfun" hmyfun :: ...
>> May be I'm omitting some compilation step or parameter also, since
>> I'm applying the same compilation process to call C standard
>> functions.
>> I'm working with ghc 5.04 on SuSe Linux 7.0.
> You should say what goes wrong.  Eg, paste the error
> messages of the compiler and/or linker into your email.
> Manuel

More information about the FFI mailing list