# Running the PIDL Compiler

## 1. Windows

You can use the [**PIDL add-on**](/proudnet.eng/proudnet/pn_utility.md#pidl-compiler-add-on) to create and compile PIDL files conveniently, but if it is not available, please set up <mark style="color:orange;">PIDL Custom Build</mark> in the following way.

#### 1-1. Setting up <mark style="color:orange;">PIDL Custom Build</mark> in a Visual Studio project

<figure><img src="/files/c6ffkwkMMP52xC13COfm" alt=""><figcaption></figcaption></figure>

Here are the details of each of the build settings.

> **Command line**: <mark style="color:orange;">\<Path where PIDL.exe is located>\PIDL.exe "%(FullPath)" -outdir .</mark>&#x20;
>
> **Description**: Compiling %(Filename).pidl ...&#x20;
>
> **Output**: %(RootDir)%(Directory)%(Filename)\_common.cpp;%(RootDir)%(Directory)%(Filename)\_common.h;%(RootDir)%(Directory)%(Filename)\_proxy.cpp;%(RootDir)%(Directory)%(Filename)\_proxy.h;%(RootDir)%(Directory)%(Filename)\_stub.cpp;%(RootDir)%(Directory)%(Filename)\_stub.h;%(Outputs)&#x20;
>
> **Additional dependency**: <mark style="color:orange;">\<Path where PIDL.exe is located>\PIDL.exe</mark>

{% hint style="warning" %}

* <mark style="color:orange;">PIDL.exe</mark> is located in the <mark style="color:orange;">util</mark> folder of ProudNet.
* You must set the same settings for both the Debug and Release builds.
  {% endhint %}

Once you are all set up, compile the PIDL file and if it is done successfully, you should see the output like below.

```
1>---— Start build: Project: ..., Configuration: Release Win32 ---—
1>Compiling TestC2C.pidl ...
1>The build log was saved to "...".
1>ProudNetTest_2005 - Error: 0, Warning: 0
========== Build: Success 1, Fail 0, Latest 0, Omit 0 ==========

```

Visual Studio 2005 and 2008 versions support[ **Custom Build Rules**](/proudnet.eng/proudnet/using_pn/pidl/using_pidl.md#custom-build-rules)**,** which are automatically set up each time you add a PIDL file without the need for custom build settings. However, Visual Studio 2010 and later versions can use <mark style="color:orange;">Build customizations.</mark>

<figure><img src="/files/Bfm8Gmis2PPIafNyX8kZ" alt=""><figcaption></figcaption></figure>

***

## 2. Linux

{% tabs %}
{% tab title="Ubuntu" %}
Example of installing the open source Mono library on Ubuntu\
※ The open-source Mono project supports Linux, Windows, and Mac OS.

```
$sudo apt-get install mono-gmcs
$sudo apt-get install mono-runtime
```

{% endtab %}

{% tab title="CentOS" %}
Example of installing the open source Mono library on CentOS\
※ The open-source Mono project supports Linux, Windows, and Mac OS.

```
$sudo yum install mono-devel
$sudo yum install mono-complete
```

{% endtab %}

{% tab title="Mono platform" %}
Example of running the PIDL compiler on the Mono platform

```
$pwd
/home/ProudNet/util
$mono PIDL.exe ../Sample/Simple/Common/*.pidl -outdir ./
```

{% endtab %}
{% endtabs %}

***

## 3. C\#

RMI is also available in the C# language, so the PIDL compiler also generates proxy and stub code for the C# language.

\
Running as follows generates the proxy and stub code for the C# language. (Existing -clr is the same as -cs.)

```csharp
PIDL.exe -cs <input-file-name>
```

It is recommended to use proxy and stub created in C# language as commonly used modules. As with PIDL, this module requires input of a PIDL file from a C# project and custom build.

<figure><img src="/files/HaGuSESVBL6tYIK4SZmQ" alt=""><figcaption><p>Setting up a custom build for PIDL files in a C# project</p></figcaption></figure>

The proxy,stub generated after building <mark style="color:orange;">C2S.pidl</mark> is as follows.

* C2S\_common.cs
* C2S\_proxy.cs
* C2S\_stub.cs

Include these files in your C# project (<mark style="color:orange;">.csproj</mark>). However, these files are build output and should not be placed in source control (e.g. SVN, etc.), as you may get writing errors on read-only files.

We recommend opening the <mark style="color:orange;">.csproj</mark> file in an editor and modifying it as follows.

```csharp
<Target Name="BeforeBuild">
<ItemGroup>
<Compile Include="C2S_common.cs" />
<Compile Include="C2S_proxy.cs" />
<Compile Include="C2S_stub.cs" />
</ItemGroup>
 
</Target>
<Target Name="AfterBuild">
</Target>
```

{% hint style="info" %}
The proxy and stub generated in the C# language are the class with the same name as in C++, and the usage is the same.
{% endhint %}

### - Setting public, internal, and private for RMI proxy and stub class

The access modifiers for the proxy, stub, and common classes that the PIDL compiler generates are **internal** by default. These classes can be used from different sources within the same module (or assembly), but not from other modules.&#x20;

However, if you want to build a module that collects these classes separately and use the classes in this module in other modules, you may want to change the access modifier to **public**.

\
In this case, set the access modifier properties for the class that the PIDL compiler generates as follows.

```csharp
// This will let proxy, stub and common classes to have access modifier 'public'.
[marshaler(clr)=MyMarshaler, access=public]
global MyC2S 3000
{
    Foo(...);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.proudnet.com/proudnet.eng/proudnet/2.setting/running-the-pidl-compiler.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
