IDI-Systems / UnrealImGui

Unreal plug-in that integrates Dear ImGui framework into Unreal Engine 4/5.
MIT License
132 stars 28 forks source link

Compile Error - "overflow in constant arithmetic" #32

Open 2wol opened 1 month ago

2wol commented 1 month ago

Hey,

So, in issue #29 I wrote that I cannot compile the project correctly after adding UnrealImGui to a project created in Unreal Engine 5.4.2.

I'm still getting errors releated to ImPlot "overflow in constant arithmetic"

Steps to reproduce:

Here is video showing what I'm doing step by step: https://www.youtube.com/watch?v=JSbJqWXOcik

2wol commented 1 month ago

I did some "research" on the Internet - the problem seems to be in the INFINITY variable in implot_demo.cpp, which is used in those lines of code where the error occurs:

ImPlot::PlotShaded("Stock 1", xs1, ys1, 101, shade_mode == 0 ? -INFINITY : shade_mode == 1 ? INFINITY : fill_ref, flags);
ImPlot::PlotShaded("Stock 2", xs1, ys2, 101, shade_mode == 0 ? -INFINITY : shade_mode == 1 ? INFINITY : fill_ref, flags);
ImPlot::PlotShaded("Stock 3", xs1, ys3, 101, shade_mode == 0 ? -INFINITY : shade_mode == 1 ? INFINITY : fill_ref, flags);

Unfortunately, I am not able to find a solution for this other than removing these three lines of code.... After removing these three lines - project builds correctly but it seems that the UnrealImGui plugin is skipped during building in Visual Studio.

2>------ Building 11 action(s) started ------
2>[1/11] Compile [x64] AMBUSHCharacter.gen.cpp
2>[2/11] Compile [x64] AMBUSHGameMode.cpp
2>[3/11] Compile [x64] AMBUSHCharacter.cpp
2>[4/11] Compile [x64] TP_PickUpComponent.cpp
2>[5/11] Link [x64] UnrealEditor-ImGui-0006.lib
2>   Creating library C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Plugins\ImGui\Intermediate\Build\Win64\x64\UnrealEditor\Development\ImGui\UnrealEditor-ImGui-0006.lib and object C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Plugins\ImGui\Intermediate\Build\Win64\x64\UnrealEditor\Development\ImGui\UnrealEditor-ImGui-0006.exp
2>[6/11] Compile [x64] TP_PickUpComponent.gen.cpp
2>[7/11] Link [x64] UnrealEditor-ImGui-0006.dll
2>   Creating library C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Plugins\ImGui\Intermediate\Build\Win64\x64\UnrealEditor\Development\ImGui\UnrealEditor-ImGui-0006.sup.lib and object C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Plugins\ImGui\Intermediate\Build\Win64\x64\UnrealEditor\Development\ImGui\UnrealEditor-ImGui-0006.sup.exp
2>[8/11] Compile [x64] TP_WeaponComponent.cpp
2>[9/11] Link [x64] UnrealEditor-AMBUSH-0006.lib
2>   Creating library C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Intermediate\Build\Win64\x64\UnrealEditor\Development\AMBUSH\UnrealEditor-AMBUSH-0006.lib and object C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Intermediate\Build\Win64\x64\UnrealEditor\Development\AMBUSH\UnrealEditor-AMBUSH-0006.exp
2>[10/11] Link [x64] UnrealEditor-AMBUSH-0006.dll
2>   Creating library C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Intermediate\Build\Win64\x64\UnrealEditor\Development\AMBUSH\UnrealEditor-AMBUSH-0006.sup.lib and object C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Intermediate\Build\Win64\x64\UnrealEditor\Development\AMBUSH\UnrealEditor-AMBUSH-0006.sup.exp
2>[11/11] WriteMetadata AMBUSHEditor.target
2>Total time in Parallel executor: 10.50 seconds
2>Total execution time: 15.10 seconds
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 1 skipped ==========

and I cannot use #include <imgui.h> cause VS cannot open this file.

EDIT

Well imgui is already working in my project, it turned out that I didn't have the environment variable set to Microsoft.NET.Sdk - I can create a window etc. but there is still a problem with three lines of code that I mentioned above:

------ Building 1 action(s) started ------
  [1/1] Compile [x64] ImGuiImplementation.cpp
  C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Plugins\ImGui\Source\ThirdParty\ImPlotLibrary\Private\implot_demo.cpp(353) : error C4756: overflow in constant arithmetic
     while compiling ImPlot::Demo_FilledLinePlots
  C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Plugins\ImGui\Source\ThirdParty\ImPlotLibrary\Private\implot_demo.cpp(353) : error C4756: overflow in constant arithmetic
     while compiling ImPlot::Demo_FilledLinePlots
  C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Plugins\ImGui\Source\ThirdParty\ImPlotLibrary\Private\implot_demo.cpp(354) : error C4756: overflow in constant arithmetic
     while compiling ImPlot::Demo_FilledLinePlots
  C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Plugins\ImGui\Source\ThirdParty\ImPlotLibrary\Private\implot_demo.cpp(354) : error C4756: overflow in constant arithmetic
     while compiling ImPlot::Demo_FilledLinePlots
  C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Plugins\ImGui\Source\ThirdParty\ImPlotLibrary\Private\implot_demo.cpp(355) : error C4756: overflow in constant arithmetic
     while compiling ImPlot::Demo_FilledLinePlots
  C:\Users\Laptop\Documents\Unreal Projects\AMBUSH\Plugins\ImGui\Source\ThirdParty\ImPlotLibrary\Private\implot_demo.cpp(355) : error C4756: overflow in constant arithmetic
     while compiling ImPlot::Demo_FilledLinePlots
  Total time in Parallel executor: 19.62 seconds
  Total execution time: 20.34 seconds
Build failed.

and more specifically with the definition of INFINITY.

MifikTTV commented 2 days ago

how did you set the environment variable to Microsoft.NET.Sdk ?

2wol commented 2 days ago

I belive you only need to add C:\ProgramFiles\dotnet to a 'Path'. Some time ago I reinstalled Windows and reconfigured UE with Visual Studio and I have this variable in 'Environment Variables' and I'm not sure if that's it, but I'm guessing 90% on that bcs C++ in UE5 works correctly (except the Issue I described). Could you let me know if everything is working properly for you? For me the ImPlot Issue still shows up on UE 5.4.3.

image