TwistedTwigleg / Godot_BacktraceModule

A module for Godot 3.x that makes it easy to send crash reports to Backtrace
MIT License
17 stars 0 forks source link

Error while compiling Godot 3.3 #2

Open havana24 opened 2 years ago

havana24 commented 2 years ago

Hi there! :) A friend of mine is trying to implement backtrace in Godot 3.3 with your module... He followed all the steps but this error appears while compiling the Godot engine.

backtrace_compile_error

Do you have any clue?

He also tried to implement this on Godot 3.4 but Godot seems to have changed some paths like "core/reference.h" that is now in "core/object/ref_counted.h".

Thanks in advance! Alessandro

TwistedTwigleg commented 2 years ago

Hi Alessandro!

The issue appears to be in the get_std_string_from_godot_string function, if I am reading the error correctly. Based on the error log, I think the issue is that calling c_str() on the Godot string type is returning a std::string rather than a std::wstring like it does on Linux, which is why it's crashing. I think what may fix the issue is changing the function so that it returns the result of the Godot c_str() function directly:

std::string Crashpad::get_std__string_from_godot_string(String input)
{
    return std::string(input.c_str());
}

But I will have to test to know for sure.

Based on the picture, your friend is trying to compile on Windows, right? By any chance, do you know what compiler they are using? I am wondering because I might be able to recreate the issue on my Windows machine. I think I was using MingW when I tested compiling the module on Windows, but I'm not positive. I will test on my machine and see if I can find a fix!

He also tried to implement this on Godot 3.4 but Godot seems to have changed some paths like "core/reference.h" that is now in "core/object/ref_counted.h".

Thank you for letting me know! I'll see if I can fix the compile issue first and then will update the module to Godot 3.4 as well :+1:

havana24 commented 2 years ago

Thanks for the fast reply! :)

He said he is using Visual Studio 2019 on a Windows machine. We will try your fix this evening and let you know, thanks again!

havana24 commented 2 years ago

Hi there!

We tried your fix but now there is a new error:

client.lib(client.crashpad_client_win.obj) : error LNK2038: rilevata errata corrispondenza per 'RuntimeLibrary': il valore 'MD_DynamicRelease' non corrisponde al valore 'MT_StaticRelease' in godot_windows.windows.tools.64.obj

Do you have any clue ? Thanks in advance

TwistedTwigleg commented 2 years ago

I'm not sure right off, but based on the error, I think the issue might be that the Crashpad library is being linked dynamically instead of statically. Was Crashpad compiled with gn gen out\Default --args="extra_cflags=\"/MD\""?

TwistedTwigleg commented 2 years ago

So, I've been looking into the issue with Visual Studio 2019 and have been able to successfully compile when compiling from the Visual Studio Command-line instead of the generated Visual Studio project. I think it is because the Visual Studio project tries to compile a 32-bit solution rather than a 64-bit one, which seems to be causing the issue.

When compiling for 32-bits, I am able to recreate the first issue. I'm not getting the linking issue, but trying the fix hasn't fixed it for me either. I am looking into it and will try to find a solution.

Edit: There does seem to be an issue on 64 bit windows but I have fixed it and will push the result. I am just trying to see if I can fix the 32 bit issue, as it is still occurring.

TwistedTwigleg commented 2 years ago

Okay, I fixed the issue and got a working compile on 32 bit Windows and 64 bit Windows! There was a small issue with compiling on Windows that I missed, which I just pushed a commit to fix: Commit.

Additionally, to compile Godot on 32 bit Windows you need to use a 32 bit compiled version of Crashpad or it will not work. If you are running on a 64 bit machine, by default gn will generate a 64 bit version of Crashpad and this will not work if compiling the 32 bit version of Godot through Visual Studio. The easiest way I found to solve this on a 64 bit Windows machine is to download the Crashpad library from the Crashpad Integration Guide from Backtrace (direct link to downloads). Just download the crashpad-release-x86-latest.zip file and then copy the libraries from lib_mt to the modules/crashpad/libs folder and then compiling the 32-bit version of Godot should work.

Compiling the 64 bit version of Godot should now just work like expected. If using Visual Studio though, you will need to change the solution from Win32 to x64 to compile the 64 bit version, as it defaults to trying to compile the 32-bit version.

I am pretty sure it should compile now! If everything works, then I'll close the issue and then look at updating the module to support Godot 3.4 after that 🙂

havana24 commented 2 years ago

Hi there, thanks for checking it! :D Unfortunately my friend got the same last error as before. He said he followed all your steps but nothing changed unfortunately.

If you compiled the Godot engine with backtrace correctly on windows could you send it here via WeTranfer or something similar? The thing is that we need it in order to join a game jam and we have no more time to make it work by ourself. If you can't, is not a problem, we will try to implement this module for the next game jam with more calm. :)

TwistedTwigleg commented 2 years ago

Sure! I will upload both the 32-bit and 64-bit builds to Google Drive and link to them here, I just need to get to my Windows desktop to get the files. Will get it ASAP. 👍

TwistedTwigleg commented 2 years ago

Here's the Google Drive link: Link It includes the executable for 32-bit and 64-bit, as well as the debug symbols that are automatically generated. I think you will still need to use dump_sys to get readable results in Backtrace, from what I remember at least, but it should be able to be generated with the files provided.

If you need anything else, please do not hesitate to let me know! Best of luck with the jam 😄

havana24 commented 2 years ago

Thank you very much! :)