You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GnuCOBOL调用Rust报错:libcob: error: module not found

GnuCOBOL调用Rust动态库时找不到模块的问题

我尝试按照Brian Tiffin的GnuCOBOL FAQ中「Can GnuCOBOL interface with Rust?」的首个示例,用GnuCOBOL调用Rust代码,但运行时出错。

预期执行结果

$ make -B
rustc --crate-type=dylib called.rs
LD_RUN_PATH=. cobc -xj caller.cob -L. -lcalled
:Hello, world:

实际执行结果

$ make -B
rustc --crate-type=dylib called.rs
LD_RUN_PATH=. cobc -xj caller.cob -L. -lcalled
libcob: error: module 'hello_rust' not found
make: *** [makefile:5: caller] Error 1

直接通过命令行编译两个文件后执行./caller,仍出现相同错误。

对照cobc手册页、GnuCOBOL手册的链接章节及Rust参考文档检查,语法无问题。已尝试按照GnuCOBOL手册设置./caller COB_LIBRARY_PATH=.,但无效果。Rust源码已成功编译为库,但COBOL无法找到该模块。

使用cobcrun caller执行时,显示libcob: error: module 'caller' not found。

参考过两个类似错误的问题:其一为多个COBOL源文件静态链接问题(该场景可正常工作),其二涉及X"AF"语法问题(本次未使用该写法)。另外,Jay Moseley的「C Wrapper for Calling Library Function」示例静态链接C源码可正常运行,但Rust暂不支持静态链接。

使用的软件版本

  • Ubuntu 22.04.1 LTS
  • cobc (GnuCOBOL) 3.1.2.0
  • rustc 1.64.0

内容的提问来源于stack exchange,提问作者Joseph E

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 20:21:10