Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DLLNotFound Exception on Linux: rtmidi not found #8

Closed
sbrl opened this issue Nov 22, 2017 · 11 comments
Closed

DLLNotFound Exception on Linux: rtmidi not found #8

sbrl opened this issue Nov 22, 2017 · 11 comments

Comments

@sbrl
Copy link
Contributor

sbrl commented Nov 22, 2017

Hello again, with the new getting started section, I've taken a look at this library - but I've stumbled upon a crash:

System.TypeInitializationException: The type initializer for 'Commons.Music.Midi.RtMidi.MidiDeviceManager' threw an exception. ---> System.DllNotFoundException: rtmidi
  at at (wrapper managed-to-native) Commons.Music.Midi.RtMidi.RtMidi:rtmidi_out_create_default ()
  at Commons.Music.Midi.RtMidi.RtMidiOutputDevice..ctor () [0x00000] in /svn/commons-music-prog/managed-midi/Commons.Music.Midi.Desktop/rtmidi/RtMidiSharp.cs:270
  at Commons.Music.Midi.RtMidi.MidiDeviceManager..cctor () [0x00000] in /svn/commons-music-prog/managed-midi/Commons.Music.Midi.Desktop/rtmidi/RtMidiSharp.cs:301
  --- End of inner exception stack trace ---
  at Commons.Music.Midi.RtMidi.RtMidiAccess.get_Outputs () [0x00001] in /svn/commons-music-prog/managed-midi/Commons.Music.Midi.Desktop/rtmidi/RtMidiAccess.cs:15
  at MIDITest.MainClass.Main (System.String[] args) [0x00013] in /path/to/MIDI-Test/MIDI-Test/Program.cs:13

I suspect I don't have a dependency installed. Thoughts?

@atsushieno
Copy link
Owner

Is that macOS? What is your project type? mono console app?

I'm asking, because I prepared couple of Commons.Music.Midi.dlls for Mac but they are with CoreMIDI which is from Xamarin.Mac. I suspect we'll need RtMidiSharp backend for non-XamMac apps.

@sbrl
Copy link
Contributor Author

sbrl commented Nov 23, 2017

Nope, I'm on Linux. Here's a link to a download of the project I created: https://transfer.sh/OOEAf/MIDI-Test.7z (available for 60 days)

Here are a bunch of additional details of the system I'm doing this on:

  • uname -a: Linux erreling 4.9.63-1-lts #1 SMP Sat Nov 18 17:02:19 UTC 2017 x86_64 GNU/Linux
  • Monodevelop version: monodevelop-stable 7.0.1.24-2
  • mono version: stable 5.0.0.100/9667aa6

@atsushieno
Copy link
Owner

Hmm, weird. I wonder if I don't understand how nuget unpacks and copies the contents for the target framework appropriately... in managed-midi-1.0.0.4.nupkg archive I put librtmidi.so (which is the shared library that you are missing) under lib/net_4_5. It seems that your .csproj does not put it along with Commons.Music.Midi.dll.

So far, could you manually add packages/Commons.Music.Midi.1.0.0.4/lib/net_4_5/librtmidi.so to your project (.csproj) with "Content" build action and "Copy If Newer" option? Or add below directly in .csproj (under some ItemGroup):

<Content Include="librtmidi.so">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

@sbrl
Copy link
Contributor Author

sbrl commented Nov 23, 2017

Yep, copying librtmidi.so to my project and adding the MSBuild directives in an <ItemGroup/> does appear to fix the issue. As proof, here's the output of the program 😺

MIDI outputs found:
 - 1: Midi Through 14:0 (LinuxAlsa version )
 - 2: FLUID Synth (4550) 128:0 (LinuxAlsa version )

@atsushieno
Copy link
Owner

Nice :-) Let's leave this issue open until we get the right fix.

@sbrl
Copy link
Contributor Author

sbrl commented Nov 24, 2017

Ok!

@atsushieno
Copy link
Owner

For the record, I finally implemented ALSA backend so that you wouldn't need librtmidi.so anymore since a2a98f5.

@sbrl
Copy link
Contributor Author

sbrl commented Jan 6, 2018

Cool! I'll have to try that out and report back. It should work then pulseaudio is running, right?

(And I still need a software synthesizer running like Fluidsynth, right?)

@atsushieno
Copy link
Owner

Regardless of whether your synth backend is pulseaudio or not, our ALSA backend will connect to it as long as it is served as an ALSA MIDI device.

(And I still need a software synthesizer running like Fluidsynth, right?)

Not really ;-)
image

@sbrl
Copy link
Contributor Author

sbrl commented Jan 30, 2018

Hello again! Sorry it's taken me so long to get back to you on this - I've been writing reports......

Anyway, it does appear to work correctly now without librtmidi.so - thanks! I'll have to do some further experimentation to see if I can break it lol :P

@sbrl sbrl closed this as completed Jan 30, 2018
@sbrl sbrl changed the title DLLNotFound Exception on Linux DLLNotFound Exception on Linux: rtmidi not found Jan 30, 2018
@atsushieno
Copy link
Owner

Thanks for reporting back further :-) It's still missing things like inputs, but I plan to resume working on it once I'm done with my ongoing stuff (busy until weekend of the next week).

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

No branches or pull requests

2 participants