OS2 World Community Forum

OS/2, eCS & ArcaOS - Technical => Programming => Topic started by: KO Myung-Hun on February 15, 2026, 06:29:44 pm

Title: cross-os2emx
Post by: KO Myung-Hun on February 15, 2026, 06:29:44 pm
Hi/2.

Here is the cross compiler for OS/2 on x86_64 Linux.

This consists of the three parts.

1. binutils v2.33.1
2. LIBCn v0.1.14
3. gcc/g++ v9.2.0

This provides the following:

1. binutils + emxexp, emximp, emxbind and OS/2 ld.
2. static libgcc.a
3. ability to build .EXEs and .DLLs with the ld linker which supports a.out object files only

This does *NOT* provide the following:

1. emxomf* family
2. shared libgcc_so_d.a(Currently, this is the symbolic link to libgcc.a)
3. ability to build .EXEs and .DLLs with the OMF linkers which supports OMF object files

How to use:

1. Download the following file:
    https://www.os2.kr/komh/testcase/os2emx-cross-toolchain-test.tar.xz

2. Extract files from it with `tar xvJf ' to some dir
3. Files are in some_dir/opt/os2emx/
4. Prepend some_dir/opt/os2emx/bin to your $PATH like:
  export PATH=/path/to/your/opt/os2emx:$PATH
5. Now, you can cross-compile C/C++ sources with i686-pc-os2-emx-gcc/g++

Report your experiences, please...

Thanks!

KO Myung-Hun
Title: Re: Please test os2emx-cross-toolchain
Post by: Martin Iturbide on February 16, 2026, 11:45:40 pm
Hello

Sorry if don't understand this. Is the idea is that with this set of tools you can compile software for OS2 from a Linux machine?
Is the benefit of this to overcome some limitation we are getting on OS/2 to compile complex software?

Regards
Title: Re: Please test os2emx-cross-toolchain
Post by: Mentore on February 19, 2026, 09:08:04 am
Hello

Sorry if don't understand this. Is the idea is that with this set of tools you can compile software for OS2 from a Linux machine?
Is the benefit of this to overcome some limitation we are getting on OS/2 to compile complex software?

Regards

Hi Martin.
Cross compiling can be a great help when you have to compile really big projects, where an OS/2 machine can fail due to resource exhaustion.

Currently I don't have a linux machine at home with which to try this, but I'm eager to follow these experiments and maybe I'll try ASAP to do something.
But for now, onto some ports I still have to test.

Mentore
Title: Re: Please test os2emx-cross-toolchain
Post by: Jochen Schäfer on February 19, 2026, 09:25:49 am
Yes, it is this. I have to build the Dosbox-X cores one at a time, because even building two in parallel would result in constant out of memory compiler crashes. The rest of Dosbox-X is then build in parallel.
Title: Re: Please test os2emx-cross-toolchain
Post by: KO Myung-Hun on February 19, 2026, 07:32:14 pm
Hi/2.

Here is the second test version:

https://www.os2.kr/komh/testcase/os2emx-cross-toolchain-test2.tar.xz

Added support of emxomf tools such as emxomf, emxomfar, emxomfld, emxomfstrip, listomf and stripomf.
Added support of -Zomf option with watcom tools such as wlink and wrc.
Fixed directory hierachy problem.

KO Myung-Hun
Title: Re: Please test os2emx-cross-toolchain
Post by: KO Myung-Hun on February 19, 2026, 07:36:05 pm
@Martin: As Mentore and Jochen said, it's possible to overcome 4GB memory problem of 32-bit OS/2 with this cross compiler, and to utilize various development environments of Linux.
Title: Re: Please test os2emx-cross-toolchain
Post by: Dave Yeo on February 20, 2026, 12:15:59 am
Downloaded the latest tar.xv and untarred it under ~ Trying simple commands fail,
Code: [Select]
dave@dave-ThinkCentre-M910s:~$ export PATH=~/opt/os2emx/bin:$PATH
dave@dave-ThinkCentre-M910s:~$ i686-pc-os2-emx-gcc --version
bash: /home/dave/opt/os2emx/bin/i686-pc-os2-emx-gcc: cannot execute binary file: Exec format error
dave@dave-ThinkCentre-M910s:~$ i686-pc-os2-emx-g++ --version
bash: /home/dave/opt/os2emx/bin/i686-pc-os2-emx-g++: cannot execute binary file: Exec format error
dave@dave-ThinkCentre-M910s:~$ echo $PATH
/home/dave/opt/os2emx/bin:/home/dave/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
ls -la does show the files with the x bit set.

Edit: This is current Linux Mint
Edit2:
Code: [Select]
dave@dave-ThinkCentre-M910s:~/opt/os2emx/bin$ file i686-pc-os2-emx-gcc
i686-pc-os2-emx-gcc: POSIX tar archive (GNU)
and looking at the file, it does look like the exe tarred with ustar by komh.
I'll try different untar commands and/or installing ustar
Title: Re: Please test os2emx-cross-toolchain
Post by: Dave Yeo on February 20, 2026, 01:02:44 am
OK, seems mc screwed up the untar. Running from the command line seems to have properly worked.
Now seems I have the wrong libiconv
Code: [Select]
dave@dave-ThinkCentre-M910s:~$ i686-pc-os2-emx-g++ --version
i686-pc-os2-emx-g++: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
And I don't seem to have iconv installed,
Code: [Select]
dave@dave-ThinkCentre-M910s:~$ sudo apt install iconv
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package iconv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'iconv' has no installation candidate
Title: Re: Please test os2emx-cross-toolchain
Post by: Dave Yeo on February 20, 2026, 01:36:23 am
OK, got pissed off chasing a libiconv package so downloaded the source and installed it in /usr/local, remembered to run sudo ldconfig and,
Code: [Select]
dave@dave-ThinkCentre-M910s:~$ i686-pc-os2-emx-g++ --version
i686-pc-os2-emx-g++ (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Have to play with it later and look up cross-compiling.

Edit: Now I get,
Code: [Select]
/home/dave/opt/os2emx/bin/../libexec/gcc/i686-pc-os2-emx/9/cc1: error while loading shared libraries: libmpfr.so.4: cannot open shared object file: No such file or directory

Looks like libmpfr.so.4 is old and no package available. Have to build version 3 by the looks of it. Current is 4.2.2
Edit2: Ok, built a simple C program using configure and it runs on OS/2, both with -Zomf and without.
Test G++ next.
BTW, used,
Code: [Select]
export CC=i686-pc-os2-emx-gcc
./configure --host=i686-pc-os2-emx --build=x86_64-linux-gnu LDFLAGS=-Zomf
Edit3: g++ also worked fine.
Title: Re: Please test os2emx-cross-toolchain
Post by: KO Myung-Hun on February 21, 2026, 03:05:33 pm
@Dave:
Good to hear that!

Usually, --host is enough. setting CC and --build option are not necessary.

And for other people, here are the missing files which you said:

libiconv: https://www.os2.kr/komh/testcase/os2emx-cross-toolchain-libiconv.tar.gz
libmpfr: https://www.os2.kr/komh/testcase/os2emx-cross-toolchain-libmpfr.tar.gz

Extract the above files to any dir listed in your LD_LIBRARY_PATH.

Thanks!
Title: Re: Please test os2emx-cross-toolchain
Post by: Ian B Manners on February 22, 2026, 11:57:14 am
Hi Myung-Hun,

Thank you very much for this, it is ideal for me as I do most of my stuff under Ubuntu now, with OS/2 in a VirtualPC.
Will set it up and give it a try over the next week.
Title: Re: Please test os2emx-cross-toolchain
Post by: Neil Waldhauer on February 22, 2026, 03:15:42 pm
Hi Myung-Hun,

Thank you very much for this, it is ideal for me as I do most of my stuff under Ubuntu now, with OS/2 in a VirtualPC.
Will set it up and give it a try over the next week.

If you get a chance, try to build PMMail with this environment.
Title: Re: Please test os2emx-cross-toolchain
Post by: KO Myung-Hun on February 22, 2026, 04:41:49 pm
Hi/2.

Released at github: https://github.com/komh/cross-os2emx

You can build by yourself.

And here is Beta 1:

https://github.com/komh/cross-os2emx/releases/download/b1/os2emx-cross-toolchain-b1.tar.gz

If there are missing files, visit https://github.com/komh/cross-os2emx/issues/2.

Thanks!
Title: Re: cross-os2emx
Post by: KO Myung-Hun on March 15, 2026, 03:14:32 pm
Hi/2.

Here is cross-os2emx v1.0.0:

https://github.com/komh/cross-os2emx/releases/download/1.0.0/cross-os2emx-1.0.0.tar.gz

Thanks!
Title: Re: cross-os2emx
Post by: JTA on March 15, 2026, 05:58:18 pm
KO ... thanks for this emx effort!

If I may further impose upon you, how hard would it be to provide some details of your compiler/dev environment (and I assume you are running OS/2 on physical machine(s))? If such a thread exists, can you point me at it?

I would like to replicate your build environment in a VM, under my AToF scheme, and see if I can push compiling limits further away from causing us grief (VAL = xxxx, for example). I see these limits in other threads, and it seems like we can push past them with virtualization, with multiple os/2 vm's, and so on ... it just needs to be detailed out for new devs, I would think.

Is it possible for you to document your dev environment for us?

Again, thanks so much for all that you do for OS/2!
Title: Re: cross-os2emx
Post by: David McKenna on March 15, 2026, 10:18:04 pm
 I'm not a programmer, but this seems like a major accomplishment to make building complex apps for OS/2 (or any apps) faster and even possible because of the larger memory available. Thanks Mr. Ko! One thing I wonder: does this also mean that any dependencies a program needs to be built do not need to be first be ported to OS/2? For example, QTWebEngine needs node.js to be built. Would you just use the node.js in Linux and this new tool will output OS/2 binaries using that, or do all dependencies still need to be converted to OS/2 first.

Regards,
Title: Re: cross-os2emx
Post by: Dave Yeo on March 15, 2026, 11:48:08 pm
Hi David. As far as I can see, it is going to depend on whether OS/2 specific features are needed. eg, Python or Perl would generally work but our ports have OS/2 stuff that a Linux build wouldn't have. Generally they could be added.
Don't know node.js but it might just work. I'm planning on trying to build Qt5 on Linux and see how far it gets.
Really, eventually we need an OS/2 node.js anyways as a bunch of stuff uses it.
There will be other OS/2 stuff that needs rebuilding on Linux, tried FFmpeg and the stock build died from no lxlite.
Rexx is another consideration, thinking of trying to build FF for a test, there's a REXX script where the build would have to be adjusted to use the sh version and I think a couple of batch files that might need converting. It also depends on Lxlite during the packaging step. Need to see if there's a Linux Pascal that will build a Linux lxlite.
Title: Re: cross-os2emx
Post by: David McKenna on March 16, 2026, 12:26:33 am
 Hey Dave,

  OK, so it might help with dependencies - great! I thought lxlite was not necessary, just a convenience, but maybe I'm wrong? I seem to remember Paul building stuff without it - just made the binaries bigger. Couldn't that be done inside OS/2 after the build?

Regards,
Title: Re: cross-os2emx
Post by: Dave Yeo on March 16, 2026, 03:03:57 am
Yes, it is easy enough not to use lxlite, just some makefile editing, and there's omfstrip or whatever it is called. Same with other things like REXX scripts, which might need porting to sh scripts or install Regina Rexx, which would still need minor makefile editing. Rexx.cmd becomes rexx.rx.
Need to differentiate between native and cross compiling some how to have some if else logic.
Title: Re: Please test os2emx-cross-toolchain
Post by: Dave Yeo on March 18, 2026, 05:33:52 am
Hi Myung-Hun,

Thank you very much for this, it is ideal for me as I do most of my stuff under Ubuntu now, with OS/2 in a VirtualPC.
Will set it up and give it a try over the next week.

If you get a chance, try to build PMMail with this environment.

Where is the source?
Title: Re: cross-os2emx
Post by: Dave Yeo on March 18, 2026, 06:05:25 am
Running ./cmake --version results in,
Code: [Select]
dave@dave-ThinkCentre-M910s:~/opt/os2emx/bin$ cmake --version
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/home/dave/opt/os2emx/share/cmake-3.28
cmake version 3.28.3

CMake suite maintained and supported by Kitware (kitware.com/cmake).

And sure enough, there is only ~/opt/os2emx/share/cmake-3.31, along with sibling cmake directory.
Title: Re: cross-os2emx
Post by: Dave Yeo on March 18, 2026, 06:18:37 am
Docview perhaps should be added to cross-os2emx to view inf files. Can you test if it works on your dist.
Title: Re: cross-os2emx
Post by: KO Myung-Hun on March 20, 2026, 12:28:48 am
Hi/2.

It's hard to connect to this forum :(

@JTA:
I recommend to use rpm/yum to set up build environment. For my build environment, you can read my blog, https://lvzuufx.blogspot.com/search?q=%22porting+to+os%2F2%22.

@David:
As Dave said, it's ok to use programs as is unless they behave differently for OS/2.

@Dave:
For lxlite, I know, lxlite has been built by Virtual Pascal which supports Linux output. So, it's possible to build lxlite for Linux.

For cmake, I don't understand the situation. Where does cmake-3.28 come from? When using cross-os2emx, prepend /path/to/opt/os2emx/bin to $PATH, please.

For docview, it has many dependencies out of my control. So it would be better to distribute it separately. But, it's good to be able to see .inf on Linux.

Thanks!