[英]ghc 7.6.3 not generating _stub.c and _stub.o
I'm learning how to make C++ call haskell code from a library, I was following instructions from FFI complete examples http://www.haskell.org/haskellwiki/FFI_complete_examples 我正在学习如何从库中调用C ++调用haskell代码,我按照FFI完整示例的说明进行操作http://www.haskell.org/haskellwiki/FFI_complete_examples
however, after 然而,之后
ghc -v Foo.hs
only Foo_stub.h
and Foo.o
are created, there's no Foo_stub.c
or Foo_stub.o
. 只有
Foo_stub.h
和Foo.o
创建,有没有Foo_stub.c
或Foo_stub.o
。 According to Calling Haskell from C , ghc > 7.2 doesn't generate _stub.o
anymore. 根据来自C的Calling Haskell ,ghc> 7.2不再生成
_stub.o
。
In this case do I still need a stub.o
to link an executable using g++ ? 在这种情况下,我还需要
stub.o
来使用g ++链接可执行文件吗?
At the moment after 此刻之后
g++ -o test Foo.o test.o `cat link_options`
I get lots of undefined symbols errors for hs_init
and the like. 我为
hs_init
等获取了许多未定义的符号错误。 Is it because _stub.o
is not present or something else missing? 是因为
_stub.o
不存在还是缺少其他东西?
I can link them correctly using ghc: 我可以使用ghc正确链接它们:
ghc -no-hs-main -o test test.o Foo.o -lstdc++
(after reading this question: Building a dynamic library with haskell and using it from C++ ) (阅读完这个问题后: 使用haskell构建动态库并使用C ++编写 )
but I wonder is it still possible to link using g++? 但我想知道是否仍然可以使用g ++进行链接?
You're looking at an out-of-date example (it's using ghc 6.12.3). 你正在看一个过时的例子(它使用的是ghc 6.12.3)。 This example works for 7.6.3:
此示例适用于7.6.3:
http://www.haskell.org/haskellwiki/GHC/Using_the_FFI http://www.haskell.org/haskellwiki/GHC/Using_the_FFI
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.