Compiling and linking

This section explains how to compile Visualization Server applications and the demos supplied with the libraries and covers the following topics:

Visualization Server and Views build system

Visualization Server and Views use the CMake cross-platform build generator tool as the primary build system. CMake generates the files needed by your build tool (GNU make, Visual Studio, and so forth) for building your applications with Views and Visualization Server.

Environment variables

The environment variable ILSHOME should be set to the location of the Visualization Server distribution.

The environment variable ILVHOME should be set to the location of the Views distribution.

Visualization Server compilation flag

Refer to the following table for the Visualization Server compilation flags:

IL_DLL and ILSDLL

Includes code specifically for shared build. Both should be defined in case of using DLL Visualization Server libraries on Windows (dll_mda).

ILS_MFC

Server can be used with the Microsoft Foundation Classes (MFC) by defining the preprocessor symbol ILS_MFC.

ILS_USE_THREADS

Use this flag to indicate a multithreaded compilation.

Compiler options for multithreaded applications

The following table shows the compiler or compiler/linker options that must be used to build a multithreaded application. Failure to use these options results in undefined behavior at runtime.

Port Compilation Link Macros1

IBM AIX

 

 

_THREAD_SAFE

Linux SLES,

Linux Ubuntu,

Linux RHEL

-pthread

-pthread

-lpthread

 

Windows Visual Studio

/MD or /MT

 

_MD or _MT

1 These macros are used to detect a multithreaded compilation. Do not set them when compiling in single-thread mode. All other platforms use the flag ILS_USE_THREADS to indicate a multithreaded compilation.

Compiling and linking with Microsoft Visual C++

This section discusses the requirements for compiling your source files with Microsoft Visual C++.

Most of the binaries rely on the data files provided in the Visualization Server library, and you need to copy these files as well as the .EXE file when installing a program on another platform. You may also place these files in the resources bound to the executable.

The libraries are standard C++ libraries and are in the following formats:

  • dll_mda: dynamic multi-threaded Visualization Server release libraries with dynamic runtime libraries

  • dll_mdad: dynamic multi-threaded Visualization Server debug libraries with dynamic runtime libraries

  • stat_mda: static multi-threaded Visualization Server release libraries with dynamic runtime libraries

  • stat_mdad: static multi-threaded Visualization Server debug libraries with dynamic runtime libraries

  • stat_mta: static multi-threaded Visualization Server release libraries with static runtime libraries

  • stat_mtad: static multi-threaded Visualization Server debug libraries with static runtime libraries

The following table lists the compilation flags to use:

Table 1   Compilation flags for Microsoft Visual C++

dll_mda

/DIL_DLL /ILSDLL /MD /EHsc /GR /D_CRT_SECURE_NO_DEPRECATE

dll_mdad

/DIL_DLL /ILSDLL /MDd /EHsc /GR /D_CRT_SECURE_NO_DEPRECATE

stat_mda

/MD /EHsc /GR /D_CRT_SECURE_NO_DEPRECATE

stat_mdad

/MDd /EHsc /GR /D_CRT_SECURE_NO_DEPRECATE

stat_mta

/MT /EHsc /GR /D_CRT_SECURE_NO_DEPRECATE

stat_mtad

/MTd /EHsc /GR /D_CRT_SECURE_NO_DEPRECATE

Note

If you are using release Visualization Server libraries when compiling files in debug mode, you must use the non-debug version of the runtime libraries and undefine the macro DEBUG. This is because Visualization Server uses non-debug runtime libraries for release libraries. However, if you are using the separately distributed debug Visualization Server libraries, you must use the debug versions of the runtime libraries.

Compiling with GCC

Visualization Server libraries are standard C++ libraries and are provided in the following formats:

  • shared: dynamic Visualization Server release libraries

  • sharedd: dynamic Visualization Server debug libraries

  • static_pic: static Visualization Server release libraries

  • static_picd: static Visualization Server debug libraries

Compiling and linking applications using MvTCP

When you are using the MvTCP port of the Generic Protocol, you must link your client (component) application with one of the following libraries:

  • mvtcp

  • mvvwtcp (Linux/Unix platforms only) when linking a process using Views

Your server application should be linked with either of the following libraries:

  • svtcp

  • svvwtcp (Linux/Unix platforms only) when linking a process using Views

When using this communication layer in a Java application, you must use the following jar file located in $ILSHOME/lib/java:

  • mvtcp.jar

Using Visualization Server with MFC

Visualization Server can be used with the Microsoft Foundation Classes (MFC) by defining the preprocessor symbol ILS_MFC. This symbol instructs Visualization Server to include <afx.h> instead of <windows.h> in the Visualization Server include files.

Compiler warnings suppression

The Visualization Server library relies extensively on initializing certain classes by passing the constructor 'this' in the constructor initializer. This results in a harmless warning (number 4355). By default, in Visualization Server these warnings have been suppressed. Warning number 4786 is also suppressed. These warnings are due to class names being truncated to 255 characters in the debug information. Long identifier names are created by nested template instantiations, this warning only occurs when compiling in debug mode and does not affect the behavior of the program.

All warnings can be enabled by adding:

/D ILS_MSVC_ALL_COMPILER_WARNINGS

Compiling with Visualization Server libraries

The following Windows libraries are required when linking an application built with Visualization Server:

wsock32.lib

Ws2_32.lib

kernel32.lib

user32.lib

gdi32.lib

comdlg32.lib

advapi32.lib

shell32.lib

When linking with Views it is also necessary to add the following system libraries:

 imm32.lib

Visualization Server and Views libraries have a system dependency on the system thread library. On Linux, make sure to link with the -lpthread option to satisfy this dependency.

Compiling and linking with CMake

This section describes how Views and Visualization Server could be included to your CMake build system. You can use find_package() for views, IFC, iljs, studio, and server components.

CMake command line options:

  • -DCMAKE_GENERATOR_PLATFORM — Specifies system bitness. Possible values are x64, x86 (Unix only), or Win32 (Windows only).

  • -DCMAKE_PREFIX_PATH — Point this to the CMake folder in the Visualization Server install directory. Can be set to %ILSHOME%/cmake on Windows or $ILSHOME/cmake on Unix. Add the path to the Views installation directory if you want to use Views libraries (%ILVHOME%/cmake on Windows or $ILVHOME/cmake on Unix).

  • -DVISU_SYSTEM_NAME — Configures the Visualization Server system. Set it according to which Visualization Server binaries you wish to use. For example, set it to x64_.net2019_16.0 for Windows or x64_rhel7.2_5.3 for Unix. A list of the installed versions can be found in the <Visualization Server install path>/lib directory. All supported OS and compiler combinations are also listed in the Views Supported Platform Guide.

  • -DVISU_LINK_MODE — Configures the Visualization Server library link mode. Set it according to which Visualization Server binaries format you wish to use. For example, set it to dll_mda, stat_mda, or stat_mta for Windows; and shared or static_pic for Unix. To use separately distributed debug libraries, add a "d" suffix to link mode: dll_mdad, stat_mdad, stat_mtad, sharedd, static_picd.

Example CMake file

A CMakeLists.txt file looks something like the following:

cmake_minimum_required(VERSION 3.5)

project(server_app VERSION 7.0 LANGUAGES CXX)

 

find_package(iljs REQUIRED)

find_package(IFC REQUIRED)

find_package(server REQUIRED)

find_package(Threads REQUIRED)

 

add_executable(${PROJECT_NAME}

main.cpp

)

target_link_libraries(${PROJECT_NAME} PRIVATE

mvserver

server

ilxml

ilog

)

 

if (WIN32)

target_compile_options(${PROJECT_NAME} PRIVATE

/DIL_DLL /ILSDLL /MD /EHsc /GR /D_CRT_SECURE_NO_DEPRECATE /DILS_USE_THREADS)

else()

target_compile_options(${PROJECT_NAME} PRIVATE -DILS_USE_THREADS)

endif()

Let's assume your source directory contains main.cpp and CMakeLists.txt. From your build directory run CMake with a relative path to your project CMakeLists.txt file and an absolute path to <Visualization Server install path>/cmake.

On Windows:

cmake ../ -G "Visual Studio 16 2019" -DCMAKE_GENERATOR_PLATFORM=x64

-DCMAKE_PREFIX_PATH="<Visualization Server install path> /cmake"

-DVISU_SYSTEM_NAME="x64_.net2019_16.0" -DVISU_LINK_MODE=dll_mda

On Unix:

cmake ../ -G "Unix Makefiles" -DCMAKE_PREFIX_PATH="<Visualization Server install path>/cmake"

-DVISU_SYSTEM_NAME="x64_rhel7.2_5.3"

-DVISU_LINK_MODE=shared -DCMAKE_BUILD_TYPE=Release

make

Note

If CMake reports errors trying to find the Visualization Server packages, double check your paths and use -DCMAKE_FIND_DEBUG_MODE=ON to gather more information on why CMake is not able to find the Visualization Server dependent packages.

Compiling Visualization Server demos

To compile the demos supplied with the libraries, use the CMake build system. CMakeLists.txt files generate makefiles/solutions.

Please note:

  • Some Visualization Server demos use Views libraries. To build these demos add <Views install path>/cmake path to CMAKE_PREFIX_PATH.

  • The component part of Visualization Server also exists in Java and can be used to develop Java clients connected to a Visualization Server application. To build Java demos, please set the JAVAHOME and JVIEWSHOME environment variables.

  • To build C# demo, add -DBUILD_SERVER_DOTNET=true to the CMake command.

  • Thin client of Network7 demo requires TomCat. To compile it please set the CATALINA_HOME environment variable.

For example, to generate the demos solution for MS Visual Studio run CMake from your build directory (../<Server install path> in this example) with an absolute path to <Server install path>/cmake and <Views install path>/cmake as follows:

set JAVAHOME=<path to Java>

set JVIEWSHOME=<JViews install path>

set ILSHOME=<Visualization Server install path>

set ILVHOME=<Views install path>

cmake ../<Server install path> -G "Visual Studio 16 2019"

-DCMAKE_GENERATOR_PLATFORM=x64 -DCMAKE_PREFIX_PATH="%ILSHOME%/cmake;%ILVHOME%/cmake "

-DVISU_SYSTEM_NAME="x64_.net2019_16.0" -DVISU_LINK_MODE=dll_mda

For example, to generate samples makefile on Unix run CMake with an absolute path to <Server install path>/cmake and <Views install path>/cmake:

export JAVAHOME=<path to Java>

export JVIEWSHOME=<JViews install path>

export ILSHOME=<Server install path>

export ILVHOME=<Views install path>

cmake ../<Server install path> -G "Unix Makefiles" -DCMAKE_PREFIX_PATH="$ILSHOME/cmake;$ILVHOME/cmake"

-DVISU_SYSTEM_NAME=" x64_ubuntu20.04_9.3" -DVISU_LINK_MODE=shared

-DCMAKE_BUILD_TYPE=Release

Running demos

After compiling, you can find the server demo executables and running scripts under the <out> subfolder of your build directory.

To run the samples, make sure to set your ILSHOME, ILVHOME, JVIEWS, and JAVAHOME environment variables and any paths to the shared libraries your product is built to use.

Please refer to <Server install path>/demo/demos.html for details.