OpenCOBOL静态链接多个.cob文件

问题描述 投票:1回答:1

我试图使用GnuCobol(Windows 10)静态链接两个COBOL文件,遵循此处列出的示例:https://open-cobol.sourceforge.io/historical/open-cobol/Static-Linking.html但似乎无法使其工作。

我正在运行以下内容:

cobc -free -c InterpFunc.cob
cobc -free -c -fmain Integrator.cob 
cobc -x -o .\\dist\\integrator Integrator.o InterpFunc.o

'.o'文件正确编译,但二进制文件永远不会生成以下错误:

H:\Programs\COBAL\cobc\bin\cobc.exe: unrecognized option '-fmain'
h:/programs/cobal/cobc/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1

我尝试了一些不同的东西,比如省略'-fmain'或省略'-x',但似乎都会产生不同的错误。

这可能是我的编译器/系统设置的问题,还是我误解了如何静态链接文件?

windows compiler-errors compilation cobol gnucobol
1个回答
3
投票

我很确定你没有使用匹配旧文档的编译器(在其URL中有“历史”)。我很确定它会像current manual所说的那样工作:

组合多个文件的最简单方法是将它们编译为单个可执行文件。

一种方法是在一个命令中编译所有文件:

$ cobc -x -o prog main.cob subr1.cob subr2.cob

另一种方法是使用选项-c编译每个文件,并在最后链接它们。 >必须使用选项-x编译顶级程序。

$ cobc -c subr1.cob
$ cobc -c subr2.cob
$ cobc -c -x main.cob
$ cobc -x -o prog main.o subr1.o subr2.o
© www.soinside.com 2019 - 2024. All rights reserved.