ImGui.NET-nativebuild icon indicating copy to clipboard operation
ImGui.NET-nativebuild copied to clipboard

Submodules for cimguizmo, cimnodes, cimplot and CMake file to build corresponding libraries

Open TillAlex opened this issue 4 years ago • 11 comments

This is just a first test how to build separate DLLs for cimplot, cimnodes and cimguizmo. Only tested cimplot until now. Not sure how you would integrate it.

TillAlex avatar Nov 30 '20 22:11 TillAlex

CI seems to work for Windows, Linux and OSX now.

TillAlex avatar Dec 01 '20 21:12 TillAlex

Having imgui.cpp compiled in different Dlls is risky because of globals.

sonoro1234 avatar Apr 10 '21 20:04 sonoro1234

Personally I would prefer compiling into a single binary, but I also understand that @mellinoe wants to keep binary size small for users not using all modules.

From the imgui docs I understand that the only globals are context and allocator functions. As long as your are setting those for all DLLs you should be OK. Is this correct?

TillAlex avatar Apr 10 '21 21:04 TillAlex

I hope so. But another alternative would be having imgui.cpp only in cimgui.dll and let the others Dlls link dynamically to cimgui.dll

sonoro1234 avatar Apr 10 '21 23:04 sonoro1234

Are all the internal imgui symbols needed for those modules exported? Then this is certainly the best solution. Will have a look into this as soon as I have the time.

TillAlex avatar Apr 11 '21 07:04 TillAlex

Are all the internal imgui symbols needed for those modules exported?

You should define IMGUI_API as __declspec( dllexport ) in cimgui.dll and then __declspec( dllimport ) in the others.

Althought the notes in: https://github.com/ocornut/imgui/blob/master/imconfig.h#L22 are saying that globals cant be shared across DLL boundaries.

sonoro1234 avatar Apr 11 '21 07:04 sonoro1234

ImGui.NET is a pretty lightweight package in comparison to most other ones (if I refer to .NET game development tools). If I'd have to share my thoughts on the topic, I'd say that the benefits of having all the libraries built into one single library and nuget outweighs by far the value of having individual small nugets. If it really is an issue, ImGui.NET could be packaged into 2 flavors: one naked, one with all extensions built into cimgui.

Another thing to me might be an issue: cimgui dynamically links to the VC++ runtime. For game development, it's preferred to statically link to it.

EDIT: FYI, I've derived this work to implement this proposal and build a unified binary with the VC runtime statically linked and with macOS backward compatibility: https://github.com/FlyingOakGames/ImGui.NET-nativebuild/tree/widgets

mrhelmut avatar Apr 21 '21 12:04 mrhelmut

-> If it really is an issue, ImGui.NET could be packaged into 2 flavors: one naked, one with all extensions built into cimgui.

I like this idea, esp if CI pipelines can be created that can release 2 flavors.

zaafar avatar Sep 14 '21 21:09 zaafar

Is there something missing to merge this PR? I would be glad to help out so this can be merged

MarioGK avatar Apr 21 '22 19:04 MarioGK

I hope so. But another alternative would be having imgui.cpp only in cimgui.dll and let the others Dlls link dynamically to cimgui.dll

How would one go about doing this? I'd like to avoid problems as much as possible and this sounds like it avoids a big one?

EDIT: Is anyone actually able to use the additional libraries in C#? I can get so far but always end up with AccessViolationExceptions trying to use ImPlot.BeginPlot(), KingFisher#0001 on Discord if you are able to help me out 👍

Hi-ImKyle avatar Mar 08 '23 18:03 Hi-ImKyle

How would one go about doing this?

with cmake:

add_library(cimgui SHARED ${CIMGUI_SOURCES})
add_library(cimplot SHARED ${CIMPLOT_SOURCES})
target_link_libraries(cimplot PUBLIC cimgui)

with IMGUI_API defined for exporting functions

sonoro1234 avatar Mar 08 '23 18:03 sonoro1234