到目前为止,我\xe2\x80\x99ve 还没有将 Haskell 库链接到 Rust 项目。我\xe2\x80\x99ve 有很多错误,最新的是recompile with -fPICfor ghc.
我\xe2\x80\x99已经设法获得动态链接\xe2\x80\x94的功能示例,但无法静态链接它。
\n现在附上我当前的设置:
\n构建.rs
\nfn main() {\n println!("cargo:rustc-link-search=native=deps");\n println!("cargo:rustc-link-lib=static=tesths");\n}\nRun Code Online (Sandbox Code Playgroud)\nsrc/main.rs
\nextern "C" {\n pub fn addTwo(x: i32) -> i32;\n pub fn init();\n pub fn fin();\n}\n\nfn main() {\n println!("Hello, world!");\n}\nRun Code Online (Sandbox Code Playgroud)\nsrc/haskell/Lib.hs
\nmodule Lib where\n\nimport Foreign.C.Types\n\naddTwo :: CInt -> CInt\naddTwo = (2 + )\n\nforeign export ccall addTwo :: CInt -> CInt\nRun Code Online (Sandbox Code Playgroud)\ncwrapper.c
\n#include <HsFFI.h>\n#ifdef __GLASGOW_HASKELL__\n#include "Lib_stub.h"\n#endif\n#include …Run Code Online (Sandbox Code Playgroud)