前提・実現したいこと
Android用の動的ライブラリを生成しUnity上で使えるようにしたいです。
私は現在OpenAL-Softをubuntu(linux)上でビルドして動的ライブラリを生成し、UnityプロジェクトにPluginさせて使用したいのですがうまくいきません…最終的にはUnityプロジェクトをAndroidスマートフォンにのせて音を再生させたいのですが…
発生している問題・エラーメッセージ
OpenAL-Softのビルドはhttps://github.com/kcat/openal-softで提供されてるプロジェクトをもとに
ubuntu(linux)上でビルドさせlibopenal.soの生成まで行いました。
これをUnity上にplugin(Assets/Plugins/Android/libs/armeabi-v7a/libopenal.so)させてAndroid Device Monitorを使って確認してみたのですが次のエラーが発生します。
09-27 14:12:34.231: D/ViewRootImpl@a28921a[UnityPlayerActivity](9538): setView = DecorView@9e6514b[UnityPlayerActivity] TM=true MM=false 09-27 14:12:34.242: D/ViewRootImpl@a28921a[UnityPlayerActivity](9538): dispatchAttachedToWindow 09-27 14:12:34.251: D/ViewRootImpl@a28921a[UnityPlayerActivity](9538): Relayout returned: old=[0,0][0,0] new=[0,0][1080,2220] result=0x7 surface={valid=true 3818893312} changed=true 09-27 14:12:34.259: D/ViewRootImpl@a28921a[UnityPlayerActivity](9538): MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1080, 2220) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1 09-27 14:12:34.259: D/ViewRootImpl@a28921a[UnityPlayerActivity](9538): MSG_WINDOW_FOCUS_CHANGED 1 09-27 14:12:34.289: D/ViewRootImpl@a28921a[UnityPlayerActivity](9538): Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x7 surface={valid=true 3735711744} changed=true 09-27 14:12:34.303: I/Unity(9538): SystemInfo CPU = ARMv7 VFPv3 NEON, Cores = 8, Memory = 3458mb 09-27 14:12:34.303: I/Unity(9538): SystemInfo ARM big.LITTLE configuration: 4 big (mask: 0xf0), 4 little (mask: 0xf) 09-27 14:12:34.304: I/Unity(9538): ApplicationInfo com.LogicLab_KJH version 0.1 build 3a51b84d-9314-41a3-8681-133a0c3cec5c 09-27 14:12:34.304: I/Unity(9538): Built from '2018.2/staging' branch, Version '2018.2.0f2 (787658998520)', Build type 'Release', Scripting Backend 'mono' 09-27 14:12:34.334: D/ViewRootImpl@a28921a[UnityPlayerActivity](9538): Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x1 surface={valid=true 3735711744} changed=false 09-27 14:12:34.437: D/Unity(9538): GL_EXT_debug_marker GL_ARM_rgba8 GL_ARM_mali_shader_binary GL_OES_depth24 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_EXT_read_format_bgra GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_standard_derivatives GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3 GL_OES_EGL_sync GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_required_internalformat GL_OES_vertex_array_object GL_OES_mapbuffer GL_EXT_texture_format_BGRA8888 GL_EXT_texture_rg GL_EXT_texture_type_2_10_10_10_REV GL_OES_fbo_render_mipmap GL_OES_element_index_uint GL_EXT_shadow_samplers GL_OES_texture_compression_astc GL_KHR_texture_compression_astc_ldr GL_KHR_texture_compression_astc_hdr GL_KHR_texture_compression_astc_sliced_3d GL_KHR_debug GL_EXT_occlusion_query_boolean GL_EXT_disjoint_timer_query GL_EXT_blend_minmax GL_EXT_discard_framebuffer GL_OES_get_program_binary GL_OES_texture_3D GL_EXT_texture_storage GL_EXT_multisampled_render_ 09-27 14:12:34.438: D/Unity(9538): to_texture GL_OES_surfaceless_context GL_OES_texture_stencil8 GL_EXT_shader_pixel_local_storage GL_ARM_shader_framebuffer_fetch GL_ARM_shader_framebuffer_fetch_depth_stencil GL_ARM_mali_program_binary GL_EXT_sRGB GL_EXT_sRGB_write_control GL_EXT_texture_sRGB_decode GL_EXT_texture_sRGB_R8 GL_EXT_texture_sRGB_RG8 GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_OES_texture_storage_multisample_2d_array GL_OES_shader_image_atomic GL_EXT_robustness GL_EXT_draw_buffers_indexed GL_OES_draw_buffers_indexed GL_EXT_texture_border_clamp GL_OES_texture_border_clamp GL_EXT_texture_cube_map_array GL_OES_texture_cube_map_array GL_OES_sample_variables GL_OES_sample_shading GL_OES_shader_multisample_interpolation GL_EXT_shader_io_blocks GL_OES_shader_io_blocks GL_EXT_tessellation_shader GL_OES_tessellation_shader GL_EXT_primitive_bounding_box GL_OES_primitive_bounding_box GL_EXT_geometry_shader GL_OES_geometry_shader GL_ANDROID_extension_pack_es31a GL_EXT_gpu_shader5 GL_OES_gpu_shader5 GL_EXT_texture 09-27 14:12:34.438: D/Unity(9538): _buffer GL_OES_texture_buffer GL_EXT_copy_image GL_OES_copy_image GL_EXT_shader_non_constant_global_initializers GL_EXT_color_buffer_half_float GL_EXT_color_buffer_float GL_EXT_YUV_target GL_OVR_multiview GL_OVR_multiview2 GL_OVR_multiview_multisampled_render_to_texture GL_KHR_robustness GL_KHR_robust_buffer_access_behavior GL_EXT_draw_elements_base_vertex GL_OES_draw_elements_base_vertex GL_EXT_protected_textures 09-27 14:12:37.062: D/ViewRootImpl@a28921a[UnityPlayerActivity](9538): Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x1 surface={valid=true 3735711744} changed=false 09-27 14:12:37.104: E/Unity(9538): Unable to find openal 09-27 14:12:37.121: D/ViewRootImpl@a28921a[UnityPlayerActivity](9538): Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x1 surface={valid=true 3735711744} changed=false 09-27 14:12:37.245: E/Unity(9538): DllNotFoundException: openal 09-27 14:12:37.245: E/Unity(9538): at (wrapper managed-to-native) call:open () 09-27 14:12:37.245: E/Unity(9538): at call.Start () [0x00000] in <filename unknown>:0 09-27 14:12:37.245: E/Unity(9538): 09-27 14:12:37.245: E/Unity(9538): (Filename: Line: -1)
"Unable to find openal"のように動的ライブラリを探せないみたいですが、この後の解決策が分かりません…(DllImport[openal]のようにlibと.soは除きました。)
該当のソースコード
OpenAL-SoftのビルドはXCompile-Android.txtの内容を少し修正し行ないました。
(cmake .. -DCMAKE_TOOLCHAIN_FILE=../XCompile-Android.txt -DHOST=/home/ユーザー名/Desktop/workbench/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi -DCMAKE_C_FLAGS="--sysroot=/home/ユーザー名/Desktop/workbench/android-ndk-r16b/platforms/android-16/arch-arm" -DCMAKE_CXX_FLAGS="--sysroot=/home/ユーザー名/Desktop/workbench/android-ndk-r16b/platforms/android-16/arch-arm")
以下は修正したXCompile-Android.txtです。
# Cross-compiling requires CMake 2.6 or newer. Example: # cmake .. -DCMAKE_TOOLCHAIN_FILE=../XCompile-Android.txt -DHOST=arm-linux-androideabi # Where 'arm-linux-androideabi' is the host prefix for the cross-compiler. If # you already have a toolchain file setup, you may use that instead of this # file. Make sure to set CMAKE_FIND_ROOT_PATH to where the NDK toolchain was # installed (e.g. "$ENV{HOME}/toolchains/arm-linux-androideabi-r10c-21"). # the name of the target operating system SET(CMAKE_SYSTEM_NAME Android) #LinuxからAndroidに修正 # which compilers to use for C and C++ SET(CMAKE_C_COMPILER "${HOST}-gcc") SET(CMAKE_CXX_COMPILER "${HOST}-g++") SET(CMAKE_RC_COMPILER "${HOST}-windres") SET(CMAKE_SYSTEM_VERSION 16) #追加 # here is the target environment located SET(CMAKE_FIND_ROOT_PATH /home/ユーザー名/Desktop/workbench/android-ndk-r16b/toolchains/arm-linux-androideabi-4.9) #パスを追加 # here is where stuff gets installed to SET(CMAKE_INSTALL_PREFIX "${CMAKE_FIND_ROOT_PATH}" CACHE STRING "Install path prefix, prepended onto install directories." FORCE) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search # programs in the host environment set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # set env vars so that pkg-config will look in the appropriate directory for # .pc files (as there seems to be no way to force using ${HOST}-pkg-config) set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") set(ENV{PKG_CONFIG_PATH} "") # Qt4 tools SET(QT_QMAKE_EXECUTABLE ${HOST}-qmake) SET(QT_MOC_EXECUTABLE ${HOST}-moc) SET(QT_RCC_EXECUTABLE ${HOST}-rcc) SET(QT_UIC_EXECUTABLE ${HOST}-uic) SET(QT_LRELEASE_EXECUTABLE ${HOST}-lrelease)
補足情報(FW/ツールのバージョンなど)
使用中のPC:mac OS X
開発環境:virtual machine ubuntu 18.04.1 Desktop (Linux)
Unity version:2018.2.0f2
Android Phone Architecture : ARM Cortex-A53
必ずOpenAL-Softを使用し音を再生させたいです…
あなたの回答
tips
プレビュー