Compiling and linking
This section explains how to compile the examples supplied with the libraries and covers the following topics:
Views build system
Views uses 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. CMake version 3.14 or above is required.
Compiling and linking with CMake
This section describes how Views could be integrated into a CMake-based project. You can use find_package() for views, IFC, iljs, and studio components.
Using find_package(views REQUIRED) sets the variables shown in the following table:
CMake variables
VIEWS_CORE_LIBRARIES
List of core libraries:
views;winviews for windows
views;xviews for unix (for Motif you must set mviews manually and use static build)
VIEWS_MAIN_LIBRARIES
Optional ilvmain lib for windows (declares WinMain())
VIEWS_LF_LIBRARIES
List of look-and-feel libraries installed with Views
VIEWS_COMPILE_OPTIONS
VIEWS_LINK_OPTIONS
Link flags
Views Components
The Views libraries are grouped into components. The find_package(views REQUIRED) command sets a view_<component>_FOUND CMake variable to TRUE for each installed component. The possible values are: appframe, charts, foundation, gadgets, gantt, graph_layout, grapher, manager, prototype. Note that some components might not be installed depending on which features of Views were selected during the installation.
CMake command line options
*G — specifies the generator.
*DCMAKE_GENERATOR_PLATFORM — Specifies system bitness. Possible values are x64, x86 (Unix only), or Win32 (Windows only).
*DCMAKE_PREFIX_PATH — Defines lookup path for CMake packages. Point this to the CMake folder in the Views install directory. Files that are shipped with Views use the correct directory and do not need to be modified. For custom CMake files, set the path to %ILVHOME%/cmake on Windows or $ILVHOME/cmake on Unix.
*DCMAKE_MODULE_PATH — Defines lookup path for CMake Find-modules. Point this to the CMake folder in the Views install directory. Files that are shipped with Views use the correct directory and do not need to be modified. For custom CMake files, set the path to %ILVHOME%/cmake on Windows or $ILVHOME/cmake on Unix.
*DVISU_SYSTEM_NAME — Configures the Views system. Set it according to which Views binaries you wish to use. Possible values are 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 <Views install path>/lib directory. All supported OS and compiler combinations are also listed in the Views Supported Platform Guide.
*DVISU_LINK_MODE — Configures the Views library link mode. Set it according to which Views binaries format you wish to use. Possible values are dll_mda, stat_mda, or stat_mta for Windows; and shared or static_pic for Unix. To use separately distributed debug Views libraries, add a "d" suffix to link mode: dll_mdad, stat_mdad, stat_mtad, sharedd, static_picd.
Views compilation flag
Refer to the following table for the Views compilation flags:
Views compilation flags
IL_DLL
Includes code specifically for shared builds. Should be defined in case of using DLL Views libraries on Windows (dll_mda).
Example CMake
cmake_minimum_required(VERSION 3.14)
project(views_app VERSION 7.0 LANGUAGES CXX)
 
find_package(iljs REQUIRED)
find_package(IFC REQUIRED)
find_package(views REQUIRED)
find_package(Threads REQUIRED)
 
add_executable(${PROJECT_NAME}
   main.cpp
)
target_link_libraries(${PROJECT_NAME} PRIVATE
   ${VIEWS_CORE_LIBRARIES}
   ${VIEWS_MAIN_LIBRARIES}
   ${VIEWS_LF_LIBRARIES}
   ilvgadgt
)
target_compile_options(${PROJECT_NAME} PRIVATE ${VIEWS_COMPILE_OPTIONS})
target_link_options(${PROJECT_NAME} PRIVATE ${VIEWS_LINK_OPTIONS})
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 <Views install path>/cmake.
On Windows:
cmake ../ -G "Visual Studio 16 2019" -DCMAKE_GENERATOR_PLATFORM=x64
-DCMAKE_PREFIX_PATH="<Views install path> /cmake"
-DVISU_SYSTEM_NAME="x64_.net2019_16.0" -DVISU_LINK_MODE=dll_mda
On Unix:
cmake ../ -G "Unix Makefiles" -DCMAKE_PREFIX_PATH="<Views 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 Views 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 Views dependent packages.
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 Views 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 packing alignment for structure and union members is 8 bytes.
The libraries are standard C++ libraries and are in the following formats:
*dll_mda: dynamic multi-threaded Views release libraries with dynamic runtime libraries
*dll_mdad: dynamic multi-threaded Views debug libraries with dynamic runtime libraries
*stat_mda: static multi-threaded Views release libraries with dynamic runtime libraries
*stat_mdad: static multi-threaded Views debug libraries with dynamic runtime libraries
*stat_mta: static multi-threaded Views release libraries with static runtime libraries
*stat_mtad: static multi-threaded Views debug libraries with static runtime libraries
The following table lists the compilation flags to use:
Compilation flags for Microsoft Visual C++
dll_mda
/DIL_DLL /MD /EHsc /GR /D_CRT_SECURE_NO_DEPRECATE
dll_mdad
/DIL_DLL /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 Views 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 Views uses non-debug runtime libraries for release libraries. However, if you are using the separately distributed debug Views libraries, you must use the debug versions of the runtime libraries.
Compiling with GCC
Views libraries are standard C++ libraries and are provided in the following formats:
*shared: dynamic Views release libraries
*sharedd: dynamic Views debug libraries
*static_pic: static Views release libraries
*static_picd: static Views debug libraries
The following table lists the compilation flags to use:
Compilation flags for GCC
shared
 
sharedd
 
static_pic
 
static_picd
 
Compilation options for GCC
When creating a CMake based project, it’s possible to specify extra compiler options for a target through the target_compiler_options CMake function. Some possible values for GCC are -Wall and -Wextra.
target_compile_options(${PROJECT_NAME} PRIVATE ${VIEWS_COMPILE_OPTIONS}-Wall -Wextra)
Typically, the options are applied only to client code and not to Views targets’ headers. In order to apply compiler options to external headers, add the following line to the project’s CMake file.
set_target_properties(${PROJECT_NAME} PROPERTIES NO_SYSTEM_FROM_IMPORTED ON)
Compiling samples
You can use CMake to configure and build the examples provided together with the libraries. The examples, together with their CMakeLists.txt file, are in the <Views install path>/samples directory.
Note: You need to set the ILDHOME environment variable to the DB Link installation path.
On Windows or Unix, create a directory for building and configuring the samples. We recommend creating this folder outside the Views install path. We refer to this directory as <Views samples>.
On Windows, running the following command from within your build directory generates an MS Visual Studio solution:
cd <Views samples>
cmake %ILVHOME%/samples -G "Visual Studio 16 2019"
-DCMAKE_GENERATOR_PLATFORM=x64
-DVISU_SYSTEM_NAME="x64_.net2019_16.0" -DVISU_LINK_MODE=dll_mda
The samples can now be built from within Visual Studio.
On Unix, running the following command from within your build directory generates a makefile project:
cd <Views samples>
cmake $ILVHOME/samples -G "Unix Makefiles"
-DVISU_SYSTEM_NAME="x64_rhel7.2_5.3" -DVISU_LINK_MODE=shared
-DCMAKE_BUILD_TYPE=Release
The samples can now be built using the make command.
Please note:
*The samples are grouped by topic into several directories (appframe, gadgets, dataccess, and so on). By default, CMake attempts to configure all samples directories. However, you can choose to configure only a selection of these directories by adding -DBUILD_<SAMPLE_DIR>_SAMPLES=ON for each selected directory. Possible values for <SAMPLE_DIR> are: APPFRAME, CHARTS, FOUNDATION, GADGETS, GANTT, GRAPHER, LAYOUT, MANAGER, PROTOS, STUDIO, CSS, TUTORIALS, MAPS, DATACCESS.
*A samples directory is configured only if it is enabled in the configuration (with -DBUILD_<SAMPLE_DIR>_SAMPLES) and the needed components have been found by the find_package(views REQUIRED) command (see the Views Components section).
Compiling Views Studio examples
To compile the Views Studio samples supplied with Views, use CMake with the provided /studio/CMakeLists.txt file. Please use the same CMake options as for compiling Views samples.
Compiling Views tools
To compile the tools supplied with Views, use CMake with the provided /tools/CMakeLists.txt file. Please use the same CMake options as for compiling Views samples.
Running samples
To run the samples, make sure to set your ILVHOME environment variable and any paths to the shared libraries your product is built to use.
For example, on Linux using a BASH style shell:
export ILVHOME=<Views install path>
export LD_LIBRARY_PATH=$ILVHOME/lib/x64_rhel8.0_8.2/shared:$ILVHOME
/studio/x64_rhel8.0_8.2/shared:$ILDHOME/lib/x64_rhel8.0_8.2/shared.
cd <Views samples>/out
./IlvButton_css_sample
For example, on Windows:
set ILVHOME="C:\Perforce\Views\7.0"
set PATH="%ILVHOME%\lib\x64_.net2019_16.0\dll_mda;%ILVHOME%
\studio\x64_.net2019_16.0\dll_mda;%ILDHOME%\lib\x64_.net2019_16.0\dll_mda;%PATH%"
cd <Views samples>\out
IlvButton_css_sample.exe
Links to Views statically
Due to licensing reasons, it is not possible to statically link to Modest library. Modest must be linked dynamically. When using CMake and find_package(views) as explained in previous paragraphs, the dynamic linking to Modest library is already handled. It is only necessary to provide the Modest shared library when running the resulting application.
Published date: 05/24/2022
Last modified date: 02/24/2022