# Installation

## 4DIAC-IDE

The installation of 4DIAC-IDE is independent from the used operating system. In order to run 4DIAC-IDE you at least require Java 8.

To install 4DIAC-IDE you simply download the latest version for your operating system under downloads. Unzip it to any desired folder and start the 4DIAC-IDE. It already contains a function block library, some sample applications and also pre-build versions of FORTE. If you only want to use available Function Blocks you are ready to go.

### Building your own 4DIAC-IDE from source

Running 4DIAC-IDE from source has the great advantage that you can easily keep up with the developments performed in the Mercurial repository. In case you want to run 4DIAC-IDE from source follow the Installation steps under 4DIAC-IDE Installation from Source

## Precompiled FORTE

For conducting first experiments with 4DIAC you can use the pre-build version of FORTE which comes along in the runtime directory of the 4DIAC-IDE package. Step by step tutorial will direct you making a simple application with 4DIAC-IDE and using built-in FORTE. However if you want to develop your own Function Blocks or you want to run FORTE on different control devices, then you have to download and set up FORTE for the specific platform you are using. This means that you will need to compile FORTE from the source code. In the following section a general explanation is given, followed by the cases of Windows and Unix-based system, since most user's first test is done in these platforms. For other platforms, links are provided here below.

If you want to start using 4DIAC right away, you can skip the rest of the page and go directly to end where you can decide your next step.

## FORTE - Compile your own Function Blocks and code

### Download Source Code

The first thing to do is to get FORTE's source code. For that you will need Git to download it by using the clone command from Git to the repository https://git.eclipse.org/r/4diac/org.eclipse.4diac.forte. If you're using the terminal, do:

$ cd ~ $ git clone https://git.eclipse.org/r/4diac/org.eclipse.4diac.forte

The code will be copied to the new created folder ~/org.eclipse.4diac.forte. We'll call this folder FORTE_FOLDER_ROOT from now on.

### Generate files for compiling

Once you have FORTE's code in your computer, you must generate files to be compiled. Why? Because forte is prepared for many platforms and many features can be enable, disabled or tunned. In order to make this setting of preferences easier and faster, it's used a tool called CMake. For starters we recommend to use the GUI tool that comes with CMake.

1. When starting the CMake-GUI you have to select the source directory (1), which is FORTE_FOLDER_ROOT and also the directory where to build the binaries (2) (e.g. FORTE_FOLDER_ROOT/bin/posix or FORTE_FOLDER_ROOT/bin/win32, and so on) which is the output directory (let's call it OUTPUT_FOLDER). In OUTPUT_FOLDER, CMake will put the build project files (e.g., the makefiles) as well as any configuration data which then are compiled creating the executable. Then you will need to press the Configure button (3) at the low part of CMake. If you asked to create a folder if it doesn't exist, say yes.

2. A window will pop up that lets you select the kind of project you like to build. For the correct Project Setting please have a look at the settings for your corresponding platform in the links below, but making it short, in this first configuration you tell CMake if you would like to export the files as a project for Visual Studio, Eclipse or some other type of project, and the compiler you will use to compile the executable. In this step you would select the cross-compiler that you would use if you are compiling for a specific platform different from the one where you are compiling (for example, compiling for a Raspberry Pi or a PLC from a Windows or a Linux computer).

3. After selecting the type of project and compiler, the CMake main window shows a list of red marked options. The color red doesn't mean that something is wrong, but that these rows were affected by the last configuration, so they need to be checked. These options allow you to configure your FORTE build. The minimal configuration you have to perform is to select the architecture you like to build for using the FORTE_ARCHITECTURE option and the modules with the function block libraries you like to enable (a basic configuration uses FORTE_MODULE_CONVERT, FORTE_MODULE_IEC61131 and FORTE_MODULE_UTILS). The modules that you enable, represent the group of Function Blocks that the your FORTE executable will contain. You should also keep the option FORTE_SUPPORT_MONITORING (which is found when ticking the Advanced box)enabled for Debugging and FB-Testing. Another important option is the CMAKE_BUILD_TYPE, which determines if your building a Debug or Release version. Write the according word to the option to select.

4. After you change some options in CMake, you must press again Configure, until no more red rows appear. Then, press the Generate button to create the project files in OUTPUT_FOLDER.

### Compiling

The last part is compiling the generated project. This depend of the project output you selected in the previous step. Check the links below to see more details of your case.

For the development with FORTE the understanding of the general file structure is helpful. Therefore the essential parts as well as the Makefiles which are important for the configuration and compilation of FORTE are listed in the following:

- src/modules: this folder contains the source code (cpp, h) of all Function Blocks available for FORTE
- bin/[YOUR_SYSTEM]/src: contains the FORTE executable after compilation
- bin/[YOUR_SYSTEM]/src_gen: contains the object files generated during compilation

### Build external Modules

Before showing how to compile, this part of the documentation shows how to add your own function blocks to FORTE.

When you create and export your own types, you need to add them to FORTE's compilation. In this case, we'll show as an example, how to add three function block called BasicTest, CompositeTest, and ServiceTest. The module's name will be EXAMPLE_TEST. Follow the directions below:

1. Create a folder in your system that will hold all future Modules. Let's called forteModules
2. Create a folder inside of it called EXAMPLE_TEST (the name doesn't need to be exactly the name of the module, but this helps organizing) and access it.
3. Put in the subfolder all six files (a .cpp and .h file for each FB).
4. Create a file called CMakeLists.txt (this cannot be different).
5. Inside write:
   forte_add_module(EXAMPLE_TEST "Example test module") forte_add_sourcefile_hcpp(BasicTest) forte_add_sourcefile_hcpp(CompositeTest) forte_add_sourcefile_hcpp(ServiceTest)
   and save. The first parameter of forte_add_module is the name of the module; the second is a commentar. The forte_add_sourcefile_hcpp command tells CMake which .cpp and .h files to compile. You can use forte_add_subdirectory to include subdirectories which again have their own CMakeLists.txt file
6. In CMake, there's a variable called FORTE_EXTERNAL_MODULES_DIRECTORY. Set this to the forteModules folder.
7. When pressing Configute in CMake, a variable called FORTE_MODULE_EXAMPLE_TEST will appear. Checking the box will include the module for compilation.
8. After setting all the desired variables, do the same as before: Generate and then compile

## FORTE for Windows and Unix-based systems

You can use different development Environments, whereas the C++ Compiler you can use to build FORTE not only depends on this environment but also on your operating system. For compiling FORTE under Windows you can use either Visual Studio (Express or full edition) or Eclipse. When using Eclipse for development and debugging under Windows you will need to use a Posix emulation environment like MinGW or Cygwin.

- Compilers

  - Setting up MinGW (Windows)
  - Setting up Cygwin (Windows)
  - In Unix-like systems (Linux, raspberry pi, etc) you need to install binutils, gcc, gdb, make and cmake. To compile forte, you do
    $ cd FORTE_FOLDER_ROOT/bin/[YOUR_SYSTEM] $ make

- IDE

  - Using MS Visual Studio Express (The compiler is already installed)
  - Using Eclipse

## Build FORTE for other platforms

- Setting up FORTE for RaspberryPi
- Setting up FORTE for RaspberryPi SPS
- Setting up FORTE for Wago PFCs SPS
- Setting up FORTE for Lego Mindstorms EV3
- Setting up FORTE for Lego Mindstorms

# Where to go from here?

Now that you installed the required tools, it's time to start using them. Take a look at the following page:

Step by step tutorial

If you want to go back to the Start Here page, we leave you here a fast access

Start Here page

Or Go to top