I've come across an issue where a library uses DLLImport two times for a function that is overloaded. I am building for iOS. Unity throws this when I try to build "Error building Player: SystemException: Duplicate native method found : BASS_MIDI_StreamCreateFileMemory. Please check your source carefully."
I did a simple example with my own functions (where I was careful to not use the same parameters), and Unity refuses to compile. Is this only a limitation for ios? It seems to build OK for OSX.
Here is the example .mm file
extern "C"
{
int StreamCreateFileMemory(bool mem, IntPtr memory, long offset, long length, int flags, int freq)
{
return 0;
}
int StreamCreateFileMemory(bool mem, byte[] memory, long offset, long length, int flags, int freq)
{
return 0;
}
}
Here is the .cs
using UnityEngine;
using System.Collections;
using System;
using System.Runtime.InteropServices;
public class tests : MonoBehaviour
{
[DllImport("__Internal"]
private static extern int StreamCreateFileMemory([MarshalAs(UnmanagedType.Bool)] bool mem, IntPtr memory, long offset, long length, int flags, int freq);
[DllImport("__Internal")]
private static extern int StreamCreateFileMemory([MarshalAs(UnmanagedType.Bool)] bool mem, byte[] memory, long offset, long length, int flags, int freq);
}
Is there any way around this silly design issue? Unity should be smart enough to handle this if other projects using the MonoFramework are capable.
↧