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?
That's not the question that is in the title, so answering that first.
Can you do it from Ubuntu?
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.
cobc
/libcob
working in this environment./configure --host=i686-w64-mingw32
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).
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?
That's the "long question". Yes, and very easy.
When you do have a Windows environment and want to generate an executable for that - no need for doing this in a separate VM (or WSL) in the first place, just get the official ready-to-use MinGW packages for GnuCOBOL (available for both 32 and 64bit) and compile directly on the Windows machine.