Closed jjn555 closed 5 years ago
Thanks for your report. I have not access to any cl version that is supported by Dear ImGui, so I can help very little. Anyway:
Let's start with the first example main.cpp: You say:
main.cpp however compiles fine and I can generate the executable with this:
cl /Feimguiaddon.exe /I . /I .. /I ..\addons /DIMGUI_INCLUDE_IMGUI_USER_H /DIMGUI_INCLUDE_IMGUI_USER_INL /DIMGUI_USE_WINAPI_BINDING /DIMGUI_USE_GL3W /DIMIMPL_SHADER_GL3 gl3w.c ..\imgui.cpp ..\imgui_demo.cpp ..\imgui_draw.cpp imgui_impl_win32.cpp main.cpp version.lib winmm.lib shell32.lib gdi32.lib ole32.lib advapi32.lib oleaut32.lib Opengl32.lib
Why do you need imgui_impl_win32.cpp? Can you please try this instead and see if it works:
cl /Feimguiaddon.exe /I . /I .. /I ..\addons /DIMGUI_INCLUDE_IMGUI_USER_H /DIMGUI_USE_WINAPI_BINDING /DIMGUI_USE_GL3W /DIMIMPL_SHADER_GL3 gl3w.c ..\imgui.cpp ..\imgui_draw.cpp ..\imgui_demo.cpp main.cpp version.lib winmm.lib shell32.lib gdi32.lib ole32.lib advapi32.lib oleaut32.lib Opengl32.lib
Now for the second example main2.cpp, I'd try something like:
cl /Feimguiaddon2.exe /I . /I .. /I ..\addons /DIMGUI_INCLUDE_IMGUI_USER_H /DIMGUI_USE_WINAPI_BINDING /DIMGUI_USE_GL3W /DIMIMPL_SHADER_GL3 gl3w.c ..\imgui.cpp ..\imgui_draw.cpp main2.cpp version.lib winmm.lib shell32.lib gdi32.lib ole32.lib advapi32.lib oleaut32.lib Opengl32.lib
However I can't be sure it works, because don't have access to any Visual C++ compiler that can be used to compile Dear ImGui (at the moment Visual C++ 2010 or upper, as far as I know).
I have mingw I can use to see if it works... I'll try and see if a corresponding command line works in mingw or not soon.
P.S. I've removed /DIMGUI_INCLUDE_IMGUI_USER_INL
because it is implicitly defined together with /DIMGUI_INCLUDE_IMGUI_USER_H
.
By using mingw on Ubuntu-Linux, I've just been able to compile both main.cpp and main2.cpp. So they should work using mingw.
As a reference: here are the command lines I've used from Linux (mingw command-lines on Windows should be similar):
x86_64-w64-mingw32-g++ -O2 -mwindows -I"../libs/gl3w" ../libs/gl3w/GL/gl3w.c -fpermissive ../../imgui.cpp ../../imgui_draw.cpp ../../imgui_demo.cpp main.cpp -o imgui_addons_example1.exe -fexceptions -DIMGUI_INCLUDE_IMGUI_USER_H -DIMIMPL_SHADER_GL3 -DIMGUI_USE_WINAPI_BINDING -DIMGUI_USE_GL3W -DWINVER=0x0800 -D_WIN32 -D_WIN64 -I"." -I"../.." -static-libgcc -static-libstdc++ -lopengl32 -limm32 -luser32 -lkernel32 -s
and:
x86_64-w64-mingw32-g++ -O2 -mwindows -I"../libs/gl3w" ../libs/gl3w/GL/gl3w.c -fpermissive ../../imgui.cpp ../../imgui_draw.cpp main2.cpp -o imgui_addons_example2.exe -fexceptions -DIMGUI_INCLUDE_IMGUI_USER_H -DIMIMPL_SHADER_GL3 -DIMGUI_USE_WINAPI_BINDING -DIMGUI_USE_GL3W -DWINVER=0x0800 -D_WIN32 -D_WIN64 -I"." -I"../.." -static-libgcc -static-libstdc++ -lopengl32 -limm32 -luser32 -lkernel32 -s
They work, even if I had to add -fpermissive
to fix a line in ../libs/gl3w/GL/gl3w.c
(probably caused by the fact that we're compiling it as a c++ file?!).
P.S. If I compile using glew (instead of gl3w) everything works without -fpermissive
(but glew is not bundled with Dear ImGui, so it needs to be present somewhere on the HD as a library).
[Edit] According to this link, gcc-based compilers don't allow compiling .c and .cpp files together according to their extension in a single command-line, so to remove -fpermissive in the command-line above, we need 3 lines (two compilations and one link)... that's bad (a specific option, or x86_64-w64-mingw32-gcc that could still compile .cpp files as c++ would have been better IMO).
When compiling main.cpp using your suggestion (remove imgui_impl_win32.cpp and /DIMGUI_INCLUDE_IMGUI_USER_INL from the command line), this works correctly again.
main2.cpp compile is still hanging when compiling without /DIMGUI_INCLUDE_IMGUI_USER_INL, imgui_demo.cpp, and imgui_impl_win32.cpp in the command line.
Same thing happens using glew instead of gl3w as well - main.cpp compiles fine while main2.cpp compile hangs.
When compiling main.cpp using your suggestion (remove imgui_impl_win32.cpp and /DIMGUI_INCLUDE_IMGUI_USER_INL from the command line), this works correctly again.
Good. That's the way it should be done.
main2.cpp compile is still hanging when compiling without /DIMGUI_INCLUDE_IMGUI_USER_INL, imgui_demo.cpp, and imgui_impl_win32.cpp in the command line.
Well, without any error log it's hard to guess what's happening... And what does 'hangs' mean for you? a cl.exe crash without any further info, or a never-ending compilation you have to manually quit?
It is the never-ending compilation.
It is the never-ending compilation.
Mmmh, then I would try adding different optimization flags and see if any of them works.
For example /Os
or /O1
or /O2
or /Og
... hoping something shows up in the console.
Have played with a few optimization flags but no luck so far. Also, how easy is it to change the underlying renderer to directx for more compatibility with various versions of windows?
Have played with a few optimization flags but no luck so far.
Maybe some other Windows user can help, or you can also try mingw (*).
Also, how easy is it to change the underlying renderer to directx for more compatibility with various versions of windows?
Well, the version of Direct3D9 that is available in imguibindings is a bit old, and was tested only with a very old version of the DirectX SDK: so I don't know how easy is to make it work... Anyway, the command-line is still present in README_FIRST.txt and it was something like:
cl /nologo /O2 /MT /I"../../" ../../imgui.cpp ../../imgui_draw.cpp ../../imgui_demo.cpp main.cpp /D"IMGUI_INCLUDE_IMGUI_USER_H" /D"IMGUI_USE_DIRECT3D9_BINDING" /D"WINVER=0x0501" /D"_WIN32_WINNT=0x0501" /link /out:imgui_addons_example1.exe d3d9.lib d3dx9.lib gdi32.lib Shell32.lib advapi32.lib user32.lib kernel32.lib
You can try converting it to your specific version of cl.exe, if you like.
However you asked:
for more compatibility with various versions of windows?
Well, then I think that an old version of Direct3D9 is not good enough for you.
Unluckily I cannot help anymore on Windows, because I've switched to Linux a few years ago.
In my opinion, OpenGLES2/WebGL is the most portable 3D API ever made, followed by OpenGLES3/WebGL2. So I'd stick to OpenGL if you're looking for general portability.
(*) About mingw, I remember that when I was a Windows user, I used this distro. It was extremely easy to use, but I'm not sure if it's still updated or not.
Wanted to provide an update on this. main2.cpp does compile with Visual C++ 2010, but it seems to take several hours to finish while main.cpp only took seconds. I was also successfully able to build using Direct3D9. Thank you very much for your help!
Thank you for your feedback!
main2.cpp does compile with Visual C++ 2010, but it seems to take several hours to finish while main.cpp only took seconds.
After thinking about it for a while: maybe the definition in main2.cpp at line 13, used to include FontAwesome4 can be (manually) commented out to speed up compilation. Have you tried it ?
With #define TEST_ICONS_INSIDE_TTF commented out, it still takes a few hours for the compile to finish.
With #define TEST_ICONS_INSIDE_TTF commented out, it still takes a few hours for the compile to finish.
O.K., I can't understand why it's so slow then... Thanks for testing it.
Version/Branch of Dear ImGui: Version: Dear IMGUI 1.69 WIP Branch: addons
Back-end/Renderer/Compiler/OS Back-ends: win32 + gl3w Compiler: Visual C++ 2010 Operating System: Windows 7 X64
My Issue/Question: Visual C++ 2010 hangs when trying to compile main2.cpp in addons_examples Command line used is: cl /I . /I .. /I ..\addons /DIMGUI_INCLUDE_IMGUI_USER_H /DIMGUI_INCLUDE_IMGUI_USER_INL /DIMGUI_USE_WINAPI_BINDING /DIMGUI_USE_GL3W /DIMIMPL_SHADER_GL3 main2.cpp
main.cpp however compiles fine and I can generate the executable with this: cl /Feimguiaddon.exe /I . /I .. /I ..\addons /DIMGUI_INCLUDE_IMGUI_USER_H /DIMGUI_INCLUDE_IMGUI_USER_INL /DIMGUI_USE_WINAPI_BINDING /DIMGUI_USE_GL3W /DIMIMPL_SHADER_GL3 gl3w.c ..\imgui.cpp ..\imgui_demo.cpp ..\imgui_draw.cpp imgui_impl_win32.cpp main.cpp version.lib winmm.lib shell32.lib gdi32.lib ole32.lib advapi32.lib oleaut32.lib Opengl32.lib
Screenshots/Video Standalone, minimal, complete and verifiable example: _(see ```