aliens

Author Topic: Strange problem cross-compiling OXCE+ in Linux  (Read 178 times)

Offline Flaubert

  • Sergeant
  • **
  • Posts: 48
    • View Profile
Strange problem cross-compiling OXCE+ in Linux
« on: December 03, 2024, 11:11:12 pm »
Hello,
   I've tried crosscompiling OXCE+ under Linux-Ubuntu22.04 following instructions given here: https://openxcom.org/forum/index.php?topic=7048.0

I installed and built MXE -with minor issues; I've to include a #ifndef "guard" to mxe/usr/lib/gcc/x86_64-w64-mingw32.static/8.5.0/include/cpuid.h, to avoid including that header twice-

Then I followed instructions to build OXCE+:

git clone https://github.com/MeridianOXC/OpenXcom.git
cd OpenXcom
mkdir build
cd build
export PATH=/opt/mxe/usr/bin:$PATH
/opt/mxe/usr/bin/x86_64-w64-mingw32.static-cmake -DCMAKE_BUILD_TYPE=Release -DDEV_BUILD=OFF -DBUILD_PACKAGE=OFF ..
make -j4

And I got a lot of " fatal error: SDL.h: No such file or directory". It seems that x86_64-w64-mingw32.static-cmake considers a CMAKE_SYSTEM_NAME as Windows, and in the "recipe" at OXCE+ CMakeLists.txt, there are some parts "if ( WIN32 )" (l37) and if(NOT UNIX AND IS_DIRECTORY ${DEPS_DIR})" (l84), that cause building process look for yaml-cpp and SDL includes&libs inside of OpenXcom-oxce-plus/deps  -which is empty- instead of inside /opt/mxe/usr/x86_64-w64-mingw32.static/ where you can find them.
I managed to "fix" CMakeList.txt nullifying conflictive parts in CMakeLists.txt recipe -if ( WIN32 ) --> if ( 0 ) , if(NOT UNIX AND IS_DIRECTORY ${DEPS_DIR}) --> if(0) -
In this state, it correctly crosscompile and build OXCE+ either for x86_64-w64-mingw32.static (64bits EXE) or i686-w64-mingw32.static (32bits EXE).
But this is just a "dirty patch" and I would like to know what I'm doing wrong or what is failing in the process.

So if anyone (Meridian?) can give me some light about this, I'd be very grateful.

Thanks in advance
 
 



Online Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9124
    • View Profile
Re: Strange problem cross-compiling OXCE+ in Linux
« Reply #1 on: December 03, 2024, 11:39:35 pm »
1/
My instructions are from Stoddard.
They worked for me in Kubuntu 18.04, but I haven't done that in a long while.
Stoddard's farm is offline.

I may try again (and update instructions) in a newer Linux, but there's probably better options, see point 3/ below

2/
Yankes has set up a (temporary) replacement for Stoddard's farm and it's still running today, so the cmake stuff is (probably) not the (only) issue.
Maybe he can comment more.

3/
Pedroterzero has set up a build farm using MXE directly on github... running purely in cloud.
https://github.com/pedroterzero/oxce-xp
https://github.com/pedroterzero/oxce-xp/releases

I'd recommend reverse-engineering that and making a similar one for your build.
One day I'll do the same for official OXCE builds too.


PS: OXCE+ doesn't exist, please don't use that name

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3366
    • View Profile
Re: Strange problem cross-compiling OXCE+ in Linux
« Reply #2 on: December 04, 2024, 12:52:59 am »
I make different "fix", I simply delete this folder. Problem was  that couple of months ago SupSuper needed it to make github builds possible.
But as we see this break this cmake. Probably in some near future this script will be fixed and will not need workaraund like this.

Offline Flaubert

  • Sergeant
  • **
  • Posts: 48
    • View Profile
Re: Strange problem cross-compiling OXCE+ in Linux
« Reply #3 on: December 04, 2024, 10:41:06 am »
1/
My instructions are from Stoddard.
They worked for me in Kubuntu 18.04, but I haven't done that in a long while.
Stoddard's farm is offline.

I may try again (and update instructions) in a newer Linux, but there's probably better options, see point 3/ below

2/
Yankes has set up a (temporary) replacement for Stoddard's farm and it's still running today, so the cmake stuff is (probably) not the (only) issue.
Maybe he can comment more.

3/
Pedroterzero has set up a build farm using MXE directly on github... running purely in cloud.
https://github.com/pedroterzero/oxce-xp
https://github.com/pedroterzero/oxce-xp/releases

I'd recommend reverse-engineering that and making a similar one for your build.
One day I'll do the same for official OXCE builds too.


PS: OXCE+ doesn't exist, please don't use that name
Thanks for the advices! I will use OXCE from now on.

Offline Flaubert

  • Sergeant
  • **
  • Posts: 48
    • View Profile
Re: Strange problem cross-compiling OXCE+ in Linux
« Reply #4 on: December 04, 2024, 11:30:17 am »
I make different "fix", I simply delete this folder. Problem was  that couple of months ago SupSuper needed it to make github builds possible.
But as we see this break this cmake. Probably in some near future this script will be fixed and will not need workaraund like this.

I think a possible solution to the "recipe" at CMakeLists.txt could be:

(l37) if ( WIN32) ----> if ( WIN32 AND NOT CMAKE_CROSSCOMPILING)

and

(l86) If (NOT UNIX AND IS_DIRECTORY ${DEPS_DIR}) --> If (NOT UNIX AND NOT CMAKE_CROSSCOMPILING AND IS_DIRECTORY ${DEPS_DIR})

(of course, perhaps this could break a situation of cross compiling in windows to other OS, but this is not usual)
I tried the new recipe and it seems to work, at least for cross compiling 32&64 bits Windows EXEs, and also to obtain a Linux executable.