* * *

Author Topic: Library PortAudio 64b does not load under Linux  (Read 2655 times)

tudi_x

  • Sr. Member
  • ****
  • Posts: 484
Library PortAudio 64b does not load under Linux
« on: August 12, 2017, 10:52:04 am »
hi All,
using Lazarus 1.8RC3 i am trying to load the LibPortaudio-64.so on Linux Mint.
unfortunately the file is there but i get a nil handle at:
Code: Pascal  [Select]
  1. ALibHandler := SafeLoadLibrary(AFileName);

on windows with LibPortaudio-64.dll the code works.
please advise what i am missing.

thank you

Code: Pascal  [Select]
  1. unit manage_portaudio;  //use in order to initialize and terminate working with portaudio
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   {$IFDEF UNIX}cthreads,{$ENDIF}Classes, SysUtils, dynlibs;
  9.  
  10. function ManagePortAudio(const AFileName: string; ToInitialize, ToTerminate: boolean; out AResult: integer; out ALibHandler: THandle): boolean;
  11.  
  12. {mapping external function}
  13. type
  14.   //may return an error code
  15.   TManageLib = function(): integer; stdcall;
  16.  
  17. implementation
  18.  
  19. function ManagePortAudio(const AFileName: string; ToInitialize, ToTerminate: boolean; out AResult: integer; out ALibHandler: THandle): boolean;
  20. var
  21.   msg: TManageLib;
  22.  
  23. begin
  24.   Result := False;
  25.   AResult := -99;
  26.  
  27.   try
  28.     if ToInitialize then
  29.       ALibHandler := SafeLoadLibrary(AFileName);
  30.  
  31.     if ALibHandler <> NilHandle then
  32.     begin
  33.  
  34.       if ToInitialize then
  35.       begin
  36.         msg := TManageLib(GetProcedureAddress(ALibHandler, 'Pa_Initialize'));
  37.       end;
  38.  
  39.       if ToTerminate then
  40.       begin
  41.         msg := TManageLib(GetProcedureAddress(ALibHandler, 'Pa_Terminate'));
  42.       end;
  43.  
  44.       if @msg <> nil then
  45.       begin
  46.         AResult := msg(); //runs also the function call
  47.         if AResult > -1 then
  48.           Result := True;
  49.       end;
  50.  
  51.       if ToTerminate then
  52.         FreeLibrary(ALibHandler);
  53.     end;
  54.   except
  55.     on E: Exception do
  56.     begin
  57.       AResult := -1;
  58.     end;
  59.   end;
  60. end;
  61.  
  62. end.
Lazarus 1.8.4 64b on Linux MINT 19 XFCE

Fred vS

  • Hero Member
  • *****
  • Posts: 1667
    • miXimum is the DJ's best friend
Re: Library PortAudio 64b does not load under Linux
« Reply #1 on: August 12, 2017, 02:44:27 pm »
Hello.

Huh, you did a double post...

By the way, did you try the examples of uos in a Linux 64 system ?

Linux 64  is my main development os and all the uos examples are working perfectly.

Fre;D
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 1667
    • miXimum is the DJ's best friend
Re: Library PortAudio 64b does not load under Linux
« Reply #2 on: August 12, 2017, 02:51:45 pm »
Re-hello.

For Unix, try to change this:

Code: Pascal  [Select]
  1.   TManageLib = function(): integer; stdcall;

with this:

Code: Pascal  [Select]
  1.   TManageLib = function(): integer; cdecl;

Did you see that in uos you may define only what you want with define.inc.
Edit define.inc and comment/uncomment only what you need.

Fre;D
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

tudi_x

  • Sr. Member
  • ****
  • Posts: 484
Re: Library PortAudio 64b does not load under Linux
« Reply #3 on: August 12, 2017, 03:40:50 pm »
hi Fred vS,
i am learning - up to yesterday i never worked with external libraries.
i need to learn how to use them cross platform. i like Free Pascal very much and want to learn.

i saw that i can comment in define.inc to load restricted functionality.
uos works on my Linux Mint and shows the audio devices but for some reason my code does not load the LibPortaudio-64.so.
it does not get to the TManageLib definition - i get a nil handle so i think this indicates that it could not load the library?

if it is not too much could you please run my code on your linux setup?
thank you

Lazarus 1.8.4 64b on Linux MINT 19 XFCE

Fred vS

  • Hero Member
  • *****
  • Posts: 1667
    • miXimum is the DJ's best friend
Re: Library PortAudio 64b does not load under Linux
« Reply #4 on: August 12, 2017, 05:20:44 pm »
@ tudi_x did you try, like explained in previous topic, to change:

 TManageLib = function(): integer; stdcall;

with

 TManageLib = function(): integer; cdecl;

[EDIT]
Quote
if it is not too much could you please run my code on your linux setup?
thank you

Huh, I have try to test  your 07_portaudio_DLL.zip  but the *.lpi file is missing,..  :-X

Fre;D
« Last Edit: August 12, 2017, 05:36:35 pm by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

tudi_x

  • Sr. Member
  • ****
  • Posts: 484
Re: Library PortAudio 64b does not load under Linux
« Reply #5 on: August 12, 2017, 06:05:32 pm »
hi,
i did change to cdecl.
sorry for the missing lpi.
please find attached the project.

thank you
Lazarus 1.8.4 64b on Linux MINT 19 XFCE

Fred vS

  • Hero Member
  • *****
  • Posts: 1667
    • miXimum is the DJ's best friend
Re: Library PortAudio 64b does not load under Linux
« Reply #6 on: August 13, 2017, 01:02:17 am »
hi,
i did change to cdecl.
sorry for the missing lpi.
please find attached the project.

thank you

Hello.

Here  result on Linux Mint 17 64 bit:

Quote
fred@fred-Lenovo-YOGA-300-11IBY ~/Téléchargements/07_portaudio_DLL $ ./learn
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
bt_audio_service_open: connect() failed: Connection refused (111)
ALSA lib pcm_dmix.c:961:(snd_pcm_dmix_open) The dmix plugin supports only playback stream
succes ini lib: 0
11
0
HDA Intel PCH: ID 236 Analog (hw:0,0)
0
Heap dump by heaptrc unit
32 memory blocks allocated : 2544/2584
32 memory blocks freed     : 2544/2584
0 unfreed memory blocks : 0
True heap size : 131072
True free heap : 131072

What is the problem?

Fre;D
« Last Edit: August 13, 2017, 01:17:34 am by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

tudi_x

  • Sr. Member
  • ****
  • Posts: 484
Re: Library PortAudio 64b does not load under Linux
« Reply #7 on: August 13, 2017, 10:36:38 am »
thank you for confirming there is nothing wrong with the code.
i think it would be something else as on my environment (Linux Mint 18.2 and Lazarus 1.8 RC3) i get the attached result.

i am looking into moving to a lower Lazarus version.
Lazarus 1.8.4 64b on Linux MINT 19 XFCE

tudi_x

  • Sr. Member
  • ****
  • Posts: 484
Re: Library PortAudio 64b does not load under Linux
« Reply #8 on: August 13, 2017, 12:57:26 pm »
tested with 64 bit Lazarus 1.4.4 and FPC 2.6.4 on Linux MX 16.1.
same result - library does now initialize.

@Fred vS
when you tested, did you use the library included in the zip i uploaded?
thank you
Lazarus 1.8.4 64b on Linux MINT 19 XFCE

Fred vS

  • Hero Member
  • *****
  • Posts: 1667
    • miXimum is the DJ's best friend
Re: Library PortAudio 64b does not load under Linux
« Reply #9 on: August 13, 2017, 02:33:33 pm »
tested with 64 bit Lazarus 1.4.4 and FPC 2.6.4 on Linux MX 16.1.
same result - library does now initialize.

@Fred vS
when you tested, did you use the library included in the zip i uploaded?
thank you

Hello.

[EDIT] My config: Linux 17 Mint 64 bit, fpc 3.0.3, Lazarus 1.8.0.RC3.

I tested it with the library included.
Did you try with the portaudio library of your release ?

Code: Pascal  [Select]
  1. # sudo apt-get install libportaudio2

(but I do not know where  libportaudio.so will be installed, you have to check that).

Fre;D
« Last Edit: August 13, 2017, 03:05:17 pm by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 1667
    • miXimum is the DJ's best friend
Re: Library PortAudio 64b does not load under Linux
« Reply #10 on: August 13, 2017, 03:07:55 pm »
Quote
tested with 64 bit Lazarus 1.4.4 and FPC 2.6.4 on Linux MX 16.1.

Ooops, that is **very** old please try with minimum fpc >= 2.7.1.

Fre;D
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus