Compile Coupling Interface Code to an Executable

You can compile simple user-written code into a stand-alone executable to work with the coupling interface.

  1. Download and install a third-party compiler to compile C++ code.


    Note: To create a simple executable a third-party compiler is required to compile C++ code as EDEM does not support any specific compiler. However, Microsoft Visual Studio is commonly used and Visual Studio Community 2017 is shown in this example. When installing Visual Studio, it is important to install the C++ tool set (Universal Windows Platform development and Desktop development with c++). Depending on the installation, these may be installed by default or additional options in the installer.
  2. Place the .cpp files that you have written in a working directory.
    For example, C:\code\Dynamics_Coupling. In this instance, a Free_Body.cpp file is used which can be found on the EDEM forum.
  3. Start Visual Studio.


  4. To create a new project (Win32 Console Application Visual C++), go to File > New > Project.


  5. Set name:freebody.
  6. Set the location to: C:\code\Dynamics Coupling and then click OK.
  7. Select Application Settings and then do the following:


    1. Select Console Application.
    2. Select Empty Project.
    3. Click Finish.
  8. Add the file Free_Body.cpp to the project.
    1. Copy this file to the following location: C:\code\Dynamics_Coupling\freebody.
    2. Right-click Source Files > Add > Existing Item > Free_Body.cpp.


  9. Go to Project > Properties and set the following:
    1. Configuration to All Configurations.
    2. Platform to All Platforms.
    3. Select Configuration Properties > C/C++ > General.
      1. Select Additional Include Directories and then click Edit.


      2. Add the following paths then click OK.

        C:\Program Files\Altair\<version number>\EDEM\bin\src\Api\Coupling

        C:\Program Files\Altair\<version number>\EDEM\bin\src\Api\Core

  10. Select Configuration Properties > Linker > General > Library Directories > Edit.


    1. Include the following:
      C:\Program Files\Altair\<version number>\EDEM\lib\
  11. Select Configuration Properties > Linker > Input > Additional Dependencies > Edit.
    1. Add EDEMCouplingClient4.lib.


    2. Click OK.
  12. Go to Project > Properties > Configuration Manager, and set the following:
    1. Active solution configuration to Release or Debug.

      Active solution platform to x64 and then click Close.

      Build the solution (Build > Build Solution) to create the .exe file.

    Note: To compile the EDEM-FLUENT coupling, see Coupling EDEM with ANSYS Fluent’ E-Learning on the Altair website. To access the E-Learning Login, go to eLearning Courses > EDEM > Coupling EDEM with ANSYS Fluent.

Compile Coupling Interface Applications on Linux

To compile coupling interface applications for use with EDEM running on Linux, it is recommended to use the GNU Compiler Collection, more referred to as GCC.

To compile with GCC:
If you have the source code <source_code>.cpp file in your working directory, use the following two commands to compile the source code:
g++ -std=c++11 -c -g -DDEMLINUX -I ~/<version number>/altair/EDEM/src/Api/Core -I ~/<version number>/altair/EDEM/src/Api/Coupling/ -MMD -MP -MF <output>.o.d -o <output>.o <source_code>.cpp
followed by:
g++ -std=c++11 -o <compiled> <output>.o -L ~/<version number>/altair/EDEM/lib -lEDEMCouplingClient4 -L ~/<version number>/altair/EDEM/bin -lQt5Core -lQt5Network

where <source_code>, <output>, and <compiled> are file names of your choice. Replace EDEM_XXXX with the version of EDEM you have installed, replace libEDEMCouplingClientXXXXX with the coupling client library version associated with it, and the libQtXXXX entries use the Qt version associated with that EDEM release.

The following table lists the coupling client library and libQt versions:

EDEM version Coupling Client Library version libQt version
2022 libEDEMCouplingClient4.so 5.12
2021
2020
2019 5.6
2018
2017.2 libEDEMCouplingClientV3_2_0.so
2017.1 libEDEMCouplingClientV3_1_0.so
2017.0 libEDEMCouplingClientV3_0_0.so