
Hello, I try to use the FFI, but it doesn't work. I write: int test (void) { return 2; } and compiled this. So I created a file named project.obj. Then I wrote a Lhs File named test.lhs
module Blah where
import Foreign.C.Types(CInt) foreign import ccall test :: CInt
blah = test
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? Thx Dominik

and compiled this. So I created a file named project.obj.
We normally use .o rather than .obj; I don't know if using .obj can cause any problems with ghc.
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?
Start GHCi with the following command line: ghci -fffi test.lhs project.o GHCi should just load the object file, and you shouldn't have a problem. Cheers, Wolfgang

Start GHCi with the following command line: ghci -fffi test.lhs project.o GHCi should just load the object file, and you shouldn't have a
problem. Well, I certainly red the GHC Documentation and so I tried all that things. Fortunately doest it work now. First I compiled the *.c file with Microsoft C++ 6.0 an took the projekt.obj file, but it doesn't work. After that I tried gcc, which created the projekt.o File and I got no errors. Dominik

You should compile the .c file using GHC itself. This guarantees that, under the hood, you are using the right version of gcc. I've never been able to get MS VC++ to work for compiling statically linked C source - but it works great for building DLLs that you can then reference from the Haskell .exe . Dominik Oesterreich wrote:
Start GHCi with the following command line: ghci -fffi test.lhs project.o GHCi should just load the object file, and you shouldn't have a
problem.
Well, I certainly red the GHC Documentation and so I tried all that things. Fortunately doest it work now. First I compiled the *.c file with Microsoft C++ 6.0 an took the projekt.obj file, but it doesn't work. After that I tried gcc, which created the projekt.o File and I got no errors.
Dominik
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
participants (3)
-
Dominik Oesterreich
-
Nick Main
-
Wolfgang Thaller