openfl / lime

A foundational Haxe framework for cross-platform development
https://lime.openfl.org/
MIT License
753 stars 365 forks source link

Crash on Windows 10 - "Could not load module lime@lime_application_create_prime" #1691

Closed hoangdung-qbt closed 3 months ago

hoangdung-qbt commented 1 year ago

Platform: Windows 10 HxCpp 4.3.2 Lime 8.0.2 OpenFL 9.2.1 Haxe 4.2.5

When clicking on the exe file to start with, this error occurs and prevent the app from opening.

hoangdung-qbt commented 1 year ago

Full error log might be here Called from lime._internal.backend.native.NativeCFFI::boot lime/_internal/backend/native/NativeCFFI.hx line 214 Called from cpp.Prime::_loadPrime haxe/std/cpp/Prime.hx line 36 Error : Could not load module lime@lime_application_create__prime

hoangdung-qbt commented 1 year ago

It seems Lime 8.0.2 always copies the file lime.ndll from Windows64 folder to the 32bit release folder. go to Windows folder and move the similar one to bin folder might solve this issue. But it needs some tests on various devices. If everything works well, I will post the result here. and it is not a serious bug related to static linking, LGPL components,....

joshtynjala commented 1 year ago

If I'm understanding the code in WindowsPlatform.hx correctly, to build a 32-bit app for Windows, you may need this in your project.xml:

<architecture name="x86" if="windows" />

It's possible that you need to exclude x64 too:

<architecture name="x86" exclude="x64" if="windows" />
hoangdung-qbt commented 1 year ago

Lime 7.9.0 can copy the 32bit lime.ndll to the release folder by adding haxedef name="HXCPP_M32 Josh. This happens only with the latest release of Lime.😊

joshtynjala commented 1 year ago

Okay. That's good to know. However, did you try what I suggested?

hoangdung-qbt commented 1 year ago

Not yet. But it is worth trying to figure out what is the problem, especially with the newest versions of Lime.

joshtynjala commented 1 year ago

It's worth mentioning that I'm not sure that adding the haxedef HXCPP_M32 should be considered enough to force a 32-bit build on a 64-bit system, even if it happened to work in the past. That flag is more of an internal implementation detail of using hxcpp, and shouldn't be considered a "public API" of Lime. Typically, Lime requires something, like a -32 or -64 command line argument, or the <architecture/> element in project.xml, to use a different architecture than the target's default.

hoangdung-qbt commented 1 year ago

The most difficult thing is it doesnt constantly happen on all machines. It did some tests on 3 pcs, everything is ok but on the remaining one, this error occurs. Still looking forward to having more info and trying your way.😊

joshtynjala commented 1 year ago

Could it be that your PCs have a mix of 32-bit and 64-bit versions of Windows? On a 32-bit version of Windows, I believe that Lime will build 32-bit executables by default instead.

hoangdung-qbt commented 1 year ago

It's worth mentioning that I'm not sure that adding the haxedef HXCPP_M32 should be considered enough to force a 32-bit build on a 64-bit system, even if it happened to work in the past. That flag is more of an internal implementation detail of using hxcpp, and shouldn't be considered a "public API" of Lime. Typically, Lime requires something, like a -32 or -64 command line argument, or the <architecture/> element in project.xml, to use a different architecture than the target's default.

You may be correct because when using Lime 7.9.0, I have added -32 to the cl. So we have the 32bit lime.ndll in release folder. A lot of things to do, I can not check everyting carefully.

hoangdung-qbt commented 1 year ago

Could it be that your PCs have a mix of 32-bit and 64-bit versions of Windows? On a 32-bit version of Windows, I believe that Lime will build 32-bit executables by default instead.

I still did not know about this PC but I will do a test on it tomorrow with new builds.Hopefully, everything is Ok Thanks Josh.

hoangdung-qbt commented 1 year ago

Solved by using the 32 bit version of lime.ndll. But this is a bug on Lime 8.0.2.😁

joshtynjala commented 1 year ago

@hoangdung-qbt I'm glad that you found a workaround, but I'd still like to know what happens if you try specifying the <architecture/> values (that I mentioned in a previous comment) in your project.xml.

hoangdung-qbt commented 1 year ago

I'm not on a computer now. But i will be back soon to do some tests.😊

hoangdung-qbt commented 1 year ago
<architecture name="x86" if="windows" />

Hi Josh, adding // architecture/> // element doesn't make any changes at all. I still have the 64bit lime.ndll in the release folder. I wasn't working on the mod of FNF but this info can be useful for someone who loves it. And this is definitely a bug (Lime 8.0.1).

joshtynjala commented 1 year ago

I was able to find a moment to do a few quick tests today. To force 32-bit, I determined that you not only need to specify the x86 architecture, but you also need to exclude the x64 architecture.

<architecture name="x86" exclude="x64" if="windows" />

With this, defining HXCPP_M32 should not be required. It should be defined automatically by Lime's tools.

hoangdung-qbt commented 1 year ago

What a great workaround Josh. Something is small but makes everything work perfectly. I still dont close this issue due to lack of documents out there. Hope this useful for everyone.

player-03 commented 3 months ago

I think it's safe to close the issue. People will still be able to find it by searching for the error message.