0

I made a bot in C# for Discord and I would like to make it play music. I made it work on Windows host, but on linux, the opus.dll file can not be loaded.

On Windows I got the dlls from the official discord.net repo, but on Linux that libraries do not work.

I tried to build from source the opus library but the same result happens. I place the opus file in the same directory as the executable and on Windows it works, but on linux it does not.

Why might this happen ?

Andrei
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 08 '23 at 08:00

1 Answers1

1

DLL are generally meant for Window Systems, you would need to download a seperate package dedicated for Linux, usually so files.

Based on what I found for Ubuntu, you can do:

sudo apt-get install libopus-dev

Then, assuming your using P/Invoke

[DllImport("libopus")]
// Functions you would like to import...

Here is something that might help too.

WQYeo
  • 3,973
  • 2
  • 17
  • 26
  • Thanks for answering ! I will try your method too, but I fear that i can not package my bot if i use this. This bot that i am developing should be cross-platform and should not require anything to install. On Windows, for example, i package it with the opus dll included in the project directory so the executable can see that its there (everything in the same zip). I want to do something similar on Linux. Is there something I can do about this ? – Andrei Aug 08 '23 at 08:50
  • @Andrei You can consider conditional compilation directives, and ship different releases based on Operating Systems. Here are some links that might help you: https://stackoverflow.com/questions/3842590/how-do-i-set-a-conditional-compile-variable ; https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives ; Should you need to, you can consider `RuntimeInformation.IsOSPlatform` as well: https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.runtimeinformation.isosplatform?view=net-7.0 – WQYeo Aug 08 '23 at 09:36
  • 1
    Yes, I understand what you are saying and this is what I am doing now, but I would like to include the opus.so file into the release archive, so the end user should not bother to install another dependency (opus in this context). Isn't any easy way to do it like I am doping in windows? (just putting the SO file in the same folder as the executable and forget about it?) – Andrei Aug 08 '23 at 15:41
  • @Andrei Putting the SO file in the same folder is possible as well, but different users might use different flavors/version of Linux, which may cause some issues. It is better to create `rpm` or `deb` packages, which includes dependencies information. *(aka let your user install the dependency, but set it up such that its automatically installed)* – WQYeo Aug 08 '23 at 17:03