我想从 GnuCOBOL 调用 Rust。我已经复制了Can GnuCOBOL interface with Rust?中第一个示例的代码。来自 Brian Tiffin 的 GNUCobol FAQ 作为测试,但在运行时出现错误。
预期的:
$ make -B
rustc --crate-type=dylib called.rs
LD_RUN_PATH=. cobc -xj caller.cob -L. -lcalled
:Hello, world:
Run Code Online (Sandbox Code Playgroud)
实际的:
$ 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
Run Code Online (Sandbox Code Playgroud)
从命令行编译这两个文件然后使用$ ./caller.
根据手册页以及GnuCOBOL 手册和Rust 参考cobc的链接部分,语法似乎是正确的。我已经按照 GnuCOBOL 手册中的描述进行了尝试,但没有什么区别。Rust 源代码按预期编译为库,但 COBOL 找不到它。$ ./caller COB_LIBRARY_PATH=.
使用$ cobcrun caller …