Skip to content

Conversation

@tobil4sk
Copy link
Member

@tobil4sk tobil4sk commented Apr 12, 2023

Fixes some issues to allow compiling lime.ndll with MinGW.

I'm not too sure what the best way to deal with the System.cpp situation would be.

@tobil4sk tobil4sk changed the title Fix build issues on MinGW Fix lime.ndll build on MinGW Apr 12, 2023
@tobil4sk tobil4sk force-pushed the mingw-fixes-8.2.0-Dev branch from 5ba7e8e to c7c386d Compare April 12, 2023 22:43
@tobil4sk
Copy link
Member Author

I separated out some of the commits into #1661, because with those commits it's already possible to cross compile projects with mingw with a precompiled lime.ndll.

@DigiEggz
Copy link
Contributor

DigiEggz commented Aug 25, 2023

I'm interested in testing this build! Could you offer any links to the new precompiled minGW version of lime.ndll? If not, I can look into building from source, but it might be a while.

@tobil4sk
Copy link
Member Author

tobil4sk commented Aug 29, 2023

I'm interested in testing this build! Could you offer any links to the new precompiled minGW version of lime.ndll?

Hi sorry, I haven't uploaded the precompiled lime.ndll anywhere. Building from source isn't too complicated as long as you have mingw set up, when I have a look at this again I can try to provide some proper instructions for how to do this. I should have provided instructions originally in the PR, sorry. Once I have a look again I could probably upload a copy of the ndll here as well.

Just a heads up, I managed to get things compiling but the build wasn't really working. When I tried to run a project with the mingw ndll there was no window showing up unfortunately. This will require more investigating to figure out what exactly is wrong. In the meantime I have just been building my actual project code with mingw (with #1661 and the git version of hxcpp) but using the regular Windows lime.ndlls instead of compiling my own mingw copy.

@DigiEggz
Copy link
Contributor

I'm interested in testing this build! Could you offer any links to the new precompiled minGW version of lime.ndll?

Hi sorry, I haven't uploaded the precompiled lime.ndll anywhere. Building from source isn't too complicated as long as you have mingw set up, when I have a look at this again I can try to provide some proper instructions for how to do this. I should have provided instructions originally in the PR, sorry. Once I have a look again I could probably upload a copy of the ndll here as well.

Just a heads up, I managed to get things compiling but the build wasn't really working. When I tried to run a project with the mingw ndll there was no window showing up unfortunately. This will require more investigating to figure out what exactly is wrong. In the meantime I have just been building my actual project code with mingw (with #1661 and hxcpp patches HaxeFoundation/hxcpp#1044 HaxeFoundation/hxcpp#1045 HaxeFoundation/hxcpp#1046) but using the regular Windows lime.ndlls instead of compiling my own mingw copy.

I'll give that a try! Thanks again for all of the work you've put into this build.

@DigiEggz
Copy link
Contributor

DigiEggz commented Sep 21, 2023

When trying compiling my app (with this library), I get an error:
Error: /Users/E/Documents/Haxe/hxdiscord_rpc/git/project/discord-rpc/src/connection_win.cpp:8:10: fatal error: 'windows.h' file not found

Do you know what I may have to do in order to get the windows.h header file to be included? I'm not sure if I haven't linked minGW or if it's otherwise not set up correctly.

Edit: I used this guide to manually set some of my paths. I cannot compile to 32-bit (he -32 flag doesn't change anything) and trying to set the MINGW_ROOT path results in a double-concatenated string for some reason, but it otherwise works.

@tobil4sk tobil4sk force-pushed the mingw-fixes-8.2.0-Dev branch from 35d6050 to 75a0488 Compare May 31, 2024 18:41
@tobil4sk tobil4sk force-pushed the mingw-fixes-8.2.0-Dev branch from 75a0488 to 33f616e Compare December 18, 2024 17:21
@tobil4sk tobil4sk changed the base branch from 8.2.0-Dev to develop December 18, 2024 17:21
@tobil4sk tobil4sk force-pushed the mingw-fixes-8.2.0-Dev branch from 33f616e to a475216 Compare December 18, 2024 17:25
@tobil4sk
Copy link
Member Author

I'm not too sure what the best way to deal with the System.cpp situation would be.

I figured out that this issue can be worked around by avoiding _bstr_t(char*) calls and replacing them all with _bstr_t(wchar*) calls, which seems more consistent anyway. I've tested it with the native windows ndll and that still works too.

With current hxcpp, when cross compiling from linux it is necessary to rebuild with lime rebuild windows -Dmingw to make sure the correct flags are used for the build, see: HaxeFoundation/hxcpp#1168.

This compiles properly now, and also runs successfully from my testing!

@tobil4sk
Copy link
Member Author

tobil4sk commented Sep 1, 2025

Wondering whether this should be targeted at develop or 8.3.0-Dev. On one hand, mingw is already partially supported, and this just makes that support full. On the other hand, it requires updating cairo (1.18.2 to 1.18.4) and could be considered a new feature.

@joshtynjala
Copy link
Member

If it were me, I'd probably put it into 8.3.0-Dev. I tend to avoid updating submodules on develop unless an operating system update leaves us no choice (I recently had to do that for a few because GitHub Actions updated macOS/Xcode and builds were failing) or if I need to fix a regression from a previous submodule update.

@tobil4sk tobil4sk changed the base branch from develop to 8.3.0-Dev September 8, 2025 22:58
When cross compiling from Linux, header names are case sensitive unlike
on Windows.
This causes issues on mingw, and is no longer needed since openal now
uses std::isfinite (c++11) instead of isfinite.

kcat/openal-soft@3ae1c78
With mingw, converting from char* to _bstr_t calls ConvertStringToBSTR
which is not defined by mingw. Creating all strings from wchar* avoids
this issue.

comsuppw.lib is also unavailable on mingw, and we need to add
wbemuuid.lib manually as the #pragma comment(lib, ...) in System.cpp is
only respected by MSVC.

Adding bstr_t explicitly rather than relying on implicit conversion also
avoids gcc warnings here.
When cross compiling, the default target is set as neko in HXProject, so
we can't assume that rebuild will always be cpp.
`wbemuuid.lib` must be linked explicitly, since #pragma
comment(lib, ...) only works with msvc.

`comsuppw.lib` does not exist in mingw.

`no_shared_libs` must be set for mingw to ensure the standard library
and other libraries are linked statically.

`.lib` must be replaced with `${LIBEXT}` so that it resolves to `.a` on
mingw.
MSVC links this automatically due to a #pragma in curl's source code,
but other compilers require it to be added explicitly.
@tobil4sk tobil4sk changed the base branch from 8.3.0-Dev to develop December 20, 2025 13:00
@tobil4sk tobil4sk force-pushed the mingw-fixes-8.2.0-Dev branch from 775bece to 3eee8f1 Compare December 20, 2025 13:00
@tobil4sk
Copy link
Member Author

develop is currently on cairo 1.18.2, which turns out to be sufficient to compile lime with mingw, so I have removed the cairo 1.18.4 bump from this PR. The remaining changes are minor patches so I think they should be suitable for develop.

I have added a mingw build to ci, just so we can confirm that it builds without errors. It is uploaded as an artifact to the workflow run, but it doesn't go in the actual lime release.

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.

3 participants