Running mono on linux

How to Install and Use Mono on Ubuntu 22.04

Install and use mono on linux ubuntu 22.04; Through this tutorial, we will learn how to install and use mono on linux ubuntu 22.04.

Mono is a platform for developing and running cross-platform applications based on the ECMA/ISO Standards. It is a free and open-source implementation of Microsoft’s .NET framework.

How to Install and Use Mono on Ubuntu 22.04

  • Import Key
  • Add Repository
  • Update Dependencies
  • Install Mono again using the apt package
  • Check Mono Version
  • Use the mono on Ubuntu 22.04

Import Key

Open your command prompt and execute the following command on command prompt to import the repository key in ubuntu 22.04:

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

Add Repository

Then execute the following command on command prompt to add the repository to the list of our Ubuntu 22.04 repositories:

$ echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list

Update Dependencies

Execute the following command on command prompt to update the repository of the Ubuntu 22.04:

Install Mono again using the apt package

Execute the following command on command prompt to install the Mono again using the apt package manager:

$ sudo apt install mono-complete -y

Check Mono Version

To check the version of installed mono by executing the following command on command prompt:

Читайте также:  Управление usb устройствами linux

Use the mono on Ubuntu 22.04

To understand the usage of the Mono; let’s we will create a C-sharp code to print “Hello! world” by creating a file, MyCode.cs using the nano editor:

Type the following c sharp code:

using System; public class Tutsmake < public static void Main(string[] args) < Console.WriteLine ("Hello! world"); >>

Then saves the file, exits the editor by closing it, and compiles the file using the csc compiler:

Execute the following command on command prompt to run the executable file of the MyCode.cs:

Conclusion

Through this tutorial, we have learned how to install and use of the Mono in Ubuntu 22.04.

Источник

Compiling Mono on Linux

Pick an installation directory where you want your new copy of Mono to be installed. Lets call that location PREFIX. Your Mono installation and its dependencies will be installed there. For example, I like to use the directory /opt/mono, so I would replace PREFIX with /opt/mono in the following discussion.

If you have more than one Mono installation (for example to keep multiple versions around), you will want to read the document on Parallel Mono Environments on how to keep your various Mono installations separate.

It is strongly advised not to install Mono from source in /usr as it might conflict with Mono as installed by the Mono package.

Building Mono

Building Mono is a very simple process as Mono has very few external dependencies.

On some distribution you will need to install some development tools which are not installed by default.

Compiler/Build dependencies

Mono depends on GCC 4.8+ or Clang 3.3+ (it needs to support C++11) and on CMake 2.8.10.

Читайте также:  Astra linux создать администратора

The table below shows a (not necessarily complete list) of the compiler versions in various distributions. Strikethrough means it doesn’t satisfy the version needed.

Distribution GCC Clang CMake
Debian 7 4.7/4.6 3.0 2.8.9
Debian 8 4.9 3.5 2.8.11
Raspbian 8 4.9 (?) 3.5 (?) 2.8.11 (?)
Ubuntu 12.04 4.6 3.0 2.8.7
Ubuntu 14.04 4.8 3.4 2.8.12
Ubuntu 16.04 5.3 3.8 3.5.1
CentOS 6 4.4 3.4 2.8.12
CentOS 7 4.8 3.5 (?) 2.8.12

Debian based distributions

On Debian based distribution you should guarantee that some packages are installed in order for the compilation process to succeed.

This can be done easily by using apt-get:

 $ sudo apt-get install git autoconf libtool automake build-essential gettext cmake python3 curl 

Note: if you are using Ubuntu 15.04/Debian 8 or later, you also need to install the libtool-bin package. Without it, you will get the following error: **Error**: You must have ‘libtool’ installed to compile Mono.

Building Mono from a Release Package

Mono releases are distributed as .tar.xz packages from the Mono web site. Once you have your dependencies installed all you need to do is run the following command where VERSION is the package version number and PREFIX is your installation prefix:

PREFIX=/usr/local VERSION=4.2.1 tar xvf mono-$VERSION.tar.xz cd mono-$VERSION ./configure --prefix=$PREFIX make make install 

By the end of this process, you will have Mono installed on your PREFIX directory.

Building Mono From a Git Source Code Checkout

To build Mono from a Git Source Code checkout, you will want to have the official Mono installed on the system, as the build requires a working C# compiler to run. Once you do this, run the following commands, remember to replace PREFIX with your installation prefix that you selected:

PATH=$PREFIX/bin:$PATH git clone https://github.com/mono/mono.git cd mono ./autogen.sh --prefix=$PREFIX make make install 

Note that you have to have git installed on your distribution.

Читайте также:  Linux counting files in directory

One Stop Shop Build Script (Debian)

If you are on a Debian system (Debian/Ubuntu) and you just want to install Mono without thinking too much, just cut and paste the following script, and enter your root password when requested:

#!/bin/bash PREFIX=$@ if [ -z $PREFIX ]; then PREFIX="/usr/local" fi # Ensure you have write permissions to PREFIX sudo mkdir $PREFIX sudo chown -R `whoami` $PREFIX # Ensure that all required packages are installed. sudo apt-get install git autoconf libtool automake build-essential gettext cmake python PATH=$PREFIX/bin:$PATH git clone https://github.com/mono/mono.git cd mono ./autogen.sh --prefix=$PREFIX make make install 

This will by default install mono in /usr/local , but you can specify in the first argument of the script the directory of installation. /opt/mono or ~/.mono/ might be a nice target as well.

After installing it successfully, read the notes on Parallel Mono environments on how to use the installed mono instance.

Источник

Оцените статью
Adblock
detector