Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImNodes example not running #16

Open
system64MC opened this issue Dec 8, 2024 · 20 comments · Fixed by #17
Open

ImNodes example not running #16

system64MC opened this issue Dec 8, 2024 · 20 comments · Fixed by #17

Comments

@system64MC
Copy link
Contributor

system64MC commented Dec 8, 2024

Hi. I tried the example projects and it looks like I can't run the ImNodes example.

Here is what it says :

Added: /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
free(): double free detected in tcache 2
SIGABRT: Abnormal termination.
Abandon (core dumped)

It looks like it happens while calling NodeEditorInitialize().
I'm on POP!_OS 2204 LTS and I use Nim 2.2.0.

Is this normal?
Thanks for your answer!

@dinau
Copy link
Owner

dinau commented Dec 9, 2024

Thank you for this report.
I can reproduce this problem on my Linux Mint 22.
I will look over this issue.

dinau added a commit that referenced this issue Dec 9, 2024
@dinau dinau linked a pull request Dec 9, 2024 that will close this issue
dinau added a commit that referenced this issue Dec 9, 2024
@dinau dinau closed this as completed in #17 Dec 9, 2024
@dinau
Copy link
Owner

dinau commented Dec 9, 2024

Updated sources.
First delete old save_load.bytes file and make run.

@dinau dinau reopened this Dec 9, 2024
@system64MC
Copy link
Contributor Author

Updated sources. First delete old save_load.bytes file and make run.

It works! Thanks!

Is it also possible to make a project without Make (Nim tools only)? I tried to make a baremetal ImGUI test with ImNodes, I have linker errors.

@dinau
Copy link
Owner

dinau commented Dec 10, 2024

I will add this to README file,

pwd
examples/glfw_opnegl3_imnodes

nim c -d:release -d:strip -d:ImNodesEnable glfw_opengl3_imnodes.nim

@system64MC
Copy link
Contributor Author

I will add this to README file,

pwd
examples/glfw_opnegl3_imnodes

nim c -d:release -d:strip -d:ImNodesEnable glfw_opengl3_imnodes.nim

That was quite straightforward! Thanks!
However I noticed a problem while trying to cross-compile from Linux to Windows. I have this error :

system64@pop-os:~/programmation/testNimImNodes/glfw_opengl3$ nim compile --os:windows glfw_opengl3.nim 

#### [ gcc ] Compiler ####

Hint: used config file '/home/system64/.choosenim/toolchains/nim-2.2.0/config/nim.cfg' [Conf]
Hint: used config file '/home/system64/.choosenim/toolchains/nim-2.2.0/config/config.nims' [Conf]
Hint: used config file '/home/system64/programmation/testNimImNodes/glfw_opengl3/config.nims' [Conf]
............................................................................................................................
/home/system64/.nimble/pkgs2/imguin-1.91.4.0-d2351593496ca43b2f019cdaba21a66f5b7e0bed/imguin/cimgui.nim(79, 12) Error: cannot find: \home\system64\.nimble\pkgs2\imguin-1.91.4.0-d2351593496ca43b2f019cdaba21a66f5b7e0bed\imguin\private\cimgui\cimgui.cpp

Seems it messes up with the "/".

@dinau
Copy link
Owner

dinau commented Dec 10, 2024

Hi,
I have not tried to cross compilation for Windows OS on Linux OS.
Would you try this ?
Cross compilation to Windows, linker error (unrecognized option '-z'

https://nim-lang.org/docs/nimc.html#crossminuscompilation-for-windows

I'll try this later.

@system64MC
Copy link
Contributor Author

Hi, I have not tried to cross compilation for Windows OS on Linux OS. Would you try this ? Cross compilation to Windows, linker error (unrecognized option '-z'

https://nim-lang.org/docs/nimc.html#crossminuscompilation-for-windows

I'll try this later.

It still doesn't work sadly.

@system64MC
Copy link
Contributor Author

nim compile --os:windows glfw_opengl3.nim

Hi, I have not tried to cross compilation for Windows OS on Linux OS. Would you try this ? Cross compilation to Windows, linker error (unrecognized option '-z'
https://nim-lang.org/docs/nimc.html#crossminuscompilation-for-windows
I'll try this later.

It still doesn't work sadly.

Some progress!
I noticed that if I add ".replace("\", "/")" after each joinPath statement, it solve the errors. A way to solve this might be to create a function that changes the path only if we compile from a Linux to Windows
like joinPath(ImguiRootPath,"backends","imgui_impl_glfw.cpp").replaceIfWeAreOnLinux("\", "/")

However I also have another error : /home/system64/.nimble/pkgs2/imguin-1.91.4.0-d2351593496ca43b2f019cdaba21a66f5b7e0bed/imguin/private/cimgui/imgui/backends/imgui_impl_glfw.cpp:102:10: fatal error: GLFW/glfw3.h
Which means it can't find GLFW/glfw3.h (however everything works fine when I compile from Linux to Linux).

@dinau
Copy link
Owner

dinau commented Dec 11, 2024

I can successfully generated Windows exe file using your idea and it works well on Windows OS.

it can't find GLFW/glfw3.h (however everything works fine when I compile from Linux to Linux).

This error can be silent by changing cimgui.nim line 56,

from

{.passC:"-I" & joinPath(staticExec("nimble path nimgl").strip,"nimgl","private","glfw","include").}

to

{.passC:"-I" & joinPath(staticExec("nimble path nimgl").strip,"nimgl","private","glfw","include").replace("\\", "/").}

I've executed this command,

nim c -d:release -d:strip -d:mingw --passL:-lstdc++ glfw_opengl3.nim 

@system64MC
Copy link
Contributor Author

nim c -d:release -d:strip -d:mingw --passL:-lstdc++ glfw_opengl3.nim 

It works! It also works with --os;windows!
I think we have found and solved the issue!

@dinau
Copy link
Owner

dinau commented Dec 11, 2024

Thank you for your interesting idea.

@system64MC
Copy link
Contributor Author

Thank you for your interesting idea.

You are welcome! Do you want me to try to do a pull request with the changes I suggested?

@dinau
Copy link
Owner

dinau commented Dec 12, 2024

I would appreciate your PR.

@system64MC
Copy link
Contributor Author

system64MC commented Dec 12, 2024

I would appreciate your PR.

Alright! I will do this once I'm back home.

I also try to add ImGui-knobs, an addon for Dear ImGui that adds... Knobs.
I achieved to make a C interface, however should I add the Nim procs manually or is there something to do to generate them automatically?

@dinau
Copy link
Owner

dinau commented Dec 12, 2024

I think you should make for instance cimknobs repository that has imgui-knobs project as submodule.

`-- cimknobs
    |-- cimknobs.h
    |-- examples
    |   `-- main.c
    |   `-- Makefile or CMakeLists.txt
    `-- imgui-knobs
        `__ ...
        `__ ...

I will fetch your cimknobs project to Imguin project same as cimgui/cimplot/... etc.
and I wiil add to cimgui.nim,

  when defined(ImKnobsEnable):
    {.passC:"-I" & CImKnobRootPath.}
    ...snip...

Nim header file of cimknobs will be auto generated by futhark and included incimgui.nim.

Build command may be

pwd 
imguin/examples/imknobs_opengl3
nim c -d:ImKnobsEnable imknobs_opengl3.nim

@system64MC
Copy link
Contributor Author

I think you should make for instance cimknobs repository that has imgui-knobs project as submodule.

`-- cimknobs
    |-- cimknobs.h
    |-- examples
    |   `-- main.c
    |   `-- Makefile or CMakeLists.txt
    `-- imgui-knobs
        `__ ...
        `__ ...

I will fetch your cimknobs project to Imguin project same as cimgui/cimplot/... etc. and I wiil add to cimgui.nim,

  when defined(ImKnobsEnable):
    {.passC:"-I" & CImKnobRootPath.}
    ...snip...

Nim header file of cimknobs will be auto generated by futhark and included incimgui.nim.

Build command may be

pwd 
imguin/examples/imknobs_opengl3
nim c -d:ImKnobsEnable imknobs_opengl3.nim

I added cimgui knobs into my Imguin fork like what you did for the others ImGUI extensions. Is that OK?
I also sent a pull request.

@dinau
Copy link
Owner

dinau commented Dec 12, 2024

Thank you PR.
I'll check that and merge within a few days.

@dinau dinau closed this as completed Dec 13, 2024
@dinau
Copy link
Owner

dinau commented Dec 13, 2024

Done.

@system64MC
Copy link
Contributor Author

Done.

Thanks! I will have a look!

Do you also know how I can statically link the glibc / glibc++ or how I can use musl please? I'm concerned about compatibility with older Linux distros.

@dinau
Copy link
Owner

dinau commented Dec 14, 2024

I'm not familiar with static link on Linux,
but I know it generally is very difficult on Linux :-)

  • First
    Whether can this example be compiled or not on Linux with static link,
    cimgui:example_glfw_opengl3
  • Second
    If an application uses the nimble libraries, at least the libraires have to be appropriately compiled with static link option on Linux.

@dinau dinau reopened this Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants