PortAudio on Mac OS Catalina issues LIB Not Loaded

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

PortAudio on Mac OS Catalina issues LIB Not Loaded

Josh
Hi

I have been trying to get PortAudio etc to work on Mac.

I have placed the 64bit libs into a folder called Audio within the resouces folder of the bundle.

My app then Checks for that the files exists before it tries to load the librairies,
The files all exists but the i get LIBS NOT LOADED

[code]
mod_mpg_dll_filename:ansistring='LibMpg123-';
mod_port_dll_filename:ansistring='LibPortaudio-';
mod_snd_dll_filename:ansistring='LibSndFile-';  

{$IFDEF Windows}
  {$IFDEF CPU32}
   mod_extension:='.dll';mod_cpu:='32';
  {$ENDIF}
  {$IFDEF CPU64}
   mod_extension:='.dll';mod_cpu:='64';
  {$ENDIF}
 {$ENDIF}
 {$IFDEF Darwin}
     {$IFDEF CPU32}
      mod_extension:='.dylib';mod_cpu:='32_MAC';
     {$ENDIF}
     {$IFDEF CPU64}
      mod_extension:='.dylib';mod_cpu:='64_MAC';
     {$ENDIF}
 {$ENDIF}          

{$ifdef darwin}
    Modules_Folder:=ExtractFilePath(ParamStr(0));// this includes Mac_OS, so need to remove
    Modules_Folder:=Copy(Modules_FOlder,1,Length(Modules_Folder)-6)+'Resources/Audio';  
{$endif}

if not fileexistsutf8(Modules_Folder+folder_delimiter+mod_mpg_dll_filename+mod_cpu+mod_extension) then     showmessage('NOT FOUND'+Modules_Folder+folder_delimiter+mod_mpg_dll_filename+mod_cpu+mod_extension);

if not fileexistsutf8(Modules_Folder+folder_delimiter+mod_port_dll_filename+mod_cpu+mod_extension) then
showmessage('NOT FOUND '+Modules_Folder+folder_delimiter+mod_port_dll_filename+mod_cpu+mod_extension);

if not fileexistsutf8(Modules_Folder+folder_delimiter+mod_snd_dll_filename+mod_cpu+mod_extension) then
      showmessage('NOT FOUND '+Modules_Folder+folder_delimiter+mod_snd_dll_filename+mod_cpu+mod_extension);



The ABove goes through without showing any NOT Found messages, so the files exists in the Bundle



if uos_LoadLib(pchar(Modules_Folder+folder_delimiter+mod_port_dll_filename+mod_cpu+mod_extension),
                  pchar(Modules_Folder+folder_delimiter+mod_snd_dll_filename+mod_cpu+mod_extension),
                  pchar(Modules_Folder+folder_delimiter+mod_mpg_dll_filename+mod_cpu+mod_extension),
                  nil, nil, nil)=0 then showmessage('Libs Loaded') else showmessage('LIBS NOT LOADED');

[/code]

Any ideas.
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
Hello Josh.

Hum, I dont have any Mac to try.

Are you sure it is only PortAudio that cannot be loaded, did you try with only Portaudio?

if uos_LoadLib(pchar(Modules_Folder+folder_delimiter+mod_port_dll_filename+mod_cpu+mod_extension),nil,
                  nil, nil, nil, nil)=0 then showmessage('Libs Loaded') else showmessage('LIBS NOT LOADED');

Also are you sure that the libraries are in the bundle (Mac application)?

I did Googling and found this:

https://www.reddit.com/r/musicprogramming/comments/dmmp2f/portaudio_on_macos_catalina/

Did you try with other earlier Mac OS, was it working?

Fre;D









Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
Re-hello Josh.

I propose to do it step by step.

Try to make work the uos example deviceinfos.lpr.

This example use only Portaudio.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

Josh
In reply to this post by fredvs
Hi

If I display the Filename location prior it display correct ie.

/Volumes/My_Projects/Audio_Tests/TestingOpeningLibs.app/Contents/Frameworks/LibPortaudio-64_MAC.dylib

And the dylib are in the Framworks Folder, as they are found with fileexists.

Its worth noting that if i put a showmessage before the loadlib, there is no delay between clicking ok and displaying that the LIBS have not loaded,  On windows etc there is a noticeable delay as it loads in the dll's in the case of windows.

SO it appears that a problem exists with portaudio etc, with MAC OS.
Maybe time to try some other library?
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

Josh
Hi

I think I have made an error.

If I load just portaudio using nil for snfile etc, then it loads the lib

the problem is with

LibSndfile

When I add this in, the the library is not loaded; even though the file is there.

so I thiunk the area to concentrate on is the LibSndfile-64.dylib file

I am using the dlls, from the lates OPM version of UOS.
the size of the dylib is 371K  date 1/1/2020

Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
Hello Josh.

Ha, ok, one step behind...

About LibSndfile-64.dylib, I did add the one from here:
https://forum.lazarus.freepascal.org/index.php?topic=41218.0

Audacity is using LibSndFile.

Maybe you can download it, there is maybe LibSndFile included:
https://www.audacityteam.org/download/mac/

Fre;D

Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
Hello Josh.

About Audacity, they write this:

"macOS 10.15  (Catalina) is not currently supported,"

Aaargh.

If you cannot find a working LibSndfile-64.dylib, please say it, I will do a issue at Github LibSndfile.
https://github.com/erikd/libsndfile

Fre;D


Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

Josh
Hi Fred,

I have tried various libsnd dylib files; all exhibit the same; although al theones I can find are older and smaller than the one in your lib folder.

I followed the link to try to buidl my own; i had to modify the brew download script as the libopus one complained and had to use libopusenc instead; but It would not build; produced numerous errors.
I must admit that building libraries is not my forte; so probably me..

Regarding the listdevicee example; the display box shows the incorrect folder.
I will create a patch for it so that looks in the correct location if you run the exec file, and if run from within a bundle assumes the libs are in the Framework of the bundle; if not found to show a message informing user to copy the dylib to the Framework Folder.

Regarding portaudio etc; Catalina should prompt the user if your app tries to access the Microphone; this can be done in the info.plist file of the Bundle.

<key>NSMicrophoneUsageDescription</key>
<string>The Application requires use of the microphone.</string>
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
In reply to this post by Josh
Re-hello Josh.

> I will create a patch

Ho yes, it would be fantastic if uos could have demos out-of-the-box for Mac too, like it it has for Linux, Windows, FreeBSD and Rpi ARM.

I dont have a Mac and the code for Mac in uos demos was added following infos from Mac site.
But I never try it.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
In reply to this post by Josh
Re-Re hello Josh.

> the libopus one complained

Huh, yes, I am partly guilty for that:
https://github.com/erikd/libsndfile/issues/364

And I admit (see the issue) that even for Linux it was very difficult to build it.

But, if you dont need to play opus-files, maybe you may try to compile a older version of libsndfile, that does not have opus files added.

Opus file was added by commit on Feb 20, 2019, maybe try the commits before, like this:
https://github.com/erikd/libsndfile/commit/1a87c44

Fre;D
 
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

Josh
Hi Fred,

It's getting interesting.

If I now run the same app with no mods, its says the libs ARE loaded.

Now the only changes to this machine is running the install script from brew for libsndfile, this would suggest that it has installed some requirement for the dylib into the usr folder.

This mac was a vainilla Catalina; with no additional libraries, primariliy to make sure things work 'out of the box' for Catalina, as I was finding things would work on an upgraded High Sierra, but not on a NEW machine with Catalina on.

If I try to uninstall from brew it gives me an error that it cant uninstall because some of the files are required by Guile; which further suggests that additional stuff has been added.

I have done checked rewuirements of the library and results are:
josh@Joshs-Mac Frameworks % otool -L LibSndFile-64.dylib
LibSndFile-64.dylib:
        /usr/local/lib/libsndfile.1.dylib (compatibility version 2.0.0, current version 2.25.0)
        /usr/local/lib/libFLAC.8.dylib (compatibility version 12.0.0, current version 12.0.0)
        /usr/local/lib/libogg.0.dylib (compatibility version 9.0.0, current version 9.2.0)
        /usr/local/lib/libvorbis.0.dylib (compatibility version 5.0.0, current version 5.7.0)
        /usr/local/lib/libvorbisenc.2.dylib (compatibility version 3.0.0, current version 3.10.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
josh@Joshs-Mac Frameworks %

this would suggest that these dylib are also required for it to run.

Thoughts before I start and grab these files and place somewhere safe, and then bring mac back to state prior to installing via brew.

Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
Hello Josh.

Afaik, it is possible to compile libsndfile including those static libraries in the binary of libsndfile.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
> Afaik, it is possible to compile libsndfile including those static libraries in the binary of libsndfile.

It is what is done for the binaries of libsndfile for Windows (that are kindly given in libsndfile site).
It would be great if they do it for Mac too.
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

Josh
In reply to this post by fredvs
Hi Fred,

That would be ideal, if it can be done.

If It cant, the user would either have to install these additional libs with an install script; which with the current hardened security of MAC could create issue.
Or developer would need to add these into their app bundle; which would be the better of the 2 so as to make sure the dylib are compatible with the version of libsnfile.

But having them linked into the one dlib would be the obvious choice for Catalina new Security lock down; as to publush the app developer would have to harden the app and take 'ownership' of the libraries to allow their app to succeed this phase.
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
Ok, I will ask it to Erik. (please follow the issue)

But not sure he will do it asap, lot of people ask him regularly to publish a new release (but without luck).

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

Josh
Hi

Just addition, moced the individual lib to apps Framwork folder, and removed the dylib from system.

WHen I try to launch It still fails.

It appears that the install has hard coded links in it back to the usr location.

SO this is not working..
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
> WHen I try to launch It still fails.

Sorry, I do not understand, to launch what?
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
Hi Josh.

I fear that I will not be very useful for this Catalina problem.
And now if Apple decided to make life of developers even more complicated than before, imho, it is very sad.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: PortAudio on Mac OS Catalina issues LIB Not Loaded

fredvs
Administrator
Hi Josh.

There is some movement there:

https://github.com/erikd/libsndfile/issues/517

But I fear that we will need a Mac-guru to compile it.

Fre;D