aboutsummaryrefslogtreecommitdiffstats
path: root/pages/develop/setup/csharp/start.md.txt
blob: 2ef3ced6b36333268e814e24e43abb9b40c43fc8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
---
~~Title: Setting Up a C# Development Environment~~
---

# Setting Up a C# Development Environment #

This page shows how to compile and install the Enlightenment Foundation Libraries (EFL) with C# bindings support, and explains how to build and run applications using them.

|     | WARNING |     |
| --- | ------- | --- |
| ![NOTE](/_media/note-important.png) | **The C# bindings are currently in BETA state**<br>They should only be used for experimenting and **NOT** for any product development. | ![NOTE](/_media/note-important.png) |

## Prerequisites ##

* Before you start you may want to read about [how to compile the EFL](https://www.enlightenment.org/docs/distros/start).

## Dependencies ##

### On Linux ###

You need a compatible version of [Mono](http://www.mono-project.com/download/stable) (5.0 or higher).

> **NOTE:**
> Currently the C# bindings do **NOT** work with Mono 4.x.

The paths to the ``mcs`` compiler and to the ``mono`` application must be in the ``PATH`` environment variable before compiling.

### On Windows ###

In order to have EFL on a Windows environment we highly recommend following [this guide](https://phab.enlightenment.org/w/windows/) which accomplishes that using [win-builds](http://win-builds.org) and [MSYS2](http://www.msys2.org).

You need a compatible version of [Mono](http://www.mono-project.com) (5.0 or higher).
You can use Mono binaries installed directly to your Windows system (i.e. outside the MSYS2 environment), you just need to make sure that the paths to the ``mcs.exe`` compiler and to the ``mono.exe`` application are in the ``PATH`` environment variable in your MSYS2 terminal.
Using the default installation path, Mono binaries normally go in ``C:\Program Files\Mono`` so in MSYS2 you can point to the binaries using the path ``/c/Program Files/Mono/bin``.
You can also permanently set this in your ``/etc/profile`` in MSYS2 adding something like this at the end of the file:
```bash
export PATH="$PATH:/c/Program Files/Mono/bin"
```
If you used another installation path to Mono just adjust the paths used.

> **NOTE:**
> It is advisable to add the Mono path at the **end** of the ``PATH`` environment variable, like in the example above.
Mono has its own version of some applications (like ``pkg-config``) which can take priority over the ones from MSYS2 and cause things to fail.

Now you can use the MSYS2 console to compile, install and run EFL and your applications.

## Compiling and Installing EFL With C# Support ##

In order to compile and install EFL with C# binding support, on both Windows and Linux, just compile the EFL like the respective guides explain, and add the argument ``--enable-csharp-bindings`` to the ``autogen.sh`` or ``configure`` command:

```bash
./autogen.sh --enable-csharp-bindings #other arguments
make -j4
sudo make install
```

> **NOTE:**
> It is known that some portions of the code (typically the examples) can get a bit outdated from time to time, causing the building process to fail. The leading cause for this is a missing dependency.
> Usually, reading the error message and installing the missing package solves the problem.
> If you cannot solve the problem by yourself, try [contacting the community](/contact).

## Building EFL C# Applications ##

With EFL installed, you can compile EFL applications using ``pkg-config`` to get the proper flags to use the C# bindings:

```bash
mcs your_app.cs -out:your_app.exe `pkg-config --libs efl-mono`
```

Otherwise, you have to manually point the compiler to the location of the EFL C# bindings library ``libefl_mono.dll``, like this:

```bash
mcs your_app.cs -out:your_app.exe -r:/home/my_user/efl/build/src/lib/efl_mono/libefl_mono.dll
```

## Running EFL C# Applications ##

To run your application you can either copy the EFL C# bindings library ``libefl_mono.dll`` to your application folder or set the ``MONO_PATH`` environment variable and then execute it using ``mono``. In both cases, you can use ``pkg-config`` to get the right paths.

Example copying the library:

```bash
cp `pkg-config --variable=Libraries efl-mono` .
mono button_example_00.exe
```

Example setting ``MONO_PATH``:

```bash
export MONO_PATH=`pkg-config --variable=assemblies_dir efl-mono`
mono button_example_00.exe
```

Note that if you installed EFL in a path that is not directly accessible to ``pkg-config`` or to your application you have to manually make it accessible somehow, for example, setting proper environment variables before compiling and running:

```bash
export PKG_CONFIG_PATH=/opt/my_install_prefix/lib/pkgconfig
export LD_LIBRARY_PATH=/opt/my_install_prefix/lib
```
Try the [Hello World](/develop/tutorials/csharp/hello-world-cs.md) tutorial now to verify that everything works as expected.