简体   繁体   中英

Compiling a windows (.exe) executable file using gnu cobol on ubuntu

I need a program I wrote in a .cobc file to be compiled to a windows executable file. The file is called main.cobc
Compiling it with: cobc -x -free *.cobc -o main
makes it a linux executable which is ok, but can't be run directly on windows.
I have gnucobol (OpenCOBOL installed on my linux ubuntu VM.
Please help. Is there a way I could compile it in a way that it's windows compatible?

Thanks in advance!

Is there a way I could compile it [a COBOL source] in a way that it's windows compatible?

Yes, ...

as cobc uses an underlying C compiler and you can do cross-compiling with C compilers (you'll likely use gcc-mingw-w64-i686 or gcc-mingw-w64-x86-64 ).

... but it needs a lot of set-up.

  • install the cross-compiler environment
  • get all the dependencies for cobc / libcob working in this environment
  • build and install a second version of the GnuCOBOL package from source using ./configure --host=i686-w64-mingw32
  • compile your programs using the mingw version of cobc

This way you get a "main.exe" which you can use on a Windows computer as long as you ship the mingw dll, libcob dll (and the dll files of all its dependencies).

Instead of using the GNU compiler, perhaps try a different one. Microfocus has been a great Microsoft Cobol language implementation since the Workbench years. You have to pay for the Microfocus license but it is by far the most professional premium Cobol for PC in the world, superior to the likes of Realia, Microsoft Cobol, VisualAge Cobol, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM