mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-04 10:07:58 +00:00
Can't build example on Linux invalid conversion from ‘void (*)()’ to ‘void*’ #411
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#411
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.csdl2-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.csdl2-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.
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.csdl2-config --libs-lGL -ldl -o sdl2exampleSorry 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?
change to
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.csdl2-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.