如何构建 OpenAL-Soft 并在 Android 版 Qt Creator 中进行设置

问题描述 投票:0回答:1

我没有找到如何构建 OpenAL-Soft 以从 Qt for Android 使用它的分步指南。

我尝试通过将 OpenAL-Soft 源代码复制到项目中来实现。我将 OpenAL-Soft 源代码复制到我的示例中。您可以从 DropBox 下载我的示例。我使用 Qt 6.2.4 和 OpenAL-Soft 1.23.1。请大家下载示例存档。尝试编译一下。谁更有经验,就能理解其中的错误。我的示例包含存档 openal-soft-1.23.1.zip 我将在论坛上分发这些示例。它对激励初学者有很大帮助。 OpenAL 包含处理 3D 音频的函数,这非常有吸引力。通过添加库源进行安装应该很容易(除了一些应该记录的细微差别之外),因为 Qt Creator 具有出色的“添加现有目录...”和“添加现有文件...”选项。如果此主题已关闭,请在主题在此链接中回答,或订阅它。我尝试为 Android 构建 OpenAL-Soft,但出现以下错误:https://github.com/DJLink/android-openal-soft/issues/1

我已经为 Box2D 完成了此操作,并且我的应用程序在具有相同代码库的 PC、模拟器和 Android 智能手机上运行。这是安装 Box2D 最简单、最快的方法。我只是将源代码复制到项目中,然后立即在 Android 和桌面之间切换来构建 APK 和 EXE。如果我包含了库,我会花费大量时间来弄清楚如何为 Android 构建以及如何在 Android 和桌面构建之间切换。

我不能只针对一个错误提出问题,因为这些错误可能相互依赖。也许有人也尝试将 OpenAL-Soft 作为源添加到他们的项目中,但遇到了相同的错误。

其中一些:

In file included from ..\openal-with-source-using-android-qt6-cpp\core\converter.h:10, from ..\openal-with-source-using-android-qt6-cpp\core\converter.cpp:4: ..\openal-with-source-using-android-qt6-cpp\core\mixer/defs.h:67:79: error: expected ',' or '...' before 'src' 67 | using ResamplerFunc = void(*)(const InterpState *state, const float *RESTRICT src, uint frac, | ^~~ ..\openal-with-source-using-android-qt6-cpp\core\mixer/defs.h:74:64: error: expected ',' or '...' before 'src'

稍后添加:

我添加了

#define RESTRICT

,我看到的错误更少了。有些文件有这一行 
#include "config.h"
,但该文件不在 OpenAL-Soft 源代码中。我添加了空的 
config.h
 文件。我认为如果您从源代码编译 OpenAL-Soft,则该文件必须由 CMake 生成。我发现 
config.h.in
 文件没有 
#define RESTRICT
:

配置..h.in

/* Define if deprecated EAX extensions are enabled */ #cmakedefine ALSOFT_EAX /* Define if HRTF data is embedded in the library */ #cmakedefine ALSOFT_EMBED_HRTF_DATA /* Define if we have the posix_memalign function */ #cmakedefine HAVE_POSIX_MEMALIGN /* Define if we have the _aligned_malloc function */ #cmakedefine HAVE__ALIGNED_MALLOC /* Define if we have the proc_pidpath function */ #cmakedefine HAVE_PROC_PIDPATH /* Define if we have the getopt function */ #cmakedefine HAVE_GETOPT /* Define if we have DBus/RTKit */ #cmakedefine HAVE_RTKIT /* Define if we have SSE CPU extensions */ #cmakedefine HAVE_SSE #cmakedefine HAVE_SSE2 #cmakedefine HAVE_SSE3 #cmakedefine HAVE_SSE4_1 /* Define if we have ARM Neon CPU extensions */ #cmakedefine HAVE_NEON /* Define if we have the ALSA backend */ #cmakedefine HAVE_ALSA /* Define if we have the OSS backend */ #cmakedefine HAVE_OSS /* Define if we have the PipeWire backend */ #cmakedefine HAVE_PIPEWIRE /* Define if we have the Solaris backend */ #cmakedefine HAVE_SOLARIS /* Define if we have the SndIO backend */ #cmakedefine HAVE_SNDIO /* Define if we have the WASAPI backend */ #cmakedefine HAVE_WASAPI /* Define if we have the DSound backend */ #cmakedefine HAVE_DSOUND /* Define if we have the Windows Multimedia backend */ #cmakedefine HAVE_WINMM /* Define if we have the PortAudio backend */ #cmakedefine HAVE_PORTAUDIO /* Define if we have the PulseAudio backend */ #cmakedefine HAVE_PULSEAUDIO /* Define if we have the JACK backend */ #cmakedefine HAVE_JACK /* Define if we have the CoreAudio backend */ #cmakedefine HAVE_COREAUDIO /* Define if we have the OpenSL backend */ #cmakedefine HAVE_OPENSL /* Define if we have the Oboe backend */ #cmakedefine HAVE_OBOE /* Define if we have the Wave Writer backend */ #cmakedefine HAVE_WAVE /* Define if we have the SDL2 backend */ #cmakedefine HAVE_SDL2 /* Define if we have dlfcn.h */ #cmakedefine HAVE_DLFCN_H /* Define if we have pthread_np.h */ #cmakedefine HAVE_PTHREAD_NP_H /* Define if we have malloc.h */ #cmakedefine HAVE_MALLOC_H /* Define if we have cpuid.h */ #cmakedefine HAVE_CPUID_H /* Define if we have intrin.h */ #cmakedefine HAVE_INTRIN_H /* Define if we have guiddef.h */ #cmakedefine HAVE_GUIDDEF_H /* Define if we have initguid.h */ #cmakedefine HAVE_INITGUID_H /* Define if we have GCC's __get_cpuid() */ #cmakedefine HAVE_GCC_GET_CPUID /* Define if we have the __cpuid() intrinsic */ #cmakedefine HAVE_CPUID_INTRINSIC /* Define if we have SSE intrinsics */ #cmakedefine HAVE_SSE_INTRINSICS /* Define if we have pthread_setschedparam() */ #cmakedefine HAVE_PTHREAD_SETSCHEDPARAM /* Define if we have pthread_setname_np() */ #cmakedefine HAVE_PTHREAD_SETNAME_NP /* Define if we have pthread_set_name_np() */ #cmakedefine HAVE_PTHREAD_SET_NAME_NP /* Define the installation data directory */ #cmakedefine ALSOFT_INSTALL_DATADIR "@ALSOFT_INSTALL_DATADIR@"
    
android c++ qt openal openal-soft
1个回答
0
投票
我找到了最简单的方法!我只是下载这些源:

https://github.com/AerialX/openal-soft-android并使用 CMake 构建它。创建了“libopenal.so”库。我创建了“播放”按钮。我构建了第一个使用 OpenAL 播放音乐的应用程序!它可以在我的智能手机上使用!太酷了!

我的 Qt 6.2.4 MinGW 64 位分步指南:

    下载这些源:
  • https://github.com/AerialX/openal-soft-android
  • 下载 CMake(将其添加到 Path 变量中):
  • https://cmake.org/download/
  • 从控制台转到
  • openal-soft-android
    (cd openal-soft-android)
  • 将接下来的命令复制到控制台(不要忘记更改路径到您的
  • android.toolchain.cmake
cmake -G “MinGW Makefiles” -S 。 -B ./build -DCMAKE_TOOLCHAIN_FILE=E:\AppData\Android\SDK dk .1.7171670 uil
© www.soinside.com 2019 - 2024. All rights reserved.