# ezcompilex

> It is a node.js library which is written on top of compilex to run code on Linux

Latest version **0.7.4** (published 2015-04-30) · 0 weekly downloads

## Install

```sh
npm install ezcompilex
pnpm add ezcompilex
yarn add ezcompilex
bun add ezcompilex
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.4 |
| Published | 2015-04-30 |
| First published | 2015-04-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Accolite Sofware Pvt. Limited https://accolite.com) |
| Maintainers | sumit10bana |
| Keywords | compiler, compilex, c, c++, java, python, c#, vb, gcc, javac, csc, vbc |

## Links

- npm: https://www.npmjs.com/package/ezcompilex
- Repository: https://github.com/accolite/compilex
- Issues: https://github.com/accolite/compilex/issues
- npm.io page: https://npm.io/package/ezcompilex

## Dependencies (2)

- [cuid](https://npm.io/package/cuid.md) ~1.2.4
- [colors](https://npm.io/package/colors.md) ~0.6.2

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 0.7.4 (latest) — 2015-04-30

## README

<h1>compilex</h1>
[![NPM version](https://badge.fury.io/js/compilex.svg)](http://badge.fury.io/js/compilex)
[![Build Status](https://travis-ci.org/scriptnull/compilex.svg?branch=master)](https://travis-ci.org/scriptnull/compilex)
[![Dependency Status](https://david-dm.org/scriptnull/compilex.svg)](https://david-dm.org/scriptnull/compilex)
[![Download Status](http://img.shields.io/npm/dm/compilex.svg)](https://www.npmjs.org/package/compilex)
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/scriptnull/compilex/blob/master/License.md)
[![Gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/scriptnull/compilex?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)


compilex is a node.js library which is used to build online code compiler/interpreter websites and webservices.

You can compile and respond back outputs for all the languages that can be compiled by the server.

Some of the online code compiling/judging websites are 
<ul>
<li><a href="http://www.codepad.org">codepad</a></li>
<li><a href="http://www.ideone.com">ideone</a></li>
<li><a href="http://www.hackerrank.com">HackerRank</a></li>
<li><a href="http://www.codechef.com">CodeChef</a></li>
</ul>
Using compilex , you can built sites and services like the above said examples.

Why compilex ?
=============
1) compilex can detect infinite loops in the users program . <br/>
2) It can compile programs by getting input from STDIN.<br/>
3) Generates statistics for the administrator. <br />

Supported Languages 
===================
compilex is currently in initial development stage . As the library grows , so does the list here .

| Language | Support |
|---------|:-------:|
|C |&#x2714;|
|C++ | &#x2714; |
|Java | &#x2714; |
|Python | &#x2714; |
|C# | &#x2714; |
|Visual Basic | &#x2714; |


Work Flow
=========
1) Get the program as input from the client as a request<br/>
2) Use compilex modules to compile the program <br/>
3) Get the output and errors in json and string formats <br/>
4) Respond the output to the client<br/>

Setting Up Compilers 
====================
Inorder to compile any programming language , you need to first have the compiler for that programming language in the server machine.

<h4>C and C++</h4>
<ol>
<li><b>Installation :</b>You need GCC compiler that can compile programs from your cmd/terminal
    <ul>
    <li>Windows - You can get <a href="http://www.mingw.org/">MinGw</a> . </li>
    <li>Linux - Most of the linux versions are installed with gcc by default. If you haven't got , Take a look at <a href="http://gcc.gnu.org/wiki/InstallingGCC">Installing GCC</a> . </li>
    </ul>
</li>
<li><b>Testing the Environment :</b>After installing , set your environment variables for accessing the GCC command lines from any directory
    <ul>
    <li>Windows - create a c file in a directory , execute <br/> 
    <i><b>g++ filename.c -o output.exe<br/>
    output.exe</b></i><br/>
    then you will get the output of the program</li>
    <li>Linux - create a c file in a directory , execute <br/>
    <i><b>gcc filename.c -o output.out<br/>
    ./output.out</b></i><br />
    then you will get the output of the program</li>
    </ul>
</ol>

<h4>Java</h4>
<ol>
<li><b>Installion :</b> You need JDK ( Java Development Kit ) to compile Java programs.Click <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"> here </a> to download JDK for various platforms.</li>
<li><b>Testing the Environment :</b>After installing , set your environment variables for accessing the javac command lines from any directory
<ul>
<li>Create a Java file named Main.java with main function<br/>
<i><b>javac Main.java <br />
java Main </b></i><br/>
then you will get the output of the program.
</li>
</ul>
</ol>

<h4>Python</h4>
<ol>
<li><b>Installation :</b> You can get and install Python from <a href="https://www.python.org/download/"> here </a></li>
<li><b>Testing the Environment :</b>After installing , set your environment variables for accessing python command lines from any directory
<ul>
<li>Create a python file hello.py and execute <br/>
<i><b>python hello.py</b></i><br/>
then you will get the output of the program.
</li>
</ul>
</ol>

<h4>C# and VB </h4>
<ol>
<li><b>Installation :</b> You can have the idea of accessing C# compiler from <a href="http://msdn.microsoft.com/en-us/library/ms379563(v=vs.80).aspx"> here </a> . This step also adds VB compiler to the scope automatically as csc and vbc are located in the same directory </li>
<li><b>Testing the Environment :</b>After installing , set your environment variables for accessing C# and VB command lines from any directory
<ul>
<li>Create a C# or VB file Hello.cs or Hello.vb and execute <br/>
<i><b>csc Hello.cs <br/>
     Hello.exe
</b></i><br/>
or <br />
<i><b>vbc Hello.vb <br/>
     Hello.exe
</b></i><br/>
then you will get the output of the program.
</li>
</ul>
</ol>

<b>NOTE : </b> Video demos for setting up the compilers and using compilex will be availble soon.

Documentation
=============
<h5>1)Require compilex </h5>
```javascript
var compiler = require('compilex');
var options = {stats : true}; //prints stats on console 
compiler.init(options);
```
init() creates a folder named temp in your project directory which is used for storage purpose.
Before using other methods , make sure to call init() method.

<h5>2)C and C++ </h5>
```javascript
    //if windows  
    var envData = { OS : "windows" , cmd : "g++"}; // (uses g++ command to compile )
    //else
    var envData = { OS : "linux" , cmd : "gcc" }; // ( uses gcc command to compile )
    compiler.compileCPP(envData , code , function (data) {
        res.send(data);
        //data.error = error message 
        //data.output = output value
    });
    
    //res is the response object
```

<h5>3)C and C++ with inputs </h5>
```javascript
    //if windows  
    var envData = { OS : "windows" , cmd : "g++"}; // (uses g++ command to compile )
    //else
    var envData = { OS : "linux" , cmd : "gcc" }; // ( uses gcc command to compile )
    compiler.compileCPPWithInput(envData , code , input , function (data) {
        res.send(data);
    });
```

<h5>4)Java</h5>
```javascript
    //if windows  
    var envData = { OS : "windows"}; 
    //else
    var envData = { OS : "linux" }; // (Support for Linux in Next version)
    compiler.compileJava( envData , code , function(data){
        res.send(data);
    });    
```

<h5>5)Java with inputs</h5>
```javascript
    //if windows  
    var envData = { OS : "windows"}; 
    //else
    var envData = { OS : "linux" }; // (Support for Linux in Next version)
    compiler.compileJavaWithInput( envData , code , input ,  function(data){
        res.send(data);
    });
```
<h5>6)Python</h5>
```javascript
    //if windows  
    var envData = { OS : "windows"}; 
    //else
    var envData = { OS : "linux" }; 
    compiler.compilePython( envData , code , function(data){
        res.send(data);
    });    
```

<h5>7)Python with inputs</h5>
```javascript
    //if windows  
    var envData = { OS : "windows"}; 
    //else
    var envData = { OS : "linux" }; 
    compiler.compilePythonWithInput( envData , code , input ,  function(data){
        res.send(data);        
    });
```
<h5>8)C#</h5>
```javascript
    var envData = { OS : "windows"}; 
    //mono modules for linux is not included till now
    compiler.compileCS( envData , code , function(data){
        res.send(data);
    });    
```

<h5>9)C# with inputs</h5>
```javascript

    var envData = { OS : "windows"}; 
    //mono modules for linux is not included till now
    compiler.compileCSWithInput( envData , code , input ,  function(data){
        res.send(data);        
    });
```
<h5>10)Visual Basic</h5>
```javascript
    var envData = { OS : "windows"}; 
    compiler.compileVB( envData , code , function(data){
        res.send(data);
    });    
```

<h5>11)Visual Basic with inputs</h5>
```javascript

    var envData = { OS : "windows"}; 
    compiler.compileVBWithInput( envData , code , input ,  function(data){
        res.send(data);        
    });
```

<h5>12)Memory Management </h5>
All the temporary files ( source code and executables ) are created in your temp directory.
flush and flushSync helps you to free the memory by deleting the temporary files.
```javascript
    compiler.flush(function(){
    console.log('All temporary files flushed !'); 
    });
```
Synchronous version of flush
```javascript
    compiler.flushSync();
```

<h5>13)Statistical Data</h5>
Getting statistics about your compilex server has been taken care.
fullStat returns json data about your server.
```javascript
    compiler.fullStat(function(data){
        res.send(data);
    });
```

---
_Source: https://npm.io/package/ezcompilex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
