For my latest project I used the import-command to load the BASS audio library. However, this appears to cause problems on other computers because BASS is in a subfolder of my program and Import also on other computers refers to the absolute location of the BASS-folder computer on which I compiled the program.
Someone on this forum advised me to use OpenLibrary(). Is it true that I can use this command for a relative folder and does it still work in Linux? I spent a day trying to figure out how OpenLibrary works, but I still can't figure out how to import functions from a .so file with it. Would anyone be kind enough to give a small example or know another solution to my problem?
How to use OpenLibrary() with Linux
-
- Enthusiast
- Posts: 134
- Joined: Sun Apr 01, 2018 11:26 am
- Location: Netherlands
- Contact:
Re: How to use OpenLibrary() with Linux
Example with SDL
Link: https://www.purebasic.fr/english/viewto ... 15#p618215
Works with path to lib
But ...
If the BASS library has been properly installed under Linux, there should be no problems with importing.
The library must also be in the correct folder under linux so that it can always be found.
Link: https://www.purebasic.fr/english/viewto ... 15#p618215
Works with path to lib
But ...
If the BASS library has been properly installed under Linux, there should be no problems with importing.
The library must also be in the correct folder under linux so that it can always be found.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
-
- Enthusiast
- Posts: 134
- Joined: Sun Apr 01, 2018 11:26 am
- Location: Netherlands
- Contact:
Re: How to use OpenLibrary() with Linux
Hi mk-soft, thanks for this clear example
That's why I had put BASS into a subfolder of my program, but maybe that is not the best idea?

The idea was that my program should work immediately, without copying BASS files to /usr/lib/mk-soft wrote: Fri Mar 29, 2024 2:27 pm But ...
If the BASS library has been properly installed under Linux, there should be no problems with importing.
The library must also be in the correct folder under linux so that it can always be found.
That's why I had put BASS into a subfolder of my program, but maybe that is not the best idea?
Re: How to use OpenLibrary() with Linux
There are also rules under Linux as to where something has to be located.
It only works with the effort via LoadLibrary with path specification.
It only works with the effort via LoadLibrary with path specification.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: How to use OpenLibrary() with Linux
How do you import the bass library in your code ?
-
- Enthusiast
- Posts: 134
- Joined: Sun Apr 01, 2018 11:26 am
- Location: Netherlands
- Contact:
Re: How to use OpenLibrary() with Linux
Like this:
bass.pbi:
And I solved the problem in bass.pbi with:
Code: Select all
IncludeFile "pb_include/bass/linux/bass.pbi"
bass.pbi:
Code: Select all
;...
Import "../../../assets/bass/linux/libbass.so"
BASS_SetConfig.l(option.l,value.l)
BASS_GetConfig.l(option.l)
;and so on...
EndImport
And I solved the problem in bass.pbi with:
Code: Select all
Lib = OpenLibrary(#PB_Any, "assets/bass/linux/libbass.so")
Re: How to use OpenLibrary() with Linux
If bass is installed, you should use only ImportC "-lbass" and it should work everywhere