Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinGW+CMake crosscompilation for Windows #18

Open
jkulawik opened this issue Jun 3, 2024 · 4 comments
Open

MinGW+CMake crosscompilation for Windows #18

jkulawik opened this issue Jun 3, 2024 · 4 comments
Milestone

Comments

@jkulawik
Copy link
Collaborator

jkulawik commented Jun 3, 2024

This is needed because if someone on Windows compiles the editors, they can release them without the Linux builds (since there's very few users for that). Meanwhile, a Linux developer can't do much with their builds because most people use Windows.

Hopefully helpful link:
https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html

@jkulawik jkulawik modified the milestone: v0.4 Jun 5, 2024
@jkulawik jkulawik changed the title Feature: crosscompilation to Windows from CMake Development: crosscompilation to Windows from CMake Jun 5, 2024
@jkulawik
Copy link
Collaborator Author

jkulawik commented Jun 8, 2024

Resolved some issues and got the toolchain to work, but at the moment progress is stopped by a redaclaration within FBX SDK headers and the libraries they import (math stuff that's taken from mingw, in this case; so it might not act the same on native windows).

This does not occur during Linux builds, so it is possible that this is caused by some mistake with the include lists.

@jkulawik jkulawik added this to the v0.4 milestone Jun 8, 2024
@jkulawik
Copy link
Collaborator Author

The supplied .lib files seem to have been compiled with MSVC (i.e. Visual Studio), which seems to be incompatible with MinGW.

https://stackoverflow.com/questions/2472924/linking-to-msvc-dll-from-mingw

You can't do this. They have exported C++ classes from their dll, rather than C-functions. The difference is, c++ functions are always exported with names in a mangled form that is specific to a particular version of the compiler.

Otherwise you will need to use MSVC to write a shim dll, that will import all the classes, and re-export them via c functions that return interfaces.

An example of writing a shim can be found here. However, given the number of libs which potentially have this issue, this fix is not very viable.

Another solution would be to do one of the following:

  • Find MinGW-compiled versions of the libraries (these aren't supplied in all libs, and AngelScript for example supplies no precompiled binaries at all)
  • Get the source codes and compile them with MinGW or incorporate them as a part of the project (again AS proves to be an issue because 2.19.2 originally used in the project doesn't compile, or at least not in C++20. Needs testing)

On the other hand:
https://stackoverflow.com/questions/2529770/how-to-use-libraries-compiled-with-mingw-in-msvc

Even though GNU g++ can link MSVC C++ libraries now, and can produce MSVC++ compatible libraries/DLLs, this does not mean that they will be able to work at run-time due to the dynamic nature of C++.

This means that it should be possible, but the dlls would be useless, so we probably need the other fix anyway.

@jkulawik
Copy link
Collaborator Author

Worth noting:
https://www.mingw-w64.org/

Tools
gendef: generate Visual Studio .def files from .dll files.

Might be helpful, but probably won't.

@jkulawik
Copy link
Collaborator Author

Got the MinGW builds to compile, but they're broken - probably because non-MinGW libraries are still being used.

@jkulawik jkulawik changed the title Development: crosscompilation to Windows from CMake MinGW+CMake crosscompilation for Windows Jun 22, 2024
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

No branches or pull requests

1 participant