BASS Module (Mac)
BlitzMax Forums/BlitzMax Programming/BASS Module (Mac)
| ||
I've decided to change from FMOD to BASS (as FMOD isn't Universal), and I'm also getting BlitzMax to accept my DYLIB and the BASS one too. I'm using a modified BMK of course, and its almost working. I just get the following now : /usr/bin/ld: warning can't open dynamic library: @executable_path/libbass.dylib referenced from: /Users/nicholaskingsley/Documents/BlitzMax/FMOD/libfmod.dylib (checking for undefined symbols may be affected) (No such file or directory, errno = 2) /usr/bin/ld: Undefined symbols: _BASS_GetVersion referenced from libFMod expected to be defined in @executable_path/libbass.dylib collect2: ld returned 1 exit status Build Error: Failed to link /Users/nicholaskingsley/Documents/BlitzMax/FMOD/TestFMod.debug.app/Contents/MacOS/TestFMod.debug Process complete The problem is @executable_path isn't either the place where the BlitzMax source is or the BlitzMax/tmp - is it possible to append my own to this (or find out where the executable paths are) ? |
| ||
Finally got it sorted - had to put the library file elsewhere in my home directory. BASS is running quite well on the Mac now. |
| ||
cool! can you give a hint for starters on how to get BASS running on a Mac under BlitzMax? |
| ||
Indeed I shall. First off, there is a strange problem with it : Sometimes BASS just wont play streamed music when the program is run from the IDE, although through Finder its okay. Whether this also happens with Windows, I dont know. The reason for using BASS, rather than FMOD is that the BASS DYLIB is Universal, rather than FMOD'S being Intel or PPC (which resulted in problems with my interface code). Plus, I'm more used to BASS too. I found I had to put the LIBBASS.DYLIB into the lib directory of the home directory for the current user. This is the interface code. There's nothing particularly hard or unusual in it, and it doesn't have everything from BASS in it. As you can see, I've added the spectrograph routines from the BASS demo. Okay - onto the BlitzMax stuff. As I mentioned elsewhere, you'll need the modified BMK routine, otherwise this wont work. |
| ||
You should probably put that code into [codebox ] tags (without spaces) as oppose to [code ] tags to shorten the length of this thread. |
| ||
thanks! |
| ||
Its all shortened now. It'll be interesting to see if Windows has the same problem as the Mac one... |
| ||
I am trying your example on a mac and I get: ld: Undefined symbols: _BASSChannelGetData _BASSChannelGetPosition _BASSChannelPlay _BASSErrorGetCode _BASSFree _BASSGetVersion ...etc Can I conclude from that that the libbass.dylib is not in the right directory, as you mentioned above? Also, there is no lib directory in the user directory and creating one doesn't help either ... what am I doing wrong? |
| ||
You could put the file in a directory used by the PATH variable, although I dont, ie - sbin, bin or something like that. The lib directory in your home directory has worked for the other Macs I've tried it on. Mine is in /Users/nicholaskingsley/lib It may be worth seeing if putting the file in with the executable helps. |
| ||
When you refer to the modified bmk, I guess you are referring to Bruceys thread here? http://www.blitzmax.com/Community/posts.php?topic=66565#743657 I edited line 217 there, and it didn't change anything. Then I printed the 'cmds' line and found out that the reference to the Bass lib never happens. On further investigation I found out that I could write anything along the lines of Import -lSomething and it doesn't even throw an error. I must be doing something terribly wrong and I don't know where, but I keep trying. |
| ||
Yes, I am refering to one of Brucey's posts about BMK. Sounds like you need to change the pathing to the C code, in the Import line. Did you also rebuild the module ? |
| ||
The BMK module? yes, that's why I see my own prints to debug. It seems (not confirmed yet) that I have to put the import bass.c statement BEFORE the -lbass - suddenly he recognize that I try to import Bass .... |
| ||
... and yes, it works now. On one hand I am glad - on the other one I still don't know what the proper magic was. So I guess I'll reconstruct the build process (propably starting with a fresh installation of BlitzMax), and I'll post the results here. So far thank you! |
| ||
Thats okay! The import thing does act rather strangely at times... |
| ||
yes, indeed - the main problem is that for some reason sometimes the BASS.c does not get imported. I *think* it has soemthing to do with the lower or uppercase of the bmx file that imports the .c file. The pattern seems to be that if the filename is all uppercase it fails to import/compile. I don't know if that's the only reason but the test is easy: could you rename your .bmx file to all uppercase (like TEST.BMX), start a fresh BM IDE with no files open, open it via menu and verify/falsify that the BASS.c compilation doesn't happen? |
| ||
There does seem to be problems with capital letters in certain places - no idea why though |
| ||
Can you confirm this specific issue? Why it is - well, after all there's Unix under the hood of OSX, which is case sensitive. So I guess when you mostly develop on a Windows box you'll have a hard time finding every single issue concerning this 'little' difference. |
| ||
I cant unfortunately - its all working on the Mac, and I want to leave it that way :) I'll see what I can find at the weekend though. One thing I have found that it does seem to need / as directory/file seperators, instead of \... But is to be expected really... |
| ||
I did a sort of minimal application that works on both mac and win32 without modification. It is heavily based on MrTAToad's code above with a few modifications - like with BASSGetDeviceDescription which has to be called like that:BASSGetDeviceDescription$z(device:Int)to get a string back. bass.c minimal.bmx |
| ||
Probably easier to read than my test code :) I cant seem to replicate the case sensitive compiler problems, so it might have been just me... |
| ||
I had no luck of compiling the above code"without modifications" on Win32. I found that changing -lbass to -Lbass is at least reporting something different than "cannot find -lbass", to "undefined reference to `BASS_Init@20". I have the modified BMK (been compiling some of Brucey's modules without a glitch). I have bass.h . I am surely missing something obvious ... |
| ||
... the DLL? |
| ||
nope! not that! |
| ||
You do need to copy the BASS.DLL into the same place as the executable. For MacOS machines, you copy the dylib file. |
| ||
I did. I have the dll in the system32 folder as well. It seems less and less obvious! I have these console outputs for all the (apparently un-) declared bass functions in bass.c : C:/BASS/BASS/.bmx/BASS.c.debug.win32.x86.o(.text+0x34):BASS.c: undefined reference to `BASS_Init@20' Debug or release, no difference. -l |
| ||
Does a 'build modules' in general work for you? |
| ||
Yes from BRL mods to Axe or BaH mods, it compiles everything. |
| ||
It looks like its mangling the function name, and thus it could think your using C++, instead of C, for some reason... The other possibility is it cant find the BASS header - I presume you've installed the BASS SDK ? If so, is the header in with the rest of the code ? If not, you'll probably need to change the #include "bass.h" to the full path (ie, something like #include "c:\program files\bass\bass.h") |
| ||
It finds the bass.h, when I type something "wrong" in it, it throws an error. So still the C++ case to investigate ... Could you send me your bass.h, I suspect something has maybe changed in it compared to the version you are using. My email address is in my profile. Thanks |
| ||
...maybe it's the mysterious 'the case of the case sensitive filenames' case? In any case, if you have enough mailbox, I'll send you the whole project. |
| ||
The bass.h file is the one from the BASS SDK - I certainly haven't needed to alter it. |
| ||
Try using this set of headers in the C file (uncommenting out the //define to activate the WIN32 path - if your using Windows) ://#define WIN32 #include "stdio.h" #include "stdlib.h" #include "string.h" #include "math.h" #ifdef WIN32 // Windows #define BASSDEF(f) (WINAPI *f) // define the functions as pointers #include "c:\program files\BASS\c\bass.h" HINSTANCE bass=NULL; #else // OSX Version #include "/Developer/bass23-osx/bass.h" #endif |
| ||
Well with this header, the bass.c errors disappeared, but Blitzmax throws a Unhandled memory exception error on each call to any bass function. @Dirk : My mailbox is surely big enough! |
| ||
That would there is no proper initialisation done - the BASS_Initialisation code should be (for Windows) : This is so the DLL is loaded when the initilisation routine is called, and without it your trying to call functions that dont exist. This is the Windows (and updated Mac) version : Uncommend the //WIN32 part for Windows |
| ||
Yes! That works with uncommenting //#define WIN32 and using import "-Lbass" instead of "-lbass". Now I am happy :) Thanks a lot. |
| ||
Knew it some something simple :) |