Skip to content

Conversation

@brlin-tw
Copy link

@brlin-tw brlin-tw commented Jan 7, 2024

This patch series along with #2 fixes cross-building against the MinGW-w64 platform on a Ubuntu Linux system. For details, please take a look at the individual commit messages and this note.

Unfortunately, I don't have a Windows environment ATM to test on so please test it before merging.

…nsitivity

Currently when building wkbre on a case-sensitive operating/file system
CMake will emit the following warning:

```
-- Detecting CXX compile features - done
CMake Warning (dev) at CMakeLists.txt:4 (add_subdirectory):
  The source directory

    wkbre/bzip2

  does not contain a CMakeLists.txt file.

  CMake does not support this case but it used to work accidentally and is
  being allowed for compatibility.

  Policy CMP0014 is not set: Input directories must have CMakeLists.txt.  Run
  "cmake --help-policy CMP0014" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done (0.3s)
```

This is probably due to the fact that the /bzip/CMakeLists.TXT file
not named as "CMakeLists.txt" as required by the CMake documentation[1]
, while it still work as expected on Windows due to files being accessed
case-insensitively this won't work on case-sensitive operating/file
systems like GNU/Linux.

This patch fixes the problem by renaming the file without changing its content.

[1]: https://cmake.org/cmake/help/book/mastering-cmake/chapter/Writing%20CMakeLists%20Files.html

Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
…shes(preprocessor directives)

Currently cross-building on Linux will fail during compilation stage
with the following error message:

```
[ 13%] Building CXX object CMakeFiles/wkbre.dir/gameset/loadgameset.cpp.obj
wkbre/gameset/loadgameset.cpp:17:10: fatal error: ..\global.h: No such file or directory
   17 | #include "..\global.h"
      |          ^~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/wkbre.dir/build.make:594: CMakeFiles/wkbre.dir/gameset/loadgameset.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:100: CMakeFiles/wkbre.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
```

This is due to the backslash usage in the #include pre-processor
directives which is not compatible in Unix operating systems.  This
patch fixes the problem by replacing them with forward slashes which
should be compatible with both Windows and Linux platforms.

Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
…tivity(windows.h)

Currently cross-building on Linux will fail during compilation stage
with the following error message:

```
[ 35%] Building CXX object CMakeFiles/wkbre.dir/cursor.cpp.obj
In file included from wkbre/anim.cpp:17:
wkbre/global.h:27:10: fatal error: Windows.h: No such file or directory
   27 | #include <Windows.h>
      |          ^~~~~~~~~~~
compilation terminated.
```

This is due to the filename casing of the "Windows.h" header file which
is not accessible in the case-sensitive file/operating systems like
GNU/Linux.

This patch fixes the problem by replacing them with "windows.h" as it
seems to be the proper filename casing in the Windows platform[1] as
well as in MinGW[2].

[1]: https://en.wikibooks.org/wiki/Windows_Programming/windows.h
[2]: https://stackoverflow.com/questions/1549123/how-to-use-the-windows-api-in-mingw

Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
…tivity(OpenGL headers)

Currently cross-building on Linux will fail during compilation stage
with the following error message:

```
[ 16%] Building CXX object CMakeFiles/wkbre.dir/wkbre.cpp.obj
wkbre/renderer_ogl1.cpp:18:10: fatal error: gl/gl.h: No such file or directory
   18 | #include <gl/gl.h>
      |          ^~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/wkbre.dir/build.make:314: CMakeFiles/wkbre.dir/renderer_ogl1.cpp.obj] Error 1
```

This is due to the filename casing of the OpenGL header files which
is not accessible in the case-sensitive file/operating systems like
GNU/Linux.

This patch fixes the problem by using the upper-case GL header directory
as it seems to be the proper filename casing of the OpenGL headers.

Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
…shes(resources compiler)

Currently cross-building on Linux will fail with the following error
message:

```
[ 13%] Building RC object CMakeFiles/wkbre.dir/wkbre.rc.res
/usr/bin/x86_64-w64-mingw32-windres: can't open icon file `.\icon.ico': No such file or directory
make[2]: *** [CMakeFiles/wkbre.dir/build.make:873: CMakeFiles/wkbre.dir/wkbre.rc.res] Error 1
make[1]: *** [CMakeFiles/Makefile2:100: CMakeFiles/wkbre.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

```

This is due to the backslash usage in the resource compiler definition
file(wkbre.rc), which is not compatible with Unix-like operating systems.

This patch fixes the problem by replacing them with forward slashes which
should be compatible with both Windows and Linux platforms.

Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
@brlin-tw brlin-tw force-pushed the patch/fix-linux-build-incompatibilities branch from abbc4f9 to 26fbfbd Compare January 7, 2024 17:04
@brlin-tw brlin-tw changed the title Fix linux MinGW cross-build incompatibilities Fix Linux MinGW cross-build incompatibilities Jan 7, 2024
@AdrienTD
Copy link
Owner

AdrienTD commented Jan 7, 2024

Thank you for the pull request!

Indeed, I have only compiled it on Windows, hence why the backslashes and case issues.

Note that I no longer work on this project, since it is superseded by the newer one wkbre2, especially once I implement editing functionality in wkbre2 which it is currently lacking.

I might consider merging it, in case people would like to experiment it on Linux (though they still would have to use Wine to run it).

@brlin-tw
Copy link
Author

brlin-tw commented Jan 8, 2024

I might consider merging it, in case people would like to experiment it on Linux (though they still would have to use Wine to run it).

I would suggest merging it, as:

  • It greatly enhances the portability of the software
  • The project is not fully superseded by wkbre2 yet, and people using the Linux system are using its level editor functionality(that's why I get to work on this in the first place, even though I don't even have a copy of the game :-) )
  • (Hopefully) this doesn't break anything

If the application can indeed run properly on Wine/Linux, I can even package it as a snap which can be distributed and installed by the wider Linux userbase that plays the game via Wine/Proton, but that's too far to tell by now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants