2.2.2. Linking Code with the Mesh Import API

In order to build a customized import utility routine, it must be linked with several libraries. These libraries are located in <CFXROOT>/lib/<os>/:

  • libmeshimport.lib (on Windows), or libmeshimport.a (on Linux)

  • libratlas_api.lib (on Windows), or libratlas_api.a (on Linux)

  • libratlas.lib (on Windows), or libratlas.a (on Linux)

  • libpgtapi.lib (on Windows), or libpgtapi.a (on Linux)

  • libunits.lib (on Windows), or libunits.a (on Linux)

  • libcclapilt.lib (on Windows), or libcclapilt.a (on Linux)

  • libio.lib (on Windows), or libio.a (on Linux)

2.2.2.1. Linking a Customized Mesh Import Executable on a Windows Platform

2.2.2.1.1. Linking a Customized C Mesh Import Executable on a Windows Platform

You can build the executables on Windows systems. An example command line follows:

cl /MD /I "C:\Program Files\Ansys Inc\v242\CFX\include" ImportTemplate.c /link /libpath:"C:\Program Files\Ansys Inc\v242\CFX\lib\winnt-amd64" libcclapilt.lib libio.lib libmeshimport.lib libunits.lib libpgtapi.lib libratlas_api.lib libratlas.lib

2.2.2.1.2. Linking a Customized Fortran Mesh Import Executable on a Windows Platform

You can write the import program in Fortran and then compile and link it. An example command line follows:

ifort /MD /I "C:\Program Files\Ansys Inc\v242\CFX\include" /threads /iface:mixed_str_len_arg ImportTemplate.F /exe:ImportTemplate.exe /libs:dll /link /libpath:"C:\Program Files\Ansys Inc\v242\CFX\lib\winnt-amd64" libcclapilt.lib libio.lib libmeshimport.lib libunits.lib libpgtapi.lib libratlas_api.lib libratlas.lib

The supported compilers are listed in Compiler Requirements for All Windows Versions in the Ansys, Inc. Installation Guides.

2.2.2.2. Linking a Customized Mesh Import Executable on a Linux Platform

2.2.2.2.1. Linking a Customized C Mesh Import Executable on a Linux Platform

On most Linux systems you should be able to build the executable with the command:

gcc myimport.c -I<CFXROOT>/include/ -o myimport.exe -L<CFXROOT>/lib/<OSDIR> \
  -lmeshimport -lratlas_api -lratlas -lpgtapi -lunits -lcclapilt -lio \
  -lm -lc -fopenmp

where <CFXROOT> is the directory in which CFX is installed and <OSDIR> is a directory name corresponding to the architecture of the machine.

Here, -lmeshimport, -lratlas_api, -lratlas, -lpgtapi, -lunits, -lcclapilt, and -lio indicate the libraries mentioned above, while -lm, -lc and -fopenmp are system libraries.

In this example, your own import program is named myimport.c and the executable file will be called myimport.exe. You should ensure that the libraries to which you are linking (which are in the path given after -L) appear on the command line after the source file (or object file if you are just linking to an existing object).

The compiler flags and required libraries may vary, depending on the compiler and the custom program.

The supported compilers are listed in Compiler Requirements for All Linux Versions in the Ansys, Inc. Installation Guides.

2.2.2.2.2. Linking a Customized Fortran Mesh Import Executable on a Linux Platform

The following is an example of how to build the executable on Linux, when the source code for the executable is written in Fortran:

ifort myimport.F -L<CFXROOT>/lib/linux-amd64 -lmeshimport -lratlas_api -lratlas \
  -lpgtapi -lunits -lcclapilt -lio -lm -qopenmp -o myimport.exe

The supported compilers are listed in Compiler Requirements for All Linux Versions in the Ansys, Inc. Installation Guides.