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

OpenGL3 Example code not running | Linux x64 #3507

Closed
immehulsolanki opened this issue Oct 4, 2020 · 2 comments
Closed

OpenGL3 Example code not running | Linux x64 #3507

immehulsolanki opened this issue Oct 4, 2020 · 2 comments

Comments

@immehulsolanki
Copy link

immehulsolanki commented Oct 4, 2020

Hi,

I just found out about this awesome library from you tube, and i wanted to give it a try to check whether it fulfills my requirements.

So i downloaded this imgui c++ library with git clone command and placed the folder on the desktop.
Then first i thing i did was to read official and unofficial documentation for installation and integration purpose.

It took me 2 days to simply just run the example, and trying all of them one by one finally SDL2 + OpenGL2 (example_sdl_opengl2) ran successfully.
What i did is simply copy and past the command from readme file and that's it.

But SDL + OpenGL3 (example_sdl_opengl3) example does not work.
As stated above i also copy pasted command from readme.

Original:
c++ sdl2-config --cflags-I .. -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.csdl2-config --libs-lGL -ldl

command i ran:
sudo g++ sdl2-config --cflags-I .. -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.csdl2-config --libs -lGL -ldl

I found out that each of that examples required proper dependency and Os environment setup in order to run.
So i install all related libs as per my understanding.

Here is the list of libs installed in my system debian10 x64:

$ ls /usr/include/GL
freeglut_ext.h  glcorearb.h  gl.h         glu_mangle.h  glxext.h  glx_mangle.h  glxtokens.h
freeglut.h      glew.h       gl_mangle.h  glut.h        glx.h     glxmd.h       internal
freeglut_std.h  glext.h      glu.h        glxew.h       glxint.h  glxproto.h    wglew.h

At first it gave me lots of errors as follows:

developer@debian:~/Desktop/dimgui/imgui/examples/example_sdl_opengl3$ sudo g++ `sdl2-config --cflags` -I .. -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -lGL -ldl
[sudo] password for developer: 
/usr/bin/ld: /tmp/ccomwQMJ.o: in function `main':
main.cpp:(.text+0x123): undefined reference to `glewInit'
/usr/bin/ld: /tmp/cc0ZCDGv.o: in function `ImGui_ImplOpenGL3_SetupRenderState(ImDrawData*, int, int, unsigned int)':
imgui_impl_opengl3.cpp:(.text+0x17e): undefined reference to `__glewBlendEquation'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x356): undefined reference to `__glewUseProgram'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x367): undefined reference to `__glewUniform1i'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x37d): undefined reference to `__glewUniformMatrix4fv'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x3aa): undefined reference to `__glewBindSampler'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x3bd): undefined reference to `__glewBindVertexArray'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x3cb): undefined reference to `__glewBindBuffer'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x3e1): undefined reference to `__glewBindBuffer'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x3f7): undefined reference to `__glewEnableVertexAttribArray'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x408): undefined reference to `__glewEnableVertexAttribArray'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x419): undefined reference to `__glewEnableVertexAttribArray'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x42a): undefined reference to `__glewVertexAttribPointer'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x454): undefined reference to `__glewVertexAttribPointer'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x47e): undefined reference to `__glewVertexAttribPointer'
/usr/bin/ld: /tmp/cc0ZCDGv.o: in function `ImGui_ImplOpenGL3_RenderDrawData(ImDrawData*)':
imgui_impl_opengl3.cpp:(.text+0x528): undefined reference to `__glewActiveTexture'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x67e): undefined reference to `__glewGenVertexArrays'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x70e): undefined reference to `__glewBufferData'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x748): undefined reference to `__glewBufferData'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x981): undefined reference to `__glewDrawElementsBaseVertex'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x9f6): undefined reference to `__glewDeleteVertexArrays'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xa0e): undefined reference to `__glewUseProgram'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xa38): undefined reference to `__glewBindSampler'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xa4b): undefined reference to `__glewActiveTexture'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xa59): undefined reference to `__glewBindVertexArray'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xa67): undefined reference to `__glewBindBuffer'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xa7a): undefined reference to `__glewBlendEquationSeparate'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xa93): undefined reference to `__glewBlendFuncSeparate'
/usr/bin/ld: /tmp/cc0ZCDGv.o: in function `CheckShader(unsigned int, char const*)':
imgui_impl_opengl3.cpp:(.text+0xcc6): undefined reference to `__glewGetShaderiv'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xcdd): undefined reference to `__glewGetShaderiv'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xd42): undefined reference to `__glewGetShaderInfoLog'
/usr/bin/ld: /tmp/cc0ZCDGv.o: in function `CheckProgram(unsigned int, char const*)':
imgui_impl_opengl3.cpp:(.text+0xde9): undefined reference to `__glewGetProgramiv'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xe00): undefined reference to `__glewGetProgramiv'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0xe6c): undefined reference to `__glewGetProgramInfoLog'
/usr/bin/ld: /tmp/cc0ZCDGv.o: in function `ImGui_ImplOpenGL3_CreateDeviceObjects()':
imgui_impl_opengl3.cpp:(.text+0x1045): undefined reference to `__glewCreateShader'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1059): undefined reference to `__glewShaderSource'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1076): undefined reference to `__glewCompileShader'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x10be): undefined reference to `__glewCreateShader'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x10d2): undefined reference to `__glewShaderSource'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x10ef): undefined reference to `__glewCompileShader'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1114): undefined reference to `__glewCreateProgram'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1123): undefined reference to `__glewAttachShader'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x113c): undefined reference to `__glewAttachShader'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1155): undefined reference to `__glewLinkProgram'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x117a): undefined reference to `__glewGetUniformLocation'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1198): undefined reference to `__glewGetUniformLocation'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x11b6): undefined reference to `__glewGetAttribLocation'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x11d4): undefined reference to `__glewGetAttribLocation'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x11f2): undefined reference to `__glewGetAttribLocation'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1210): undefined reference to `__glewGenBuffers'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1225): undefined reference to `__glewGenBuffers'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x124e): undefined reference to `__glewBindBuffer'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1261): undefined reference to `__glewBindVertexArray'
/usr/bin/ld: /tmp/cc0ZCDGv.o: in function `ImGui_ImplOpenGL3_DestroyDeviceObjects()':
imgui_impl_opengl3.cpp:(.text+0x1284): undefined reference to `__glewDeleteBuffers'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x12ad): undefined reference to `__glewDeleteBuffers'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x12e0): undefined reference to `__glewDetachShader'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x130d): undefined reference to `__glewDetachShader'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1330): undefined reference to `__glewDeleteShader'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x1355): undefined reference to `__glewDeleteShader'
/usr/bin/ld: imgui_impl_opengl3.cpp:(.text+0x137a): undefined reference to `__glewDeleteProgram'
collect2: error: ld returned 1 exit status

But this was resolved by simply adding one command:
-lGLEW
in capital letters , in small letter it won't work!!!

So new command look like:
$ sudo g++ sdl2-config --cflags-I .. -I ../.. -I ../libs/gl3w main.cpp ../imgui_impl_sdl.cpp ../imgui_impl_opengl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.csdl2-config --libs-lGL -ldl -lGLEW

Now output file was generated sucessfully!
./a.out

but in output it just flashes the screen and closes with one error as stated below:

$ ./a.out
Failed to initialize OpenGL loader!

i know there is some silly mistake i done as non CS guy, probably some linking mechanism which i dont understand, but consider me i can copy past command and run the program then later on i twick origional code untill it fulfills my requirements.

It would be great if outbox running code support for LINUX will be given, so i can use this in my realtime machinevision applications. Like: sample code with VSCode IDE or other which simply just run if i follow certain steps.

Thank You,

@ocornut
Copy link
Owner

ocornut commented Oct 5, 2020

Did you try just running make in that folder?

@immehulsolanki
Copy link
Author

Sorry for the inconvenience,

I was testing inside virtualbox (V6.1.14).
I think its VirtualBox problem or limitation that it only supports up to OpenGL 2.1.
Actual version in my virtual machine is OpenGL 2.1 Mesa 18.3.6.

My main or host OS is windows10 with OpenGL 4.3 (Graphics: Intel iGPU -HD 4600 V20.19.15.4531)

I explored both files main.cpp (opengl3 example), imgui_impl_opengl3.cpp and .h. line by line.
Also try to enforce gl3w standalone lib (gl3w.cpp and .h libs) from imconfig.h but its not working.

Here is the O/P of make command inside example folder.

1

Terminal O/P:

developer@debian:~/Desktop/dimgui/imgui/examples/example_sdl_opengl3$ sudo make
g++ -I../ -I../../ -g -Wall -Wformat -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W `sdl2-config --cflags` -c -o main.o main.cpp
g++ -I../ -I../../ -g -Wall -Wformat -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W `sdl2-config --cflags` -c -o imgui_impl_sdl.o ../imgui_impl_sdl.cpp
g++ -I../ -I../../ -g -Wall -Wformat -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W `sdl2-config --cflags` -c -o imgui_impl_opengl3.o ../imgui_impl_opengl3.cpp
g++ -I../ -I../../ -g -Wall -Wformat -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W `sdl2-config --cflags` -c -o imgui.o ../../imgui.cpp
g++ -I../ -I../../ -g -Wall -Wformat -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W `sdl2-config --cflags` -c -o imgui_demo.o ../../imgui_demo.cpp
g++ -I../ -I../../ -g -Wall -Wformat -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W `sdl2-config --cflags` -c -o imgui_draw.o ../../imgui_draw.cpp
g++ -I../ -I../../ -g -Wall -Wformat -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W `sdl2-config --cflags` -c -o imgui_widgets.o ../../imgui_widgets.cpp
cc -I../ -I../../ -g -Wall -Wformat -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W `sdl2-config --cflags` -c -o gl3w.o ../libs/gl3w/GL/gl3w.c
g++ -o example_sdl_opengl3 main.o imgui_impl_sdl.o imgui_impl_opengl3.o imgui.o imgui_demo.o imgui_draw.o imgui_widgets.o gl3w.o -I../ -I../../ -g -Wall -Wformat -I../libs/gl3w -DIMGUI_IMPL_OPENGL_LOADER_GL3W `sdl2-config --cflags`  -lGL -ldl `sdl2-config --libs`
Build complete for Linux

Same problem...

So, I guess its hardware limitation (VirtualBox), I will final update once I test it on actual O.S as dual boot.

Thank you for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants