Bass in Linux, Paths, Makefile, and other things – do not know what to do

Started by stephanos,

stephanos

Dear All

I am transferring all my Lazarus coding to my Linux computer.  So a programme I wrote on Windows, Lazarus 32 bit and also works in 64 bit, both with appropriate versions of bass, are working OK.

I have installed the 64 bit Debian version of Lazarus and made a new project folder for my programme, and copied the two Linux Bass files over the project file
   bass24-linux/pascal/bass.pas
   bass24-linux/libs/x86_64/libbass.so
However, the programme does not compile, stopping at this line of code:
     BASS_Init(0, 44100, 0, H, NIL);

So I did some reading: "Linux version - The LIBBASS.SO file needs to be in the OS's library search path for it to be found; simply placing it in the same directory as the executable won't necessarily work as it does on other platforms.  The BASS libraries should also not be placed in the standard library directories to avoid version conflicts. To meet those competing requirements, a wrapper script could be used to set the "LD_LIBRARY_PATH" environment variable before loading the executable.  Another option is to set the "rpath" in the executable to tell it where to look for libraries, which is what the example makefiles do.
When building for multiple architectures, it is possible to simply try linking with all LIBBASS.SO versions, and the linker will use the appropriate one and ignore the others."

I regret to say I do not know what the above means, and I do not know what to do.

Much help needed and any help appreciated

Stephanos

Ian @ un4seen

Quote from: stephanosHowever, the programme does not compile, stopping at this line of code:
    BASS_Init(0, 44100, 0, H, NIL);

Please post the error message(s) that you're getting there.

A window handle isn't needed when using the "No Sound" device, so you can put "NIL" in the BASS_Init "win" parameter. That parameter is actually only ever used with DirectSound output on Windows.

stephanos

Thanks for the response
Screen shot attached
Not sure which is the 'win' parameter? 
I substituted 'NIL' for each parameter but it did not work.
I read the error message again and I do not understand why H not a pointer?

Falcosoft

Quote from: stephanos...
I read the error message again and I do not understand why H not a pointer?

Because H is a HSTREAM (a DWORD) just as you defined and not a pointer.
This is exactly the parameter Ian was talking about. You should simply pass nil instead of H there.

stephanos

Dear All
Thanks for the help.  Amended the code to: "BASS_Init(0, 44100, 0, NIL, NIL);"
It did compile: see BassLinuxError-2.png
But did not run, see BassLinuxError-3.png
Wait to hear

Chris

why are you load bass in a while loop?
Lazarus on Linux is UTF8 Based so I don`t think the utf8encode is needed.
Creating  a stream with unicode (PWideChar) is the flag BASS_UNICODE needed.
Creating  a stream with Ansi (PAnsiChar) is without the flag BASS_UNICODE needed.

i would recommend to change something like this

OnFormCreate......
begin
  Bass_Init(......
end;

OnFormDestroy.....
begin
  Bass_Free();
end;

OnBitBtn4Click......
begin
........
  with Memo1 do
  begin
      for i := 0 to Lines.Count -1 do
      begin
         if h <> 0 then
         Bass_StreamFree(h).
         if FileExists(Lines[i]) then
           h := Bass_StreamCreateFile(false,PWideChar(Lines[i]),0,0, BASS_Stream_DECODE or BASS_UNICODE);
           if (h = 0) then // error can't load the file
           begin
            ErrorMessageString = Bass_ErrorGetCode();
            Display the Error.......   
            exit;
          end;
      end;
  end;
end;