-
Notifications
You must be signed in to change notification settings - Fork 10
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
The example crashes on Linux with -11 error code #13
Comments
I feel like this might be related to #8, I'll take a look, it might take a bit. |
It is not entirely related. This issue can be fixed by building cimgui with a modified build script. Ideally we want to track down the shortcommings of our build script so that it works on Linux too and builds using Linux sensibilities (not compiling SDL2, etc. from source) |
|
The modified build script I wrote for cimgui's CMakeLists.txt cmake_minimum_required(VERSION 3.1)
project(cimgui)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_tables.cpp)
set(TABLES_SOURCE "imgui/imgui_tables.cpp")
else()
set(TABLES_SOURCE "")
endif()
#general settings
file(GLOB IMGUI_SOURCES
cimgui.cpp
imgui/imgui.cpp
imgui/imgui.h
imgui/imgui_draw.cpp
imgui/imgui_demo.cpp
imgui/imgui_internal.h
imgui/imgui_widgets.cpp
${TABLES_SOURCE}
)
set(IMGUI_STATIC "no" CACHE STRING "Build as a static library")
set(IMGUI_FREETYPE "yes" CACHE STRING "Build with freetype library")
set(IMGUI_FREETYPE_IN_TREE "no" CACHE STRING "freetype library is being build in-tree")
set(IMGUI_LIBRARIES )
if(IMGUI_FREETYPE)
if (NOT IMGUI_FREETYPE_IN_TREE)
#FIND_PACKAGE(freetype REQUIRED PATHS ${FREETYPE_PATH})
FIND_PACKAGE(Freetype REQUIRED)
endif ()
list(APPEND IMGUI_LIBRARIES Freetype::Freetype)
list(APPEND IMGUI_SOURCES imgui/misc/freetype/imgui_freetype.cpp)
add_definitions("-DCIMGUI_FREETYPE=1")
add_definitions("-DIMGUI_ENABLE_FREETYPE=1")
add_definitions("-DIMGUI_ENABLE_STB_TRUETYPE=1")
endif(IMGUI_FREETYPE)
#add library and link
if (IMGUI_STATIC)
add_library(cimgui STATIC ${IMGUI_SOURCES})
else (IMGUI_STATIC)
add_library(cimgui SHARED ${IMGUI_SOURCES})
endif (IMGUI_STATIC)
target_compile_definitions(cimgui PUBLIC IMGUI_DISABLE_OBSOLETE_FUNCTIONS=1)
if (WIN32)
target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API=extern\t\"C\"\t__declspec\(dllexport\))
list(APPEND IMGUI_LIBRARIES imm32)
else (WIN32)
target_compile_definitions(cimgui PUBLIC IMGUI_IMPL_API=extern\t\"C\"\t)
endif (WIN32)
set(IMGUI_SDL_IN_TREE "no" CACHE STRING "SDL library is being build in-tree")
set(IMGUI_SDL "yes" CACHE STRING "Build with SDL")
set(IMGUI_OPENGL2 "no" CACHE STRING "Build with OpenGL2")
set(IMGUI_OPENGL3 "yes" CACHE STRING "Build with OpenGL3")
if (IMGUI_SDL)
if (NOT IMGUI_SDL_IN_TREE)
FIND_PACKAGE(SDL2 REQUIRED PATHS ${SDL2_PATH})
endif ()
target_sources(cimgui
PRIVATE
imgui/backends/imgui_impl_sdl.cpp
imgui/backends/imgui_impl_sdl.h
)
target_link_libraries(cimgui PRIVATE SDL2::SDL2)
endif()
if (IMGUI_OPENGL2)
target_sources(cimgui
PRIVATE
imgui/backends/imgui_impl_opengl2.cpp
imgui/backends/imgui_impl_opengl2.h
)
if (UNIX)
target_link_libraries(cimgui PRIVATE GL)
endif()
endif()
if (IMGUI_OPENGL3)
target_sources(cimgui
PRIVATE
imgui/backends/imgui_impl_opengl3.cpp
imgui/backends/imgui_impl_opengl3.h
imgui/backends/imgui_impl_opengl3_loader.h
)
if (UNIX)
target_link_libraries(cimgui PRIVATE GL)
endif()
endif()
target_include_directories(cimgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(cimgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)
set_target_properties(cimgui PROPERTIES PREFIX "")
target_link_libraries(cimgui PUBLIC ${IMGUI_LIBRARIES})
#install
install(TARGETS cimgui
RUNTIME DESTINATION .
LIBRARY DESTINATION .
ARCHIVE DESTINATION .
)
#test
set(CIMGUI_TEST "no" CACHE STRING "Enable compilation of a test unit based on imgui null")
if (CIMGUI_TEST)
add_subdirectory(test)
endif () As for SDL2 you have to comment out a section in its CMakeLists.txt file that handles not building in its source directory (for some reason all directories counts as the source directory for me) |
I guess there was something terribly wrong with my setup, because I did something and it works now. The problem is, I haven't quite managed to understand what exactly it was that I did and it helped. I didn't even use suggested modified build script. |
I have ran the example on a fresh install in a VM, getting error -11 again. It seems that something on my system actually fixes this instead of breaking. |
any updates? trying to get this running on linux myself, heh. it's totally fine if you haven't found anything, just curious. |
The build script I posted should make cimgui.so build. It's not pretty though. I have been investigating the root problem and I might give a shot fixing the build script over the weekend to work properly on Linux (as well as arm64 and macOS) |
I have built cimgui and SDL2 from scratch myself, and that seems to be fixing everything. Though the correct combination of building yourself and building from this binding is still a mystery to me |
How do I use that
|
Do you maybe not have the submodules cloned? There's several submodules in the deps directory. |
No, they're cloned. my command was, inside a cmake .. |
Issue is either that some distros call the SDL2 package SDL2 and some call it SDL2::SDL2 or you don't have SDL2 + it's development libraries on-system The build script I provided tries to use the system installed libraries instead of the cloned versions |
I have been trying to get the example to work on Linux for a few days now, and I'm genuinely stuck. Every time I run the example, I get acces violation at
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
. This only happens on my Linux laptop, on Windows the example runs perfectly.I have tried SDL backend examlpe of
cimgui
itself, and it works smoothly, which leads me to believe the problem is inbindbc-imgui
.I have used
deps/CMakeLists.txt
to build necessary libraries, and I copied them to/usr/lib
.Does anyone know what could be causing the issue, or where I should look for additional info? The
errors
function ofbindbc-loader
returns nothing.The text was updated successfully, but these errors were encountered: