OpenAL drivers missing on Linux

I’m trying to run a simple DesktopGL application on Linux that plays a sound effect, but it gives the error:

Microsoft.Xna.Framework.Audio.NoAudioHardwareException (0x80004005): OpenAL drivers could not be found. —> System.DllNotFoundException: soft_oal.dll

I started in Visual Studio using MonoGames DesktopGL template, and just added an .ogg using the content pipeline. I can build and run the project on windows without errors and the sound plays just fine. Trying to run the same application on Linux gives me the error.

Commenting out the code added for the sound stops the error from appearing.

using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;

namespace Test
{
///


/// This is the main type for your game.
///

public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;

    public static List<SoundEffect> sounds;
    SoundEffectInstance soundInstance;
    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
        
    }
    /// <summary>
    /// Allows the game to perform any initialization it needs to before starting to run.
    /// This is where it can query for any required services and load any non-graphic
    /// related content.  Calling base.Initialize will enumerate through any components
    /// and initialize them as well.
    /// </summary>
    protected override void Initialize()
    {
        // TODO: Add your initialization logic here
        sounds = new List<SoundEffect>();
        base.Initialize();
        soundInstance = sounds[0].CreateInstance();
    }
    /// <summary>
    /// LoadContent will be called once per game and is the place to load
    /// all of your content.
    /// </summary>
    protected override void LoadContent()
    {
        // Create a new SpriteBatch, which can be used to draw textures.
        spriteBatch = new SpriteBatch(GraphicsDevice);
        // TODO: use this.Content to load your game content here
        sounds.Add(Content.Load<SoundEffect>("bounce_c"));
    }
    /// <summary>
    /// UnloadContent will be called once per game and is the place to unload
    /// game-specific content.
    /// </summary>
    protected override void UnloadContent()
    {
        // TODO: Unload any non ContentManager content here
    }
    /// <summary>
    /// Allows the game to run logic such as updating the world,
    /// checking for collisions, gathering input, and playing audio.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Update(GameTime gameTime)
    {
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            Exit();
        // TODO: Add your update logic here
        soundInstance.Play();
        base.Update(gameTime);
    }
    /// <summary>
    /// This is called when the game should draw itself.
    /// </summary>
    /// <param name="gameTime">Provides a snapshot of timing values.</param>
    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);
        // TODO: Add your drawing code here
        base.Draw(gameTime);
    }
}

}

https://www.openal.org/downloads/

But I don’t think it works on linux, try that SDK download and see what is inside it, I am unable to check, on mobile at the moment…

Also, try using an MP3 instead and see if it still throws the error…

What version of MonoGame are you using?

Rather than installing OpenAL, you should make sure soft_oal.so is included in your bin folder in the x86 and x64 folders. It should come with a new MonoGame DesktopGL project from a template in recent versions.

OpenAL Soft is a software implementation of the OpenAL specification that uses common audio drivers underneath. The benefit of using OpenAL Soft and shipping it with your game is that players don’t have to install OpenAL themselves.

1 Like

I’m using MonoGame 3.6.

Looking into the x86 and x64 folders inside bin, both contain:

libopenal.so.1
libSDL2-2.0.so.0
SDL2.dll
soft_oal.dll

Using an mp3 instead of an ogg produces the same error.

Cannot be found means the DLL is not in the directory were the project linking reference says it is. So the dll is in the wrong place or the compiler is looking in the wrong place.

What directory is the reference pointing to for its properties in the project itself.
You can probably quick fix it manually by just pointing it to the right place.

Though I guess it seems like a install error or something got corrupted try a new test project and see if that will play.

If you’re referring to MonoGame.Framework.dll.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<dllmap dll="SDL2.dll" os="osx" target="libSDL2-2.0.0.dylib"/>
	<dllmap dll="soft_oal.dll" os="osx" target="libopenal.1.dylib" />
	<dllmap dll="SDL2.dll" os="linux" cpu="x86" target="./x86/libSDL2-2.0.so.0"/>
	<dllmap dll="soft_oal.dll" os="linux" cpu="x86" target="./x86/libopenal.so.1" />
	<dllmap dll="SDL2.dll" os="linux" cpu="x86-64" target="./x64/libSDL2-2.0.so.0"/>
	<dllmap dll="soft_oal.dll" os="linux" cpu="x86-64" target="./x64/libopenal.so.1" />
</configuration>

And making a new test project still gives the same error.

No I mean the reference dropdown in your ide for the oal.DLL you should be able to view its properties and see a link location.
Should be clickable for editing as well.

Though it sounds like your install is corrupted you might as well reinstall mg hopefully that will fix it.

I hope this is what you’re referring to because I’m not sure.

It’s possible that the install is corrupted. If that’s what it comes to, I’ll give that a shot.

Ya click full path is the directory were the compiler expects to find the DLL so the error is saying that it is not there I.e. “not found”

copy paste the fullpath to your file explorer without the filename to see whats in there.
If those files are in there it probably means open al wasnt installed correctly.
However that is were it expects it to be and system not found is file not found.
You can copy the dll files there to were it expects them to br or change the linked directory to the path were you know the files are. Though that’s just a temporary fix.

Problem is a new project didn’t link to the DLL either so something’s messed up it might not find the other 3 files either. I’d just reinstall mg first before continuing.

The file is there so I’m guessing something wasn’t installed correctly, and I’ll be reinstalling MonoGame.

Is that really what is causing the error though? The application is compiling fine. The error only appears when I run the compiled app on linux.

Hard to say Looking for the error code is no help but from the info so far it points to a corruption somewhere hopefully a reinstall of mg will fix it. After you uninstall I would move any remaing open al files from the monogame install folder if the uninstall doesnt remove them. Then reinstall.