pthom / hello_imgui

Hello, Dear ImGui: unleash your creativity in app development and prototyping
https://pthom.github.io/hello_imgui
MIT License
607 stars 91 forks source link

some linux issues #6

Closed icedman closed 1 year ago

icedman commented 3 years ago

my system: arch linux, dell xps 13

desktop: SDL opengl: issue: can't build with SDL2::SDL2-static my workaround: build with SDL2::SDL2

android: issue: assets are not automatically copied workaround: manually copy assets to app/src/main

icedman commented 3 years ago

android: issue: crash SDL (looking for shared object) workaround: build with sdl2_shared instead of sdl2_static

pthom commented 3 years ago

desktop: SDL opengl: issue: can't build with SDL2::SDL2-static my workaround: build with SDL2::SDL2

Out of curiosity, how did you install SDL? Vcpkg, global install, subrepo? The code was tested with subrepo + vcpkg, but not global install. I just pushed a commit that links with SDL::SDL.

android: issue: crash SDL (looking for shared object) workaround: build with sdl2_shared instead of sdl2_static

I do not understand the source of your issue: under android, the CMakeLists specifies to link with SDL2main + SDL2, not sdl2_static. See src/hello_imgui/CMakeLists.txt at line 72:

 elseif(ANDROID)
        target_link_libraries(${target_name} PUBLIC SDL2main SDL2)
        target_link_libraries(${target_name} PUBLIC GLESv3)

Can you make sure you followed the instructions for the SDL install, and please give more explanations on your workaround and the problem you experienced?

android issue: assets are not automatically copied

assets are copied when you run cmake, not at build time Did you re-run cmake after adding assets?

If so, could you please enable the logs inside hello_imgui_cmake/assets/hello_imgui_assets.cmake and tell me what you see:

Edit hello_imgui_cmake/assets/hello_imgui_assets.cmake at line 40, and add the line mentioned below:

elseif(ANDROID)

    function(hello_imgui_bundle_assets app_name assets_folder)
        message("hello_imgui_bundle_assets ${app_name} ${assets_folder}")
        FILE(GLOB children ${assets_folder}/*)
        # message(FATAL_ERROR "HELLO_IMGUI_ANDROID_ASSETS_FOLDER=${HELLO_IMGUI_ANDROID_ASSETS_FOLDER}")
        if (DEFINED HELLO_IMGUI_ANDROID_ASSETS_FOLDER)
            foreach(child ${children})
                message(VERBOSE "    Copying ${child}")
                FILE(COPY ${child} DESTINATION ${HELLO_IMGUI_ANDROID_ASSETS_FOLDER})

               ### ADD THIS LINE ###
                message("FILE(COPY ${child} DESTINATION ${HELLO_IMGUI_ANDROID_ASSETS_FOLDER})")

            endforeach()
        endif()
    endfunction()
icedman commented 3 years ago

Hello, i revisited imgui this time using vcpkg : no problems at all building under linux (When not using vcpkg dlclose is undefined reference)

icedman commented 3 years ago

On android:

This fixed the assets problem: message("FILE(COPY ${child} DESTINATION ${HELLO_IMGUI_ANDROID_ASSETS_FOLDER})")

But running on the emulator, I still get the SDL Error . dlopen failed libc++_shared.so

So I'm still using the previous workaround on build.grade: arguments "-DANDROID_APP_PLATFORM=android-16", "-DANDROID_STL=c++_shared"

_shared instead of _static .. My emulator is at android-25. I vaguely remember googling that for higher android versions STL _shared should be used. But I'm no longer so sure.