Skip to content

Link CoreAudio and AudioToolbox when using OpenAL on iOS [WIP]#8938

Merged
SimonDarksideJ merged 5 commits into
MonoGame:developfrom
dellis1972:dev/dellis1972/openalinkcoreaudio
Aug 6, 2025
Merged

Link CoreAudio and AudioToolbox when using OpenAL on iOS [WIP]#8938
SimonDarksideJ merged 5 commits into
MonoGame:developfrom
dellis1972:dev/dellis1972/openalinkcoreaudio

Conversation

@dellis1972

Copy link
Copy Markdown
Contributor

Fixes the following issue

3>Xamarin.Shared.Sdk.targets(1648,3): Error  : clang++ exited with code 1:
Undefined symbols for architecture arm64:
  "_AudioComponentFindNext", referenced from:
      (anonymous namespace)::CoreAudioPlayback::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
  "_AudioComponentInstanceDispose", referenced from:
      (anonymous namespace)::CoreAudioPlayback::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioPlayback::~CoreAudioPlayback() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioPlayback::~CoreAudioPlayback() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::~CoreAudioCapture() in libopenal.a[32](coreaudio.o)
  "_AudioComponentInstanceNew", referenced from:
      (anonymous namespace)::CoreAudioPlayback::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
  "_AudioOutputUnitStart", referenced from:
      (anonymous namespace)::CoreAudioPlayback::start() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::start() in libopenal.a[32](coreaudio.o)
  "_AudioOutputUnitStop", referenced from:
      (anonymous namespace)::CoreAudioPlayback::stop() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::stop() in libopenal.a[32](coreaudio.o)
  "_AudioUnitGetProperty", referenced from:
      (anonymous namespace)::CoreAudioPlayback::reset() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioPlayback::reset() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
  "_AudioUnitGetPropertyInfo", referenced from:
      (anonymous namespace)::CoreAudioPlayback::reset() in libopenal.a[32](coreaudio.o)
3>------- Finished building project: DungeonSlime.iOS. Succeeded: False. Errors: 1. Warnings: 0

@olivegamestudio

olivegamestudio commented Aug 3, 2025

Copy link
Copy Markdown

Adding the following:

<ItemGroup> <NativeReference Include="libopenal.a"> <Kind>Static</Kind> <Frameworks>AudioToolbox CoreAudio</Frameworks> <ForceLoad>true</ForceLoad> </NativeReference> </ItemGroup>

Resulted in the following output:

3>Xamarin.Shared.Sdk.targets(1648,3): Error : clang++ exited with code 1: ld: library 'libopenal.a' not found clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Tried adding this to the csproj/propertygroup, but the original issues remained.

<AppBundleExtraOptions>$(AppBundleExtraOptions) -framework CoreAudio</AppBundleExtraOptions>

@dellis1972 dellis1972 marked this pull request as draft August 3, 2025 14:28
@dellis1972

Copy link
Copy Markdown
Contributor Author

Adding the following:

<ItemGroup> <NativeReference Include="libopenal.a"> <Kind>Static</Kind> <Frameworks>AudioToolbox CoreAudio</Frameworks> <ForceLoad>true</ForceLoad> </NativeReference> </ItemGroup>

Resulted in the following output:

3>Xamarin.Shared.Sdk.targets(1648,3): Error : clang++ exited with code 1: ld: library 'libopenal.a' not found clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Tried adding this to the csproj/propertygroup, but the original issues remained.

<AppBundleExtraOptions>$(AppBundleExtraOptions) -framework CoreAudio</AppBundleExtraOptions>

@olivegamestudio

the NativeReference you added won't work since it will look for a local libopenal.a file, which won't exist.
We need a full diagnostic build log to investigate this further. use the -bl argument on dotnet build to output the msbuild.binlog file. Then upload that to this PR.

I am using the following

dotnet build mgios.csproj -bl -c Release 

to create a release build of an ios app.
I don't have an iOS developer licence so I cannot test device builds.
But I was able to replicate this issue using the above command. With the change from this PR it no longer occurs and I can get a full build.

This is the project file contents.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-ios</TargetFramework>
    <OutputType>Exe</OutputType>
    <SupportedOSPlatformVersion>11.2</SupportedOSPlatformVersion>
    <CodesignKey>iPhone Developer</CodesignKey>
    <MonoGamePlatform>iOS</MonoGamePlatform>
    <AppBundleExtraOptions>$(AppBundleExtraOptions) -framework CoreAudio</AppBundleExtraOptions>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.5-develop.5" />
    <PackageReference Include="MonoGame.Framework.iOS" Version="3.8.5-develop.5" />
  </ItemGroup>
</Project>

@olivegamestudio

Copy link
Copy Markdown

Adding the following:
<ItemGroup> <NativeReference Include="libopenal.a"> <Kind>Static</Kind> <Frameworks>AudioToolbox CoreAudio</Frameworks> <ForceLoad>true</ForceLoad> </NativeReference> </ItemGroup>
Resulted in the following output:
3>Xamarin.Shared.Sdk.targets(1648,3): Error : clang++ exited with code 1: ld: library 'libopenal.a' not found clang++: error: linker command failed with exit code 1 (use -v to see invocation)
Tried adding this to the csproj/propertygroup, but the original issues remained.
<AppBundleExtraOptions>$(AppBundleExtraOptions) -framework CoreAudio</AppBundleExtraOptions>

@olivegamestudio

the NativeReference you added won't work since it will look for a local libopenal.a file, which won't exist. We need a full diagnostic build log to investigate this further. use the -bl argument on dotnet build to output the msbuild.binlog file. Then upload that to this PR.

I am using the following

dotnet build mgios.csproj -bl -c Release 

to create a release build of an ios app. I don't have an iOS developer licence so I cannot test device builds. But I was able to replicate this issue using the above command. With the change from this PR it no longer occurs and I can get a full build.

This is the project file contents.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-ios</TargetFramework>
    <OutputType>Exe</OutputType>
    <SupportedOSPlatformVersion>11.2</SupportedOSPlatformVersion>
    <CodesignKey>iPhone Developer</CodesignKey>
    <MonoGamePlatform>iOS</MonoGamePlatform>
    <AppBundleExtraOptions>$(AppBundleExtraOptions) -framework CoreAudio</AppBundleExtraOptions>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.5-develop.5" />
    <PackageReference Include="MonoGame.Framework.iOS" Version="3.8.5-develop.5" />
  </ItemGroup>
</Project>

msbuild.binlog.zip

Here's the binlog.

@dellis1972

Copy link
Copy Markdown
Contributor Author

@olivegamestudio

You have <MtouchLink>SdkOnly</MtouchLink> set in your project.

@olivegamestudio

Copy link
Copy Markdown

@olivegamestudio

You have <MtouchLink>SdkOnly</MtouchLink> set in your project.

I've tried removing it and setting it to Full, but that didn't help. Is there a setting I should use?

@dellis1972

dellis1972 commented Aug 3, 2025

Copy link
Copy Markdown
Contributor Author

@olivegamestudio I'm not an iOS guy I'm afraid.

It works for me not having it at all.

You might need to ask on the DotNet Evolution #apple channel

EDIT: I asked.

https://discord.com/channels/732297728826277939/732297808148824115/1401587120660942941

@olivegamestudio

Copy link
Copy Markdown

@olivegamestudio I'm not an iOS guy I'm afraid.

It works for me not having it at all.

You might need to ask on the DotNet Evolution #apple channel

EDIT: I asked.

https://discord.com/channels/732297728826277939/732297808148824115/1401587120660942941

This is fine:

dotnet build -c Release -f net8.0-ios

This generates the issues when creating an IPA.

dotnet publish -c Release -f net8.0-ios -p:ArchiveOnBuild=true

@dellis1972

Copy link
Copy Markdown
Contributor Author

@olivegamestudio

ok, we are going to need some advice from someone who has more knowledge on this I'm afraid.

@rolfbjarne

Copy link
Copy Markdown
<AppBundleExtraOptions>$(AppBundleExtraOptions) -framework CoreAudio</AppBundleExtraOptions>

The missing symbols are in the AudioToolbox framework, so you need -framework AudioToolbox:

<AppBundleExtraOptions>$(AppBundleExtraOptions) -framework CoreAudio -framework AudioToolbox</AppBundleExtraOptions>

@olivegamestudio

Copy link
Copy Markdown
<AppBundleExtraOptions>$(AppBundleExtraOptions) -framework CoreAudio</AppBundleExtraOptions>

The missing symbols are in the AudioToolbox framework, so you need -framework AudioToolbox:

<AppBundleExtraOptions>$(AppBundleExtraOptions) -framework CoreAudio -framework AudioToolbox</AppBundleExtraOptions>

I added that to the project file, but the issues remain:

    /usr/local/share/dotnet/packs/Microsoft.iOS.Sdk.net8.0_18.0/18.0.8324/targets/Xamarin.Shared.Sdk.targets(1648,3): error : 
      clang++ exited with code 1:
      Undefined symbols for architecture arm64:
        "_AudioComponentFindNext", referenced from:
            (anonymous namespace)::CoreAudioPlayback::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>)
       in libopenal.a[32](coreaudio.o)
            (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) 
      in libopenal.a[32](coreaudio.o)
        "_AudioComponentInstanceDispose", referenced from:
            (anonymous namespace)::CoreAudioPlayback::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>)
       in libopenal.a[32](coreaudio.o)
            (anonymous namespace)::CoreAudioPlayback::~CoreAudioPlayback() in libopenal.a[32](coreaudio.o)
            (anonymous namespace)::CoreAudioPlayback::~CoreAudioPlayback() in libopenal.a[32](coreaudio.o)
            (anonymous namespace)::CoreAudioCapture::~CoreAudioCapture() in libopenal.a[32](coreaudio.o)
        "_AudioComponentInstanceNew", referenced from:
            (anonymous namespace)::CoreAudioPlayback::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>)
       in libopenal.a[32](coreaudio.o)
            (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) 
      in libopenal.a[32](coreaudio.o)
        "_AudioOutputUnitStart", referenced from:
            (anonymous namespace)::CoreAudioPlayback::start() in libopenal.a[32](coreaudio.o)
            (anonymous namespace)::CoreAudioCapture::start() in libopenal.a[32](coreaudio.o)
        "_AudioOutputUnitStop", referenced from:
            (anonymous namespace)::CoreAudioPlayback::stop() in libopenal.a[32](coreaudio.o)
            (anonymous namespace)::CoreAudioCapture::stop() in libopenal.a[32](coreaudio.o)
        "_AudioUnitGetProperty", referenced from:
            (anonymous namespace)::CoreAudioPlayback::reset() in libopenal.a[32](coreaudio.o)
            (anonymous namespace)::CoreAudioPlayback::reset() in libopenal.a[32](coreaudio.o)
            (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) 
      in libopenal.a[32](coreaudio.o)
            (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) 
      in libopenal.a[32](coreaudio.o)
        "_AudioUnitGetPropertyInfo", referenced from:
            (anonymous namespace)::CoreAudioPlayback::reset() in libopenal.a[32](coreaudio.o)

Build failed with 1 error(s) and 2 warning(s) in 52.3s

@rolfbjarne

Copy link
Copy Markdown

Ah, -framework isn't recognized directly in AppBundleExtraOptions, try this instead:

<AppBundleExtraOptions>$(AppBundleExtraOptions) -gcc_flags '-framework CoreAudio -framework AudioToolbox'</AppBundleExtraOptions>

@olivegamestudio

Copy link
Copy Markdown

Ah, -framework isn't recognized directly in AppBundleExtraOptions, try this instead:

<AppBundleExtraOptions>$(AppBundleExtraOptions) -gcc_flags '-framework CoreAudio -framework AudioToolbox'</AppBundleExtraOptions>

That worked! I have it running on a device and delivered through TestFlight.

@dellis1972 dellis1972 marked this pull request as ready for review August 4, 2025 10:48
@dellis1972

Copy link
Copy Markdown
Contributor Author

@olivegamestudio I've added the changes here. That will be in the next develop release.

@dellis1972 dellis1972 changed the title Link CoreAudio when using OpenAL on iOS Link CoreAudio and AudioToolbox when using OpenAL on iOS Aug 4, 2025
@dellis1972 dellis1972 force-pushed the dev/dellis1972/openalinkcoreaudio branch from 248945a to 70a405a Compare August 4, 2025 18:28
@dellis1972 dellis1972 marked this pull request as draft August 4, 2025 18:29
@dellis1972 dellis1972 removed the request for review from SimonDarksideJ August 4, 2025 18:29
@dellis1972 dellis1972 changed the title Link CoreAudio and AudioToolbox when using OpenAL on iOS Link CoreAudio and AudioToolbox when using OpenAL on iOS [WIP] Aug 4, 2025
@dellis1972 dellis1972 marked this pull request as ready for review August 5, 2025 16:17
@dellis1972 dellis1972 requested a review from CartBlanche August 5, 2025 16:17
@SimonDarksideJ SimonDarksideJ merged commit 38c7087 into MonoGame:develop Aug 6, 2025
8 checks passed
@dellis1972 dellis1972 deleted the dev/dellis1972/openalinkcoreaudio branch August 6, 2025 11:54
@ThomasFOG

Copy link
Copy Markdown
Contributor

It would have been better if it was around a NO_AUDIO check. I suspect that it might turn into an issue in some scenarios with third party audio engines (e.g. FMOD has its own linking to those two frameworks).

  <PropertyGroup>
    <MonoGamePlatform>iOS</MonoGamePlatform>
  </PropertyGroup>

  <PropertyGroup Condition="$(DefineConstants.Contains('NO_AUDIO')) != 'true'">
     <AppBundleExtraOptions>$(AppBundleExtraOptions) -gcc_flags '-framework CoreAudio -framework AudioToolbox'</AppBundleExtraOptions>
  </PropertyGroup>

So it didn't work when put into the audio .target? That's a bit annoying since that makes an audio related thing not in the audio related .target.

@dellis1972

Copy link
Copy Markdown
Contributor Author

@ThomasFOG The OpenAL.targets file never gets shipped. Its not in the nuget.

MonoGame.Framework.iOS.targets does get shipped in the Nuget, and having NO_AUDIO would mean nothing to an end user, they would need to specify that exact thing. It would have been better to maybe have an MSBuild property to control it.

@ThomasFOG

Copy link
Copy Markdown
Contributor

@ThomasFOG The OpenAL.targets file never gets shipped. Its not in the nuget.

MonoGame.Framework.iOS.targets does get shipped in the Nuget, and having NO_AUDIO would mean nothing to an end user, they would need to specify that exact thing. It would have been better to maybe have an MSBuild property to control it.

Ah! Makes sense! Sorry I didn't notice it was in that target, I assumed it was directly the csproj.

dellis1972 added a commit that referenced this pull request Oct 16, 2025
Fixes the following issue

```
3>Xamarin.Shared.Sdk.targets(1648,3): Error  : clang++ exited with code 1:
Undefined symbols for architecture arm64:
  "_AudioComponentFindNext", referenced from:
      (anonymous namespace)::CoreAudioPlayback::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
  "_AudioComponentInstanceDispose", referenced from:
      (anonymous namespace)::CoreAudioPlayback::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioPlayback::~CoreAudioPlayback() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioPlayback::~CoreAudioPlayback() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::~CoreAudioCapture() in libopenal.a[32](coreaudio.o)
  "_AudioComponentInstanceNew", referenced from:
      (anonymous namespace)::CoreAudioPlayback::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
  "_AudioOutputUnitStart", referenced from:
      (anonymous namespace)::CoreAudioPlayback::start() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::start() in libopenal.a[32](coreaudio.o)
  "_AudioOutputUnitStop", referenced from:
      (anonymous namespace)::CoreAudioPlayback::stop() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::stop() in libopenal.a[32](coreaudio.o)
  "_AudioUnitGetProperty", referenced from:
      (anonymous namespace)::CoreAudioPlayback::reset() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioPlayback::reset() in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
      (anonymous namespace)::CoreAudioCapture::open(std::__1::basic_string_view<char, std::__1::char_traits<char>>) in libopenal.a[32](coreaudio.o)
  "_AudioUnitGetPropertyInfo", referenced from:
      (anonymous namespace)::CoreAudioPlayback::reset() in libopenal.a[32](coreaudio.o)
3>------- Finished building project: DungeonSlime.iOS. Succeeded: False. Errors: 1. Warnings: 0

```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants