My unity version is 5.3.4f, and I hava C# script as a.cs and compiled a.exe and it runs OK. Then I use IL2CPP to translate a.exe into C++ compiled exe a_il2cpp.exe with command:
il2cpp.exe --outputpath=a_il2cpp.exe --cachedirectory="obj_cache" generatedcppdir="generated_cpp" a.exe
But it shows no error and no output, do I miss something? I have C++ compiler installed.
Unity does not support using IL2CPP as a general mechanism for translating C# assemblies to native binaries. In theory this is possible (indeed some of the internal testing tools at Unity do this), but I don't think the command line you mention here will allow it to work.
Related
I have a C# program that uses the MWARRAY.dll from MATLAB. I am trying to run this program on Ubuntu with mono. But, it keeps saying the MWArray.dll was not found. I have install Matlab runtime on my Ubuntu machine. I wanted to know how to reference Matlab ubuntu libraries in C# code. Is it even possible?
You can use DLLmaps to map library names for specific operating systems. For example, you can put a line like <dllmap dll="some.dll" target="libsome.so" os="!windows"/> in your /etc/mono/config file and it will be mapped for every project.
I'm trying to integrate CLIPS library in unity beta (x64) using mono 2.0 and net 4.6.
I'm using a net wrapper for clips: https://github.com/yifeitao/CLIPSNet
This project has two main files:
managedCLIPS.dll, which compiles clips C files into managed C++.
clipsNET.dll, the actual wrapper for mono, which uses managedclips.
I can compile both files and drag to unity, but when trying to run it I get some errors: MissingMethodException: Method contains unsupported native code
https://imgur.com/ESLJdGT
I used MoMa: mono migration analyzer and and it says "Methods called marked with [MonoTodo]: 5" and Currently a no-op
https://imgur.com/pS4uMZ4
¿Any ideas of how can I solve this?
Thanks!
I have a few questions about Mono:
1) Is there a way to compile application for Linux without installation of Xamarin Studio?
For example i have my helloworld.cs, i use dmcs to compile it into exe. Is there another compiler or flag to compile app for linux?
2) I need to statically link Mono runtime to run on the computer without Mono installed.
There is mkbundle command but it is a very difficult process to make it work on Windows. And static linking does not work on Windows.
And besides, I need to automate these processes =/
P.S. As I said, I'm working on Windows.
1) It doesn't matter if you compile your code with the Microsoft or Mono compiler, the resulting assembly should work on all platforms (as long as you don't use any platform-specific code of course).
You can take an assembly compiled with the MS compiler and run it on Linux/Mac with Mono, or compile on Mono and run it on Windows/.NET.
2) Problems with mkbundle should probably be filed as a bug on https://bugzilla.xamarin.com
This is what I want to achieve: build native C++ DLL library on Visual Studio, and invoke its' method on Ubuntu Linux\Mono via PInvoke from C# application. Simplified code:
[DllImport("MyLib")]
static extern int MyFunction();
static void Main(string[] args)
{
int result = MyFunction();
}
On Windows it works like a charm.
I run this sample application on mono, but I got error: DllNotFoundException. When I enable mono debugging (MONO_LOG_LEVEL="debug" mono MyApp.exe) then I can see that this DLL is found, but cannot be loaded because of error: "invalid ELF header". I suppose that DLL must be compiled with some special flags, so linux can recognize it. How to do this?
The C++ compiler that is supplied with Visual Studio targets Windows. You are trying to execute code on Linux and so you need to compile your code with a compiler that targets Linux. You simply cannot execute a Windows DLL natively on Linux.
Your solution is to take the source code to a Linux C++ compiler and compiler a Linux shared object library.
This won't work. The unmanaged library is specific to the platform on which you're running, so with Mono on Linux your unmanaged library needs to be a .so.
According to Mono Documentation you have to link the DllImport against X and Mono should do the name translation.
For example:
[DllImport("X")]
static extern int MyFunction();
This line should link against X.dll on Windows, libX.so on Linux and Unix and X.dylib on Mac OS X. You have to build each one on a native machine with gcc or you a cross-compiler to do the work.
Notice that even though you compile it natively, if it makes use of native API (WIn32 API for example) it won't compile on other platforms. You have to use cross-platform development tools, libraries and patterns to work around these issues.
I have a rather large C# library, originally written for .NET and Windows, which we are now porting to Mono and Linux. It is thoroughly unit tested with NUnit. The porting has been fairly simple, but now I need some real debugging features, like error line numbers and breakpoints.
I'm compiling either using VS2010 on Windows 7 or with xbuild on Debian 6.0.2, it really doesn't matter because the binaries are fully compatible. Running tests with Mono 2.10.2 built from tarball, and NUnit 2.5.10 from Debian experimental.
When I run my project in Visual Studio, debugging works fine after I attach to the nunit process. So, does anyone know how I can enable fully-featured Mono debugger support with NUnit tests?
P.S. I've seen this, but I'm compiling with xbuild and running with nunit-console, so I can't manually give arguments to either the compiler or the Mono runtime.
Thanks in advance!
UPDATE: I discovered the pdb2mdb utility, but even when I use this, I still can't get line numbers, which leads me to believe that the code isn't being compiled with --debug. But since I'm using xbuild on a VS .sln file, instead of invoking the compiler directly, how do I use --debug??
Figured it out. Jon Skeet comes to the rescue, once again:
Nunit .net vs mono
After converting to mdb, I needed to run nunit-console.EXE from inside the mono command, like this:
mono --debug /opt/mono-2.10/lib/mono/4.0/nunit-console.exe Test.dll -config=Debug
That took way longer than it should have :P