Building Mono's class libraries on Windows - c#

Can anyone provide a step by step instruction on how to build the Mono class library (namely System.dll and mscorlib.dll) on windows? I can already build the core libmono/mono stuff using msvc.
I've already looked at the following (none of them work...)
http://ondotnet.com/pub/a/dotnet/2005/02/07/monowindows.html
http://www.codeproject.com/KB/cross-platform/mono_on_windows.aspx
http://www.mono-project.com/Compiling_Mono_on_Windows
Note: I'm using the latest source from SVN. (I need tasklet support...)
Thanks.

Cygwin is the only psuedo-supported way to compile the Mono class libraries on Windows.
You may be better off compiling them on Linux and then copying them over to Windows.

Related

Crossgen compilation in .NET Core

I have been using .NET Core for some time now. And I have created a Console App. Everything works however I heard that I can compile .NET Core app assembly into a native assembly using CrossGen. Which quoting their documentation:
To help make your app start up faster, CoreCLR includes a tool called CrossGen, which can pre-compile the MSIL code into native code.
I have been trying for a long time right now and I have really no idea, how can I do this. There is really little documentation for CrossGen and even less questions here at StackOverflow.
How can I compile my .NET Core App to native code using CrossGen on a Mac?
I'd appreciate if somebody could answer this question with given examples.
crossgen is a tool that comes bundled with CoreCLR in the NuGet package, or is built alongside it from source. The OSX runtime package for CoreCLR here has crossgen in tools/crossgen path inside the nuget archive.
If you run the tool without any arguments, it should give you basic usage instructions. Generally, what you will want to do is run crossgen <path-to-your-app>.

MonoDevelop 5.0 for Linux Distro?

According to the official website, Mono now supports System.Speech (in 5.0) . However, I am unable to reach a linux build of version 5.0
"Packages for MonoDevelop 5.0.0.878 not yet available. The latest available version is MonoDevelop 4.2.1"
Is there any way of achieving this? (tarballs, git?)
Notes
I am using ArchLinux
The best way to use the last monodevelop on Linux is to get it from git (it's very fast and very easy :)
Now I'm using it (5.1) on Ubuntu 14.04.
You can get the source code from here:
git clone git://github.com/mono/monodevelop.git
and then compile it: http://monodevelop.com/developers/building_monodevelop
Remember that you must have installed Mono runtime 3.x.
I am answering this a little earlier but i think it applies right now too because Xamarin have already provided Mono 3.6.0 builds(technical preview) for Debian and derivatives.And with in a few months the best way to get anything latest related to mono will be from Xamarin official builds.They will provide Mono and some important applications including Monodevelop for every Debian and Centos derived Linux distributions.
See this link......
mono builds for many Linux distributions
Having just built Monodevelop the hard way, I would recommend downloading a tarball from http://download.mono-project.com/sources/monodevelop/ as everything is already included and requires no additional downloads except the some apt-get installs.
If you really want to use the git repo here is how to fix the two major issues I had.
1) I'm behind a proxy so I had to edit git module files to not use the git protocol as described in this post https://stackoverflow.com/a/11410074/1516326
2) You have to Import the Mozilla LXR certificates for Mono, so NuGet can update correctly, using:
mozroots --import --sync
For the entire process follow these instructions: http://www.monodevelop.com/developers/building-monodevelop/

Compile VS2010 c# solution (project) on ubuntu

What's the best way to build a c# solution made with Visual Studio on Ubuntu? Is there a way to convert the .sln file to a makefile? Should I use Mono?
The first thing I would do would be to use Moma to check to see if your program will run under Mono as is. You can also use MonoDevelop which can use Visual Studio Projects.
From their faq: In fact, since MonoDevelop 2.0 the default project format has been VS2008-style MSBuild projects, but VS2005 and VS2010 formats are also handled.
C# is a .NET language, .NET is a Windows-based framework. It has been ported to Linux operating systems (Ubuntu included) via the Mono Project. So yes, you need to use Mono.
Mono is the best I've tried. It says on their homepage that they are binary compatible between each other, so if it's already built, you could just run it on Mono. No need to recompile.
Your best bet is to use Mono if you want to use a process like MsBuild. Mono has xBuild that is similar. This SO question has some information about using Mono.

How to use NLog in linux with mono?

I'm porting a C# application which is completely written in windows under Visual studio which did all the nice bits for me. Now I'm finding it difficult to be able to run it under Linux with mono. I'm using a few libraries in it which I included but I'm unable to use NLog which I dont find any native version for debian-squeeze. How should I link Nlog into my project and also the config file for it?
p.s : I'm compiling under debian-squeeze x64.
Have a look here.
There is a problem with the latest NLog release - check if you can use NLog 1.0.
In general this article explains how you could install the NLog assembly for your program when you copy the compiled dll from your Windows machince to your Debian box.

SQLite on C# Cross-Platform Applications

Can someone help/guide me with using SQLite lib on Linux (MONO) and Windows (.NET)
On linux i use native mono sqlite client, and on windows i use http://sqlite.phxsoftware.com/
is there a way to define 'using' directives like this :
#if (linux)
using Mono.Data.Sqlite;
#else
using System.Data.SQLite;
Another problem is small differencies on both implementations, like :
cmd = new SqliteCommand(); // mono
cmd = new SQLiteCommand(); // sqlite.phxsoftware.com
Waiting for any help
If you know better or simplier way to do this it'll very thankfull for info.
Thanks
You can use csharp-sqlite which is a port to C# of Sql-Lite. It is very active and based on 3.6.22 version of SqlLite. See Miguel's comments on attempts to try to speed it up.
I've recently come across the issue too: building an application that uses Sqlite on Windows with Visual Studio and deploying it on an Ubuntu Server box for production.
The simplest solution I've found is using the Mono driver for Sqlite: Mono.Data.Sqlite.
Things could have been a little simpler but there is a bug with .Net 4.0 that is not yet packaged in the official Mono releases.
So you'll have to compile Mono from source (the general instructions are here):
first compile the whole Mono stuff
you do not need to install it if you want to keep your current Mono setup
copy the Mono.Data.Sqlite.dll library
Of course you can "cross-compile": I've built Mono on Ubuntu Server and used the dll in a Windows .Net project.
Then ensure you have the native Sqlite library (sqlite3.dll for Windows and sqlite3.so for Linux) in your library path: for Windows I simply copied the sqlite3.dll next to the Mono.Data.Sqlite.dll assembly, for Linux it should work out of the box.
You project should then work seamlessly in both Windows/.Net and Linux/Mono environments.
You can solve the naming differences using alias
#if (linux)
using SqlCommand = Mono.Data.Sqlite.SqliteCommand;
#else
using SqlCommand = System.Data.SQLite;
Using different assemblies for different builds is a more complex task i think.. you can have a look at the MSBuild documentation
There is a fully managed SQLite translation. If you use that, then you could use the same DLL on Mono and Windows.
Another way to solve your issue is to create your own database-interface and then implement that interface once for Mono and one for Microsoft .NET in separate DLLs. (Basically the same way you create code that runs against different databases)
You can just use the mono implementation of SQLite for both, Windows and Linux versions of your software. Just include the mono assembly for SQLite in your software package and refer to it locally.
As you can read here in the last post, you can use the managed way of mono solely in your code and need just to redistribute the native part for windows differently. But you do not have to mess with to managed implementations and redundand code through that.
The open-source Vici CoolStorage ORM library works on Windows (.NET), Mono (Mac,Linux and Windows) and MonoTouch (iPhone) using that platform's SQLite driver.
To use it on these different platforms, you don't have to change anything to your source code. Just recompile, and it should work.
IMO you should first try to find an implementation that works in both Windows and Linux. If that doesn't work, create an assembly that defines a common interface for SQLite and put all you "#if LINUX" code in that assembly. Then use that assembly in the main application to avoid cluttering the main app with all the # defines.
The SQLite ADO.NET provider is actually a mixed-mode assembly, which contains the native SQLite library. This native library is not the same on Windows and Linux of course, so this provider doesn't work on Linux. However, there is a managed-only version of the provider (SQLite-1.0.65.0-managedonly-binaries.zip on the download page). So I think you just need to use this version of the provider, and provide the adequate native SQLite dynamic library along with it (.dll on Windows, .so on Linux)
Some answers suggest the fully-managed C# port of SQLite3. But, unfortunately, no release to date supports Linux or Mac OS X despite being compilable with the Mono C# compiler.
A future release will correctly run on those non-Windows platforms with the Mono runtime. WIth some caveats, the source repository contains code that works.
Having said that, the System.Data.SQLite implementation available from sqlite.org works with both .Net and Mono, on Windows and non-Windows platforms. You just need to ensure that the app.config used by Mono at runtime maps the (C++) SQLite3 dll to the appropriate .so or .dylib library. If you choose the "mixed-mode" version, then it should just work and you don't need to worry about separate dlls.

Categories

Resources