Problem getting Cimgui to work

Mike Parker aldacron at gmail.com
Thu Dec 7 01:02:32 UTC 2017


On Wednesday, 6 December 2017 at 21:21:11 UTC, Thomas wrote:
> Hi folks!
>
> I got it to work, but honestly I don't know why.. :-)

Glad you got it working. I wanted to reply earlier but I was on 
my phone when I first saw this thread. So now instead of helping 
you solve the problem, I'll throw in a few words to hopefully 
shed some light on why it worked and help you more easily solve 
similar issues if they arise in the future.

>
> 1. clone project imgui_d_test with git
> 2. subloading the base cimgui stuff by command: git submodule 
> update --init --recursive

The short answer is that this step is why it worked. I'll 
elaborate below.

> 3. enter cimgui directory and enter make
> 4. after that dub doesn't work properly, you have to edit app.d
> replace DerelictImgui.load(); with 
> DerelictImgui.load("/..pathToFile../cimgui.so");

You shouldn't ever have to do this if things are properly 
configured.


> Hmm.. maybe they did some corrections in project imgui in the 
> last couple of hours ?

Not quite :-) But the root of the problem does, indeed, come down 
to changes in imgui. I'll quote from your previous posts to show 
how to solve the sort of problem you encountered.

> Ok, so in a second attempt I downloaded Cimgui as a ZIP and 
> also the Imgui files from the homepage into the appropriate 
> directory and unzipped them.

This was the root mistake. Whenever you are using a D binding to 
a C library, no matter if it's an official Derelict package, an 
"unofficial" package (i.e., not one maintained as part of the 
DerelictOrg group, such as derelict-imgui), a Deimos package, or 
something else, always, always, always make sure the version of 
the C library you are using matches the version the binding 
supports. Some Derelict packages, like DerelictSDL2, support 
multiple versions of their C library via DerelictUtil's 
SharedLibVersion feature. Most do not.

So the thing to do is to look at the project's code.dlang.org 
page and see if the info you need is there. If not, follow the 
link to the source repository on that page and look for any and 
all documentation you can find to see which version of the 
binding requires which version of the C library. What happens if 
there's a version mismatch? This:

> This time the compiler cried this error:

> derelict.util.exception.SymbolLoadException at ../../.dub/packages/derelict-util-3.0.0-beta.2/derelict-util/source/derelict/util/sharedlib.d(181): Failed to load symbol igPushIdPtr from shared library cimgui.so

A SymbolLoadException almost always indicates that your version 
of the C library is different (usually older) from the one the 
Derelict binding expects (in rare cases it can be a corrupt 
library). The solution is to double check that your versions 
match. It usually helps to dig into the change logs/release notes 
of the C library to see if/when any functions were added or 
removed. That way you can figure out if the binding is outdated, 
or if you need an older/newer version of the C library.

> After some research again I found a workaround on the Derelict 
> Util homepage:

No, you did not find a workaround :-) The selective loading 
mechanism is not intended as a workaround for missing symbols. 
It's intended to be used when you want to support multiple 
versions of a C library (the SharedLibVersion feature uses it 
internally), or when the C library on the user's system might be 
compiled with and without certain features you don't care about. 
If you don't know the details of the C library or the potential 
consequences of ignoring any given set of functions, you 
shouldn't be using this feature. I need to make that clear in the 
documentation.

> Unfortunately there is no DUB for Cimgui itself

Cimgui is a C library and DUB does not support building C 
libraries.

===================

So, why did it work for you? From what I can gather, looking at 
the DerelictIMGUI repo, we see it's implemented against CImgui 
1.5.0. Looking at CImgui shows it has been updated to 1.52, which 
is implemented against imgui 1.52. Looking at the release notes 
for imgui 1.51 and 1.52, we can find several breaking changes 
since 1.50. The reason you finally got it to worked is because 
the submodule tree from DerelictIMGUI gave you version 1.50 of 
CImgui and Imgui.

So the steps should be:

checkout imgui 1.50
checkout cimgui 1.50
Build both
Put them on your system library path

Then you should be set to use DerelictIMGUI without the need to 
modify its package recipe.







More information about the Digitalmars-d-learn mailing list