aybe / DearImGui

imgui & implot for .NET & OpenTK
MIT License
44 stars 3 forks source link

EntryPointNotFoundException when creating a ImPlotPoint #24

Open Cidolfas opened 11 months ago

Cidolfas commented 11 months ago

I had this issue in my own project, so I tired it inside the sample project and got the same exception.

I pulled the v1.89.3 branch, ran the build script, ran the sample app to make sure it worked, and then added the line ImPlotPoint test = new ImPlotPoint(0, 0); to the top of the MyGameWindow::OnRenderFrame function. I get the same exception if I try to use the constructor that wants a Vector2 instead.

The sample app then gets the EntryPointNotFoundException every time.

Here's the full exception:

System.EntryPointNotFoundException: Unable to find an entry point named '??0ImPlotPoint@@QEAA@NN@Z' in DLL 'implot'.
   at DearImPlot.ImPlotPoint.__Internal64.ctor(IntPtr __instance, Double _x, Double _y)
   at DearImPlot.ImPlotPoint..ctor(Double _x, Double _y) in /_/DearImPlot/ImPlot.g.cs:line 1129
   at SampleApplication.OpenTK.MyGameWindow.OnRenderFrame(FrameEventArgs args) in W:\test\DearImGui\SampleApplication.OpenTK\MyGameWindow.cs:line 67
   at OpenTK.Windowing.Desktop.GameWindow.DispatchRenderFrame()
   at OpenTK.Windowing.Desktop.GameWindow.Run()
   at SampleApplication.OpenTK.Program.Main(String[] args) in W:\test\DearImGui\SampleApplication.OpenTK\Program.cs:line 38

I don't have any issues getting an ImPlotPoint instance in C# if I call a function that returns one - like ImPlot.PixelsToPlot - so I'm at a loss for how to help dig further.

Cidolfas commented 11 months ago

I dug into this a bit, and it looks like the issue is simply that ImPlot doesn't add IMPLOT_API onto the constructors of ImPlotPoint or any of it's other structs - so the resulting DLL doesn't have those functions in its exports.

Without the macro, only the zero-argument constructor works (though I haven't tested if trying to use that object as input to an ImPlot function would cause a crash, so for all I know that won't correctly marshall back to the c++ side)

If I slap the API macro onto those, they all work without the exception. I'm going to put an issue in on the IMPLOT repo asking about why those functions don't have the macro on them.

It likely also means this project has a similar issue with the other structs used by IMPLOT - and their member functions like ImPlotRect::Min.

One other issue I've found that can't be fixed as easily (and probably also has a similar issue on the imgui side, which does have the IMGUI_API macro on its struct constructors/functions) are the copy constructors. Since they're not explicitly defined in the imgui/implot libraries but are picked up by this tool's generator code, trying to invoke the ImPlotPoint(ImPlotPoint _0) constructor has the same "calling a function that's not on the dll's export list" exception. I don't see an easy way to fix that one.