Can't build example on Linux invalid conversion from ‘void (*)()’ to ‘void*’ #411

Closed
opened 2015-11-21 19:18:41 +00:00 by anthonybakermpls · 14 comments
anthonybakermpls commented 2015-11-21 19:18:41 +00:00 (Migrated from github.com)

Trying to build the SDL opengl 3 example gives the following error:

$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
../libs/gl3w/GL/gl3w.c: In function ‘void_ get_proc(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_sdl_gl3.cpp ../../imgui_.cpp ../libs/gl3w/GL/gl3w.c sdl2-config --libs -lGL -o sdl2example
../libs/gl3w/GL/gl3w.c: In function ‘void_ get_proc(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.

Trying to build the SDL opengl 3 example gives the following error: $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 ../libs/gl3w/GL/gl3w.c: In function ‘void_ get_proc(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_sdl_gl3.cpp ../../imgui_.cpp ../libs/gl3w/GL/gl3w.c `sdl2-config --libs` -lGL -o sdl2example ../libs/gl3w/GL/gl3w.c: In function ‘void_ get_proc(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.
anthonybakermpls commented 2015-11-22 15:45:59 +00:00 (Migrated from github.com)

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

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
anthonybakermpls commented 2015-11-22 15:48:01 +00:00 (Migrated from github.com)

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.

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.
anthonybakermpls commented 2015-11-22 15:49:35 +00:00 (Migrated from github.com)

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?

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?
ocornut commented 2015-11-22 15:59:32 +00:00 (Migrated from github.com)

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)

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)
ocornut commented 2015-11-22 16:01:40 +00:00 (Migrated from github.com)

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).

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).
ocornut commented 2015-11-22 16:05:01 +00:00 (Migrated from github.com)

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.

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.
ocornut commented 2015-11-22 16:13:36 +00:00 (Migrated from github.com)

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

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
anthonybakermpls commented 2015-11-22 17:01:54 +00:00 (Migrated from github.com)

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

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
ocornut commented 2015-11-22 17:06:33 +00:00 (Migrated from github.com)

Yeah, -ldl is still required by gl3w on Linux so I added that to the README and will add the cast now. Thanks!

Yeah, -ldl is still required by gl3w on Linux so I added that to the README and will add the cast now. Thanks!
anthonybakermpls commented 2015-11-22 17:06:46 +00:00 (Migrated from github.com)

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.

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.
anthonybakermpls commented 2015-11-22 17:07:40 +00:00 (Migrated from github.com)

This looks like a really cool library. Thanks for sharing it.

This looks like a really cool library. Thanks for sharing it.
ocornut commented 2015-11-22 17:08:47 +00:00 (Migrated from github.com)

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)

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)
anthonybakermpls commented 2015-11-22 17:15:18 +00:00 (Migrated from github.com)

Okay, with explicit cast in gl3w.c, -fpermissive is not needed but -ldl is required.

Okay, with explicit cast in gl3w.c, -fpermissive is not needed but -ldl is required.
ocornut commented 2015-11-22 17:18:25 +00:00 (Migrated from github.com)

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.

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.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#411
No description provided.