Closed anthonybakermpls closed 8 years ago
Found the fix: http://askubuntu.com/questions/334884/while-compiling-truecrypt-i-get-undefined-reference-to-symbol-dlcloseglibc
need -ldl in your build command in the readme for this.
c++ -fpermissive sdl2-config --cflags
-I ../.. -I ../libs/gl3w main.cpp imgui_impl_sdl_gl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c sdl2-config --libs
-lGL -ldl -o sdl2example
Sorry I don't use github that much.. I guess I should leave this open with a suggested fix? I don't really even know how to do pull requests.
solution is to add -ldl to build command in your readme for this.
So does this mean imgui doesn't support opengl 3 natively or what is going on with these function mappings that cause this problem in the first place?
This code has nothing to do with imgui, gl3w is a wrapper to call OpenGL3 functions because modern OpenGL was designed to be tedious to use. (And thankfully libraries like gl3w are alleviating this pain)
How does the makefile for the opengl3 example perform for you? It also use gl3w.c and I haven't heard of issue with it (but I don't use Linux myself).
It looks like the problem is that gl3w.c is C not C++ and that code uses function pointer casting feature that is obsoleted in C++ and that file is compiled in C++ with the command-line.
Could you remove the permissive flag and try adding a cast to void* on line 85 of gl3w.c see if it fixes it?
res = glXGetProcAddress((const GLubyte *) proc);
change to
res = (void*)glXGetProcAddress((const GLubyte *) proc);
Thanks! If that fixes it we should probably submit the fix to https://github.com/skaslev/gl3w
If I put that explicit cast in there, remove -fpermissive and the -ldl switches, it doesn't error or warn on the assignment but it breaks on the dlclose symbol.
c++ sdl2-config --cflags
-I ../.. -I ../libs/gl3w main.cpp imgui_impl_sdl_gl3.cpp ../../imgui*.cpp ../libs/gl3w/GL/gl3w.c sdl2-config --libs
-lGL -o sdl2example
/usr/bin/ld: /tmp/ccuwMg9O.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Yeah, -ldl is still required by gl3w on Linux so I added that to the README and will add the cast now. Thanks!
oh, and it looks like -fpermissive is required too with the -ldl. The makefile with the opengl3 example works perfectly I was comparing that before to try and figure out why that worked and this one didn't but I couldn't see anything.
This looks like a really cool library. Thanks for sharing it.
Sorry - can you clarify, even with the explicit cast -fpermissive is required? You are still getting the same error/warning with the cast? (I'd rather fix gl3w here than suggest that a flag is required).
(The Makefile will use regular C compiler for the .c file where the command-line uses C++ for both)
Okay, with explicit cast in gl3w.c, -fpermissive is not needed but -ldl is required.
Thanks, fixed now. By looking at gl3w it looks like they have actually fixed the code in the recent versions and I'm not up to date there because I just grabbed a pregenerated gl3w.c from somewhere.
I'd rather not update it right now because every minor changes related to building examples it causing new issues of this kind.
Trying to build the SDL opengl 3 example gives the following error:
$c++
sdl2-config --cflags
-I ../.. -I ../libs/gl3w main.cpp imgui_impl_sdlgl3.cpp ../../imgui.cpp ../libs/gl3w/GL/gl3w.csdl2-config --libs
-lGL -o sdl2example ../libs/gl3w/GL/gl3w.c: In function ‘void_ getproc(const char)’: ../libs/gl3w/GL/gl3w.c:85:25: error: invalid conversion from ‘void (_)()’ to ‘void’ [-fpermissive] res = glXGetProcAddress((const GLubyte ) proc);when i do -fpermissive:
$c++ -fpermissive
sdl2-config --cflags
-I ../.. -I ../libs/gl3w main.cpp imgui_impl_sdlgl3.cpp ../../imgui.cpp ../libs/gl3w/GL/gl3w.csdl2-config --libs
-lGL -o sdl2example../libs/gl3w/GL/gl3w.c: In function ‘void_ getproc(const char)’: ../libs/gl3w/GL/gl3w.c:85:25: warning: invalid conversion from ‘void (_)()’ to ‘void’ [-fpermissive] res = glXGetProcAddress((const GLubyte ) proc); ^ /usr/bin/ld: /tmp/ccT2hT7y.o: undefined reference to symbol 'dlclose@@GLIBC_2.2.5' /lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status
Note the sdl_opengl_example/ works fine.