我试图将 hello.cob 编译为 hello.c:
$ ls
hello.cob
$ cobc -x -C hello.cob
$ ls
hello.c hello.c.h hello.c.l.h hello.cob
但clang
未能将 hello.c 编译为可执行文件:
$ clang hello.c
/tmp/hello-479acf.o: In function `main':
hello.c:(.text+0x1e): undefined reference to `cob_init'
hello.c:(.text+0x2a): undefined reference to `cob_stop_run'
/tmp/hello-479acf.o: In function `sampleCOBOL_':
hello.c:(.text+0x98): undefined reference to `cob_module_global_enter'
hello.c:(.text+0x133): undefined reference to `cob_display'
hello.c:(.text+0x13f): undefined reference to `cob_stop_run'
hello.c:(.text+0x15a): undefined reference to `cob_check_version'
hello.c:(.text+0x33d): undefined reference to `cob_set_cancel'
hello.c:(.text+0x38e): undefined reference to `cob_fatal_error'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这是hello.cob(可以编译cobc -x hello.cob
):
IDENTIFICATION DIVISION.
PROGRAM-ID. sampleCOBOL.
PROCEDURE DIVISION.
DISPLAY "Hello World!".
STOP RUN.