Author Topic: Sample for Xamarin iOS  (Read 7154 times)

MikaelS

  • Posts: 198
Sample for Xamarin iOS
« on: 21 Oct '14 - 06:57 »
Hello,

Does anyone got a working sample for BASS and/or BASS-NET for Xamarin iOS?
I have tried to link both libraries, but I'm met by a couple of linker warnings which I'm not sure how to solve.

Any help is appreciated.

Thanks in advance!

ken

  • Posts: 739
Re: Sample for Xamarin iOS
« Reply #1 on: 1 Nov '14 - 15:50 »
Hi,

Try this:

1. Add "libbass.a" and other bass libraries to your solution, right click on the lib and set "Build Action" to None.
2. Right click on the project and select Option, there go to "iOS Build", set linker behaviour to "Don't Link" in the Additional Options box type this:

Code: [Select]
-cxx -gcc_flags "-L${ProjectDir} -lbass -lbassmix -force_load ${ProjectDir}/libbass.a ${ProjectDir}/libbassmix.a"
Note I use bass and bassmix library here. Also note that you have to do this for all Configurations (Debug, Appstore and so on)

/Ken





MikaelS

  • Posts: 198
Re: Sample for Xamarin iOS
« Reply #2 on: 2 Nov '14 - 11:47 »
Thanks Ken, I'll try this.

ken

  • Posts: 739
Re: Sample for Xamarin iOS
« Reply #3 on: 2 Nov '14 - 12:32 »
Thanks Ken, I'll try this.

Forgot to say if you use BASS.NET then add the iOS version to "References" in Xamarin Studio, or make your own calls to BASS via "DllImport"

/Ken

MikaelS

  • Posts: 198
Re: Sample for Xamarin iOS
« Reply #4 on: 2 Nov '14 - 18:58 »
Dear Ken,

Thanks for your input. I did some tests both with BASS.NET and just libbass.a but I ended up with native linker messages?
I do not really need BASS.NET for this specific case, so just linking libbass.a should be fine.

May I ask if you have some very simple skeleton solution file you can share which just links and initialises BASS?

I think I still might link the libbass.a file incorrect or such.

Big thanks in advance!

MikaelS

  • Posts: 198
Re: Sample for Xamarin iOS
« Reply #5 on: 4 Nov '14 - 07:23 »
Update:
Almost got it to work with BASS.NET, but I get these errors during compilation:

Error MT5214: Native linking failed, undefined symbol: _BASS_GetDSoundObject. This symbol was referenced the managed member Un4seen.Bass.Bass.BASS_GetDSoundObject. Please verify that all the necessary frameworks have been referenced and native libraries linked. (MT5214)

Error MT5214: Native linking failed, undefined symbol: _BASS_MIDI_FontPack. This symbol was referenced the managed member Un4seen.Bass.AddOn.Midi.BassMidi.BASS_MIDI_FontPackUnicode. Please verify that all the necessary frameworks have been referenced and native libraries linked. (MT5214)

When viewing the BASS.NET assembly it seems like the members are exposed, but somehow it is not recognized during compilation/linking.

Any hints?

radio42

  • Posts: 4576
Re: Sample for Xamarin iOS
« Reply #6 on: 4 Nov '14 - 08:53 »
What version of Xamarin are you using?

If you are using the 'lastest' ios 8 Xamarin version please take a look here:
http://forums.xamarin.com/discussion/16489/new-type-registrar-in-xamarin-ios-7-2-1-errors-mt5210-and-mt5211

So have you tried the mentioned workaround by using the "--registarar:legacy" linker option?!

The issue seems, that Xamarin now try to resolve ALL methods at once.
Meaning any external method defined within Bass.Net must physically exist (in the corresponding native BASS/add-on lib).
E.g. if you would include ALL referenced libs (like e.g. libbasswv.a, libbassopus.a, libbassmidi.a etc. etc.) then it should link/compile fine.
Can you confirm this?!
If not, please tell me which methods are exactly missing in case you really link against ALL native libs!

The problem is, that Bass.Net is ONE assembly, which defines ALL methods off ALL available native libs, bass AND any add-on.

If I read the new Xamarin docs correctly, they now check (by default), if all those defined external methods do actually exist.
This would mean, you MUST link against ALL native libs (bass and ALL add-ons).
If that is true, I can only say: how stupid is that! So you should contact Xamarin and file an issue with them.
It is not easy to change Bass.Net is that respect, as I would need to create for every native lib one related .net wrapper lib.
And this is in some cases not really possible right now!

So I think, we need to throw this issue back to Xamarin to find a solution.
I hope they have a switch/workaround for that.
Else, I am afraid, that you must really link against ALL native libs!

If all that also fails, I guess should 'ship' a sample application as a non-working example to the Xamarin support!

MikaelS

  • Posts: 198
Re: Sample for Xamarin iOS
« Reply #7 on: 4 Nov '14 - 14:04 »
Hello,

Yes, I'm using the most recent Xamarin and iOS 8 version.

I have tried to add the --registrar:legacy option but that does not seem to help.

Not even when I reference all libraries (libbasswv, libbassopus et all) I cannot get it to compile.
If I remove one of the libraries (native reference), I get more errors, so it seems like your theory is correct, but that the legacy option does not work.

This is the errors I get in my simple project (all it does is to invoke BassNet.Registration and after that Bass.BASS_Init) with all libraries added as native references:

Error MT5214: Native linking failed, undefined symbol: _BASS_GetDSoundObject. This symbol was referenced the managed member Un4seen.Bass.Bass.BASS_GetDSoundObject. Please verify that all the necessary frameworks have been referenced and native libraries linked. (MT5214)

Error MT5214: Native linking failed, undefined symbol: _BASS_MIDI_FontPack. This symbol was referenced the managed member Un4seen.Bass.AddOn.Midi.BassMidi.BASS_MIDI_FontPackUnicode. Please verify that all the necessary frameworks have been referenced and native libraries linked. (MT5214)

Error MT5201: Native linking failed. Please review the build log and the user flags provided to gcc: "..." (MT5201)

Error MT5202: Native linking failed. Please review the build log. (MT5202)

My additional mtouch arguments are:
--registrar:legacy -cxx -gcc_flags "-L${ProjectDir} -lbass -force_load ${ProjectDir}/libbass.a"

So, it seems like two Bass.Net related methods are missing.
It is of course stupid with the need of linking all libraries, but at the moment I'm mainly looking for a working setup of BASS, so including all libs will work for now unless anyone else knows a way around it.

Thanks in advance for the help!

radio42

  • Posts: 4576
Re: Sample for Xamarin iOS
« Reply #8 on: 4 Nov '14 - 15:32 »
OKi, thanks for the info.
We/you should definitely file a bug with Xamarin, that the "--registrar:legacy" option is NOT working.

However, here is a new version, which excludes the 2 mentioned methods from the Bass.Net.iOS version.
Guess we can only try-and-error, if more methods are causing trouble.

www.un4seen.com/filez/4/Bass24.Net_iOS.zip

THX Bernd

MikaelS

  • Posts: 198
Re: Sample for Xamarin iOS
« Reply #9 on: 4 Nov '14 - 16:48 »
BIG thanks for this Bernd!

This new version solves it. It will require all libraries linked (the  "--registrar:legacy" does not seem to work at all, it even mroke the build :( ).
I will contact Xamarin about this one.

Thanks once again!

MikaelS

  • Posts: 198
Re: Sample for Xamarin iOS
« Reply #10 on: 7 Nov '14 - 06:53 »
Hi again!

I got this reply from the Xamarin team:
Quote
The problem is that you have P/Invokes referencing native methods that don't exist (at least in the iOS version of the native library). This is not a problem the legacy registrar will work around.

There are two options:

1) Ask the vendor to fix their library to not use P/Invokes referencing native methods that don't exist (or add those native methods to the native library).
2)Enable the managed linker for all assemblies (in the project's iOS Build options set 'Linker Behavior' to 'Link all assemblies'. Assuming you don't actually have code paths that could theoretically end up executing those P/Invokes, they will be removed, and you'll avoid the posterior error.

Not sure if it helps, I think it means what we already know.

radio42

  • Posts: 4576
Re: Sample for Xamarin iOS
« Reply #11 on: 7 Nov '14 - 09:20 »
No, I guess option 2) is what we/you are looking for!
Have you tried that?

However, I guess the Xamarin isn't really understanding the issue.
They typically think linear and simple; meaning they assume, that there is always a 1:1 relation between a managed wrapper (Bass.Net) and the native lib(s).
But in our case it is a N:M resp. 1:N relationship; meaning there is 1 managed wrapper (Bass.Net) offering a complete set of possible native p/Invokes to many possible native libs!
The use of the number of native libs (BASS and all the add-ons) is optional and are extending the overall functionality.
As such the enduser (i.e. the Xamarin developer) might use just one or might use many native libs!
The managed wrapper however needs to offers support for all theoretically possible P/Invokes in any theoretically possible native lib - the managed wrapper can not know upfront which number and combination of native libs the enduser will effectively use!
But exactly this is now required by the new Xamarin legacy registrar checking!
In essence, the new Xamarin checking extensively limits the development of managed to unmanged transitions - there should be a simple way to disable those checks!
(and yes, if those checks are disabled; it is the endusers responsibility to make sure, that he never effectively calls a P/Invoke to a native lib he hasn't link against - link in all Xamarin versions before and link in all other platforms/build-systems)

So please write the above comments to the Xamarin team, as they only respond fairly, if you have a running project you are having trouble with!
Many Thanks.


MikaelS

  • Posts: 198
Re: Sample for Xamarin iOS
« Reply #12 on: 7 Nov '14 - 17:07 »
Thanks. I have forwarded the question to the Xamarin dev team.
I will keep this ticket up-to-date when I get any replies.

MikaelS

  • Posts: 198
Re: Sample for Xamarin iOS
« Reply #13 on: 13 Nov '14 - 19:09 »
Ok, some updates:
I was trying to do an ad-hoc (release build) to test on some actual devices.
I set the additional mtouch arguments as for the debug setup and made a build, now the build output shows the following errors:

Compiling to native code
Undefined symbols for architecture armv7:
  "_AudioComponentFindNext", referenced from:
      l028 in libbass.a(libbass.a-armv7-master.o)
      _BASS_Init in libbass.a(libbass.a-armv7-master.o)
  "_AudioComponentInstanceDispose", referenced from:
      l030 in libbass.a(libbass.a-armv7-master.o)
      l227 in libbass.a(libbass.a-armv7-master.o)
  "_AudioComponentInstanceNew", referenced from:
      l028 in libbass.a(libbass.a-armv7-master.o)
      _BASS_Init in libbass.a(libbass.a-armv7-master.o)
  "_AudioConverterDispose", referenced from:
      l036 in libbass.a(libbass.a-armv7-master.o)
  "_AudioConverterFillComplexBuffer", referenced from:
      l037 in libbass.a(libbass.a-armv7-master.o)
  "_AudioConverterGetProperty", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
  "_AudioConverterNew", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
  "_AudioConverterReset", referenced from:
      l039 in libbass.a(libbass.a-armv7-master.o)
  "_AudioConverterSetProperty", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
      l026 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_AudioFileClose", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
      l036 in libbass.a(libbass.a-armv7-master.o)
      l024 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_AudioFileGetGlobalInfo", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
  "_AudioFileGetProperty", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
      l039 in libbass.a(libbass.a-armv7-master.o)
      l452 in libbass.a(libbass.a-armv7-master.o)
  "_AudioFileGetPropertyInfo", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
  "_AudioFileInitializeWithCallbacks", referenced from:
      l026 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_AudioFileOpenWithCallbacks", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
  "_AudioFileReadPackets", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
      l452 in libbass.a(libbass.a-armv7-master.o)
      l453 in libbass.a(libbass.a-armv7-master.o)
  "_AudioFormatGetProperty", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
      l026 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_AudioOutputUnitStart", referenced from:
      l031 in libbass.a(libbass.a-armv7-master.o)
      l455 in libbass.a(libbass.a-armv7-master.o)
  "_AudioOutputUnitStop", referenced from:
      l024 in libbass.a(libbass.a-armv7-master.o)
      l030 in libbass.a(libbass.a-armv7-master.o)
      l032 in libbass.a(libbass.a-armv7-master.o)
      l227 in libbass.a(libbass.a-armv7-master.o)
  "_AudioSessionGetProperty", referenced from:
      _BASS_RecordGetInfo in libbass.a(libbass.a-armv7-master.o)
  "_AudioSessionInitialize", referenced from:
      l280 in libbass.a(libbass.a-armv7-master.o)
  "_AudioSessionSetActive", referenced from:
      _BASS_Init in libbass.a(libbass.a-armv7-master.o)
      _BASS_RecordInit in libbass.a(libbass.a-armv7-master.o)
      l279 in libbass.a(libbass.a-armv7-master.o)
      l281 in libbass.a(libbass.a-armv7-master.o)
  "_AudioSessionSetProperty", referenced from:
      _BASS_Init in libbass.a(libbass.a-armv7-master.o)
      l280 in libbass.a(libbass.a-armv7-master.o)
  "_AudioUnitAddPropertyListener", referenced from:
      _BASS_Init in libbass.a(libbass.a-armv7-master.o)
  "_AudioUnitGetParameter", referenced from:
      _BASS_GetVolume in libbass.a(libbass.a-armv7-master.o)
  "_AudioUnitGetProperty", referenced from:
      l021 in libbass.a(libbass.a-armv7-master.o)
  "_AudioUnitInitialize", referenced from:
      l028 in libbass.a(libbass.a-armv7-master.o)
      _BASS_Init in libbass.a(libbass.a-armv7-master.o)
  "_AudioUnitRender", referenced from:
      l029 in libbass.a(libbass.a-armv7-master.o)
  "_AudioUnitSetParameter", referenced from:
      _BASS_SetVolume in libbass.a(libbass.a-armv7-master.o)
  "_AudioUnitSetProperty", referenced from:
      l021 in libbass.a(libbass.a-armv7-master.o)
      l028 in libbass.a(libbass.a-armv7-master.o)
      l030 in libbass.a(libbass.a-armv7-master.o)
      _BASS_Init in libbass.a(libbass.a-armv7-master.o)
  "_AudioUnitUninitialize", referenced from:
      l030 in libbass.a(libbass.a-armv7-master.o)
      l227 in libbass.a(libbass.a-armv7-master.o)
  "_ExtAudioFileCreateWithURL", referenced from:
      l026 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_ExtAudioFileDispose", referenced from:
      l036 in libbass.a(libbass.a-armv7-master.o)
      l024 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_ExtAudioFileGetProperty", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
      l026 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_ExtAudioFileOpenURL", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
  "_ExtAudioFileRead", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
      l037 in libbass.a(libbass.a-armv7-master.o)
  "_ExtAudioFileSeek", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
      l452 in libbass.a(libbass.a-armv7-master.o)
  "_ExtAudioFileSetProperty", referenced from:
      l033 in libbass.a(libbass.a-armv7-master.o)
      l026 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_ExtAudioFileWrapAudioFileID", referenced from:
      l026 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_ExtAudioFileWrite", referenced from:
      l016 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_ExtAudioFileWriteAsync", referenced from:
      l016 in libbassenc.a(libbassenc.a-armv7-master.o)
  "_MIDIClientCreate", referenced from:
      _BASS_MIDI_InInit in libbassmidi.a(libbassmidi.a-armv7-master.o)
  "_MIDIGetSource", referenced from:
      l043 in libbassmidi.a(libbassmidi.a-armv7-master.o)
  "_MIDIInputPortCreate", referenced from:
      _BASS_MIDI_InInit in libbassmidi.a(libbassmidi.a-armv7-master.o)
  "_MIDIObjectGetIntegerProperty", referenced from:
      l043 in libbassmidi.a(libbassmidi.a-armv7-master.o)
  "_MIDIObjectGetStringProperty", referenced from:
      l043 in libbassmidi.a(libbassmidi.a-armv7-master.o)
  "_MIDIPortConnectSource", referenced from:
      _BASS_MIDI_InStart in libbassmidi.a(libbassmidi.a-armv7-master.o)
  "_MIDIPortDisconnectSource", referenced from:
      _BASS_MIDI_InStop in libbassmidi.a(libbassmidi.a-armv7-master.o)
  "_MIDIPortDispose", referenced from:
      _BASS_MIDI_InFree in libbassmidi.a(libbassmidi.a-armv7-master.o)
  "_kMIDIPropertyName", referenced from:
      l043 in libbassmidi.a(libbassmidi.a-armv7-master.o)
  "_kMIDIPropertyUniqueID", referenced from:
      l043 in libbassmidi.a(libbassmidi.a-armv7-master.o)
  "_vDSP_create_fftsetup", referenced from:
      _BASS_ChannelGetData in libbass.a(libbass.a-armv7-master.o)
  "_vDSP_fft_zip", referenced from:
      _BASS_ChannelGetData in libbass.a(libbass.a-armv7-master.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error MT5210: Native linking failed, undefined symbol: _AudioComponentFindNext. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
error MT5210: Native linking failed, undefined symbol: _AudioComponentInstanceDispose.
error MT5210: Native linking failed, undefined symbol: _AudioComponentInstanceNew.
error MT5210: Native linking failed, undefined symbol: _AudioConverterDispose.
error MT5210: Native linking failed, undefined symbol: _AudioConverterFillComplexBuffer.
error MT5210: Native linking failed, undefined symbol: _AudioConverterGetProperty.
error MT5210: Native linking failed, undefined symbol: _AudioConverterNew.
error MT5210: Native linking failed, undefined symbol: _AudioConverterReset.
error MT5210: Native linking failed, undefined symbol: _AudioConverterSetProperty.
error MT5210: Native linking failed, undefined symbol: _AudioFileClose.
error MT5210: Native linking failed, undefined symbol: _AudioFileGetGlobalInfo.
error MT5210: Native linking failed, undefined symbol: _AudioFileGetProperty.
error MT5210: Native linking failed, undefined symbol: _AudioFileGetPropertyInfo.
error MT5210: Native linking failed, undefined symbol: _AudioFileInitializeWithCallbacks.
error MT5210: Native linking failed, undefined symbol: _AudioFileOpenWithCallbacks.
error MT5210: Native linking failed, undefined symbol: _AudioFileReadPackets.
error MT5210: Native linking failed, undefined symbol: _AudioFormatGetProperty.
error MT5210: Native linking failed, undefined symbol: _AudioOutputUnitStart.
error MT5210: Native linking failed, undefined symbol: _AudioOutputUnitStop.
error MT5210: Native linking failed, undefined symbol: _AudioSessionGetProperty.
error MT5210: Native linking failed, undefined symbol: _AudioSessionInitialize.
error MT5210: Native linking failed, undefined symbol: _AudioSessionSetActive.
error MT5210: Native linking failed, undefined symbol: _AudioSessionSetProperty.
error MT5210: Native linking failed, undefined symbol: _AudioUnitAddPropertyListener.
error MT5210: Native linking failed, undefined symbol: _AudioUnitGetParameter.
error MT5210: Native linking failed, undefined symbol: _AudioUnitGetProperty.
error MT5210: Native linking failed, undefined symbol: _AudioUnitInitialize.
error MT5210: Native linking failed, undefined symbol: _AudioUnitRender.
error MT5210: Native linking failed, undefined symbol: _AudioUnitSetParameter.
error MT5210: Native linking failed, undefined symbol: _AudioUnitSetProperty.
error MT5210: Native linking failed, undefined symbol: _AudioUnitUninitialize.
error MT5210: Native linking failed, undefined symbol: _ExtAudioFileCreateWithURL.
error MT5210: Native linking failed, undefined symbol: _ExtAudioFileDispose.
error MT5210: Native linking failed, undefined symbol: _ExtAudioFileGetProperty.
error MT5210: Native linking failed, undefined symbol: _ExtAudioFileOpenURL.
error MT5210: Native linking failed, undefined symbol: _ExtAudioFileRead.
error MT5210: Native linking failed, undefined symbol: _ExtAudioFileSeek.
error MT5210: Native linking failed, undefined symbol: _ExtAudioFileSetProperty.
error MT5210: Native linking failed, undefined symbol: _ExtAudioFileWrapAudioFileID.
error MT5210: Native linking failed, undefined symbol: _ExtAudioFileWrite.
error MT5210: Native linking failed, undefined symbol: _ExtAudioFileWriteAsync.
error MT5210: Native linking failed, undefined symbol: _MIDIClientCreate.
error MT5210: Native linking failed, undefined symbol: _MIDIGetSource.
error MT5210: Native linking failed, undefined symbol: _MIDIInputPortCreate.
error MT5210: Native linking failed, undefined symbol: _MIDIObjectGetIntegerProperty.
error MT5210: Native linking failed, undefined symbol: _MIDIObjectGetStringProperty.
error MT5210: Native linking failed, undefined symbol: _MIDIPortConnectSource.
error MT5210: Native linking failed, undefined symbol: _MIDIPortDisconnectSource.
error MT5210: Native linking failed, undefined symbol: _MIDIPortDispose.
error MT5210: Native linking failed, undefined symbol: _kMIDIPropertyName.
error MT5210: Native linking failed, undefined symbol: _kMIDIPropertyUniqueID.
error MT5210: Native linking failed, undefined symbol: _vDSP_create_fftsetup.
error MT5210: Native linking failed, undefined symbol: _vDSP_fft_zip.

Any ideas if I missed anything or configured something incorrectly?

radio42

  • Posts: 4576
Re: Sample for Xamarin iOS
« Reply #14 on: 14 Nov '14 - 21:34 »
? All these errors doesn't look they are Bass.Net related?!
I am not a Xamarin, nor an iOS or OSX expert, so I am afraid, that I can not add much more info.

However, to me this looks like some internal issues.
Where is "_AudioComponentFindNext" defined? This is not a BASS or a Bass.Net method/class.

MikaelS

  • Posts: 198
Re: Sample for Xamarin iOS
« Reply #15 on: 15 Nov '14 - 15:13 »
No, you are correct. These errors relates to missing linking of tha Audiotoolbox framework.
Something is quite odd with Xamarins linker options, I will contact their support about it since it requires me to do not apply any linker optimizations (something rated as a bug by themselves) to get it to work. (Applies to both debug/ad-hoc mode)

Phewm what a pain, developing a native objective-c app with BASS is way more simple :)

markj

  • Guest
Re: Sample for Xamarin iOS
« Reply #16 on: 17 Nov '14 - 07:14 »
So is the consensus that bass.net is broken until Xamarin fixes the linker?  I can get it to build for the simulator (it has runtime errors) and won't build at all for my iPhone 6 (missing the Audio frameworks)

radio42

  • Posts: 4576
Re: Sample for Xamarin iOS
« Reply #17 on: 17 Nov '14 - 08:18 »
No!
All the latest errors reported here have been due to another lib being used (Audiotoolbox framework).

MikaelS

  • Posts: 198
Re: Sample for Xamarin iOS
« Reply #18 on: 17 Nov '14 - 19:30 »
AudioToolbox is the native iOS library used for Audio handling and somehow it does not getting included in the Linking stage of Xamarin.
I have an open support ticket with them about this, some sample code is sent to them. So, when I know more I will post it here.

markJ

  • Guest
Re: Sample for Xamarin iOS
« Reply #19 on: 19 Nov '14 - 07:31 »
Ok I got it to build by

  • selecting "link all assemblies"
  • adding all the *.a libs to my project
  • using the compile ags  -cxx  -gcc_flags "-lstdc++  -L${ProjectDir} -lbass -lbass_fx -lbass_mpc -lbass_ape -lbassopus -lbassmidi -lbassmix -lbassenc -lbasswv -lbassmidi -lbassflac -force_load ${ProjectDir}/libbass.a ${ProjectDir}/libbassmix.a"


I have no idea what I am doing really, but this worked for me....

mserougi

  • Posts: 13
Re: Sample for Xamarin iOS
« Reply #20 on: 20 Jun '15 - 04:31 »
Just in case this might help someone else:

You really don't need to "Link All Assemblies". This can potentially break other libraries or even your own code if you're using features such as reflection. From Xamarin's documentation:

http://developer.xamarin.com/guides/ios/advanced_topics/linker/
"When linking everything, the linker can use the whole set of its optimizations to make the application as small as possible. It will modify user code, which may break whenever the code uses features in a way that the linker's static analysis cannot detect. In such cases, e.g. webservices, reflection, or serialization, some adjustements might be required in your application to link everything."

So while you do have control over your own code, you usually don't for third party libraries.

However, you can use the default "Link SDK Assemblies". You'll have to add all Bass libraries and addons as native references, the compiler will take care of generating the proper gcc flags for you. Last, you add gcc flags to other required libraries not loaded by Xamarin or your code, in my project the "Additional mtouch arguments" looked like this:

Code: [Select]
--gcc_flags "-lstdc++ -framework coremidi -framework accelerate"
Notice how I did not have to add "audiotoolbox", but that's because my project uses audio already elsewhere, and when using "using" with a framework, that framework and its dependencies are loaded for you.

Oh and even though you can only add the libraries you need as native references, skip the above, and use "Don't link", avoid doing so at all cost, your binary will explode in size otherwise!  

norbert

  • Posts: 122
Re: Sample for Xamarin iOS
« Reply #21 on: 9 Aug '15 - 09:21 »
You'll have to add all Bass libraries and addons as native references

How do you add the libbass.a, libbassmidi.a, etc. as "native reference" in a Xamarin iOS project  ???

I only see the option to add a .NET reference or I can add a lib.a file and set the build action to "Comile", "None", etc.

mserougi

  • Posts: 13
Re: Sample for Xamarin iOS
« Reply #22 on: 9 Aug '15 - 10:23 »
My project is a shared iOS/Android Forms project. If I right-click the .iOS project, I get an "Add" option, under it there are several options including the "Add Native Reference" one.

norbert

  • Posts: 122
Re: Sample for Xamarin iOS
« Reply #23 on: 9 Aug '15 - 12:17 »
I'm using Visual studio  - there is no "Add Native Reference"  item.

I guess you are using Xamarin studio ?  Also , are you on Mac or on Windows ?

mserougi

  • Posts: 13
Re: Sample for Xamarin iOS
« Reply #24 on: 11 Aug '15 - 01:29 »
Yes, I am using Xamarin Studio on a Mac, and the above instructions were specific to that IDE.