{"id":144,"date":"2023-02-20T14:31:11","date_gmt":"2023-02-20T14:31:11","guid":{"rendered":"https:\/\/oiv10wp.athena-dev.net\/?page_id=144"},"modified":"2023-09-19T07:27:40","modified_gmt":"2023-09-19T07:27:40","slug":"howto-building-examples","status":"publish","type":"page","link":"https:\/\/developer.openinventor.com\/index.php\/general-documentation\/howto-building-examples\/","title":{"rendered":"How to build examples"},"content":{"rendered":"<div class=\"page-content\">\n<p><a href=\"#Introduction\">Introduction<\/a><br \/>\n<a href=\"#PreRequisites\">Prerequisites<\/a><br \/><a href=\"#EnvironmentVariables\">Environment variables<\/a><\/p>\n<p>Project generation using CMake GUI<\/p>\n<ul>\n<li><a href=\"#ProjectGenerationWindows\">Windows<\/a><\/li>\n<li><a href=\"#ProjectGenerationLinux\">Linux<\/a><\/li>\n<\/ul>\n<p><a href=\"#ProjectGenerationCommandLine\">Project generation using CMake in command line<\/a><br \/>\n<a href=\"#CreatingModifyingProject\">Creating\/Modifying project<\/a><\/p>\n<hr>\n<h2><a name=\"Introduction\"><\/a>Introduction<\/h2>\n<p>All example projects files for Linux must be generated on the host computer by <strong>CMake<\/strong>. For MS Visual Studio the project files are delivered with the package.<\/p>\n<p><strong>CMake <\/strong>is used to control the software compilation process using simple platform and compiler-independent configuration files (see CMakelists.txt in each example directory).<br \/>\nMost rules for specific platforms and architecture are built-in in <strong>CMake <\/strong>modules, but all of them can be specifically configured depending on needs. All Open Inventor example-specific rules can be found in the installed&nbsp;<strong>CMake<\/strong>&nbsp;directory.<\/p>\n<p><strong>CMake <\/strong>generates native make Makefiles or Visual Studio solutions that can be used in the compiler environment of your choice.<\/p>\n<p>For details information on <strong>CMake<\/strong>,&nbsp;please see the <a href=\"http:\/\/www.cmake.org\/\">official CMake website.<\/a><\/p>\n<h2><a name=\"PreRequisites\"><\/a>Prerequisites<\/h2>\n<p>The following packages must be installed before project files can be generated for the examples.<\/p>\n<ul>\n<li><strong>Open Inventor Toolkit<\/strong><br \/>\nNote: You must install the version that matches the Open Inventor Demos package you are using.<\/li>\n<li><strong>CMake <\/strong>(see <a href=\"https:\/\/developer.openinventor.com\/index.php\/general-documentation\/system-requirements\">System Requirements<\/a>&nbsp;<strong>Overview<\/strong>&nbsp;for more details about&nbsp;<strong>CMake<\/strong> version).<br \/>\nDownload it for your specific platform on the CMake Website (<a href=\"https:\/\/cmake.org\/download\/\">main version 3 and at least 3.10.2<\/a>)<\/li>\n<li><strong>Qt : Optional for Windows and Linux.<\/strong><br \/>\nIf you want Qt-based examples to be built you must install the Qt package.<br \/>\nInstallers can be found on the official Qt website <a href=\"http:\/\/www.qt.io\/download\/\">http:\/\/www.qt.io\/download\/<\/a>.<\/li>\n<li><strong>CUDA\/OpenCL (Optional)<\/strong><br \/>\nIf you want CUDA and\/or OpenCL-based examples to be built, you must install the package for your specific GPU.<br \/>\nInstallers can be found on the official website of your GPU providers.<\/li>\n<li>On Windows 10 you need to have <strong>Windows 10 SDK 10.0.16299.0<\/strong> installed to be able to use directly the .vcxproj files provided in the installer. If it is not installed, you will have an error message saying \"<i>error MSB8036: The Windows SDK version 10.0.16299.0 was not found. Install the required version of Windows SDK or change the SDK version in the project property pages or by right-clicking the solution and selecting \"Retarget solution<\/i>\". To fix the issue simply run Visual Studio 2017 installer (C:\\Program Files (x86)\\Microsoft Visual Studio\\Installer\\vs_installer.exe if default installation), click on modify and select 16299 SDK under SDK\/framework in individual components tab of the installer<\/li>\n<\/ul>\n<hr>\n<h2><a name=\"EnvironmentVariables\"><\/a>Environment variables<\/h2>\n<p>Before generating and building examples example projects, following environment variables must be properly set:<\/p>\n<ul>\n<li><strong>OIVHOME <\/strong>must be set to the Open Inventor home installation folder (e.g. C:\\Open Inventor\\10.3.0 C++ Visual2017&nbsp;x64 for example).<\/li>\n<li><strong>OIVARCH <\/strong>must be set to the Open Inventor version (e.g. arch-Linux-x86_64-gcc48-release,&nbsp;arch-Windows-x86_64-msvc14-Release and so on).<\/li>\n<li><strong>LD_LIBRARY_PATH<\/strong> :<strong> Only for Linux<\/strong>. This variable must be set to $OIVHOME\/$OIVARCH\/lib<\/li>\n<\/ul>\n<p>Here is how to define these variables depending on the Operating System you are running<\/p>\n<ol>\n<li><u>On linux (tcsh) :<\/u>\n<ol>\n<li><em>setenv OIVHOME&nbsp;&lt;path to Open Inventor&gt;<\/em><\/li>\n<li><em>setenv OIVARCH arch-Linux-x86_64-gcc48-release<\/em><\/li>\n<li><em>setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH:$OIVHOME\/$OIVARCH\/lib<\/em><\/li>\n<li><em>setenv PATH $PATH:&lt;QT installation dir&gt;\/bin<\/em><\/li>\n<\/ol>\n<\/li>\n<li><u>On Windows (batch command line) :<\/u>\n<ol>\n<li>set&nbsp;<em>OIVHOME=&lt;path to Open Inventor&gt;<\/em><\/li>\n<li><em>set&nbsp;OIVARCH=arch-Windows-x86_64-msvc14-Release<\/em><\/li>\n<li><em>set PATH=%PATH%;&lt;QT installation dir&gt;\/bin<\/em><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<hr>\n<h2><a id=\"ProjectGenerationWindows\" name=\"ProjectGenerationWindows\"><\/a>Project generation using CMake GUI - Windows<\/h2>\n<p>Below the steps to use&nbsp;<strong>CMake GUI<\/strong>&nbsp;tool provided by the <strong>CMake <\/strong>installer.<\/p>\n<ul>\n<li>Set<a href=\"#EnvironmentVariables\"> environment variables<\/a>.<\/li>\n<li>Run cmake-gui<\/li>\n<li>Setup the Open Inventor examples input directory&nbsp;\"<strong>Where is the source code<\/strong>\"&nbsp;(e.g. E:\/OIVofficial\/OpenInventorC++980-Windows-Visual2015-x86_64\/examples in picture above).<\/li>\n<li>Setup the output directory \"<strong>Where to build the binaries<\/strong>\" where all generated files will be stored (e.g. E:\/build\/tests&nbsp; in picture above ).<\/li>\n<li>Press the&nbsp;<strong>Configure<\/strong>&nbsp;button.<\/li>\n<li><strong>CMake <\/strong>allows you to select the compiler version project target among those installed on the machine (e.g.: Visual Studio 15&nbsp;2017)\n<\/li>\n<li>After this step, <strong>CMake <\/strong>has checked the compiler options and library dependencies on your host computer, and allows you to customize some values.<\/li>\n<\/ul>\n<p class=\"rteindent1\" style=\"padding-left: 40px;\">Most of the time no changes are required. However, if desired, you can change default compiler options, set different paths to third party libraries, or just check that everything has been found correctly using this GUI.<\/p>\n<ul>\n<li>If an <a href=\"#CmakeErrorTips\">error occurs<\/a>, you are warned about it so that you can fix it and press the&nbsp;<strong>Configure<\/strong> button again. Repeat as necessary until the \"Configuring done\" message appears and no longer errors are shown.<\/li>\n<li>Press the&nbsp;<strong>Generate<\/strong> button, <strong>CMake <\/strong>will generate all <strong>Makefiles <\/strong>or Projects\/Solutions for all examples in the selected output directory.\n<\/li>\n<\/ul>\n<ul>\n<li>If OIVHOME and OIVARCH are not set, or wrongly set, CMake will be unable to find Open Inventor binaries needed to generated the demo projects and will generate an error. Be sure these two variables are well defined (please refer <a href=\"https:\/\/developer.openinventor.com\/index.php\/general-documentation\/installation-and-verification\/\">to this section<\/a> for additional details)<\/li>\n<li>With Linux: it is important to have this CMAKE_BUILD_TYPE=Release for release version and CMAKE_BUILD_TYPE=Debug for debug version.<\/li>\n<li>Verify paths to third party libraries, see page <a href=\"https:\/\/developer.openinventor.com\/index.php\/general-documentation\/system-requirements\">system requirement<\/a> for details on specific Operating System.<\/li>\n<li>For QT make sure the installation has been done properly and that Qt installer updated your environnement variable with correct value (this value are used by CMake to retrieve needed Qt information)<\/li>\n<\/ul>\n<hr>\n<h2><a id=\"ProjectGenerationLinux\" name=\"ProjectGenerationLinux\"><\/a>Project generation using CMake GUI - Linux<\/h2>\n<ul>\n<li>Define the requested environment variable : OIVHOME and&nbsp;OIVARCH<\/li>\n<li>If you run the classic CMake installation, just enter in a command line shell <strong>cmake-gui&amp;.<\/strong>&nbsp;\n<\/li>\n<li>In cmake-gui window you have two settings to set : the <strong>path to the examples source<\/strong> (Where is the source code), and the second one will be where you want to generate the Makefiles. Once both variables are set, you can click on the Configure button.\n<\/li>\n<li>CMake will then ask you what kind of binaries you want to generate. In the drop down list, select <strong>Unix Makefiles<\/strong> and click on Done. CMake will then start the configuration needed for the generation.\n<\/li>\n<li>During the configuration step CMake may generated critical error if your environment is not set properly.\n<ol>\n<li>If <strong>OIVHOME<\/strong> or <strong>OIVARCH<\/strong> are not set, CMake will stop because it's impossible to find Open Inventor. Be sure to set environment variable properly <strong>before<\/strong> launching cmake-gui in the command line windows. In this case, you will have to quit CMake, check (and fix) your environment, and relaunch CMake for change to be taken in account.<\/li>\n<li>It's also possible that CMake does not find your Qt installation. In this case it will display an error about not being able to find Qt5Config.cmake.In such case, click on Ok, then in the Search text box enter <strong>QT5_DIR<\/strong>. CMake will show the actual value of Qt5_DIR variable which will either not being set&nbsp;(value set to QT5_DIR-NOTFOUND) or wrongly set. Click on the button on the right in front of the variable name, it will allow you to specify where is located your Qt installation. <strong>Important note<\/strong> : the folder you must select is the one where Qt Cmakefiles are located. It might be something like <strong>&lt;Your Qt Installation Folder&gt;\/....\/lib\/cmake\/Qt5<\/strong> (see image below, taken from an old Qt 5.9.2&nbsp;installation done in folder \/Users\/buildsystems\/)<\/li>\n<\/ol>\n<\/li>\n<li>Click on configure again so the <strong>Qt5_DIR<\/strong> variable will be taken in account and CMake will be able to configure everything with the QT you just specified. Once configuration is done, you might see a window&nbsp;like the one below, with all values automatically set by CMake (note that Qt5 variables may appear on red, but this is not a problem, CMake is just showing what has been updated automatically).\n<p class=\"rtecenter\">\n<\/li>\n<li>Next step is to specify which build type you want. For this, in Search text box just enter <strong>CMAKE_BUILD_TYPE<\/strong> and press Enter. Just as before CMAKE will show the value of the variable and it must be empty. You can enter Release or Debug depending on what you intend to do with the demo. Below we decided to build the Release version of the examples. Do not forget to click on Configure for the change to be taken in account.\n<\/li>\n<li>Once the configuration is done, you can check Open Inventor Librairies have been properly selected by CMake. Search for INVENTOR in the Search text box, and a lot of variable will be shown by CMake. Some may be marked as NOTFOUND but these are some unsupported libraries on the platform. Look for values associated to variable <strong>fei_inventorBase_LIBRARY<\/strong>, it should be set properly.\n<\/li>\n<li>You can then click on the <strong>Generate<\/strong> button so CMake will generate the makefiles in the folder you defined at the beginning of the procedure. Once the generation is done, you can generate any example binary by running a make command in the wanted folder.<\/li>\n<\/ul>\n<h2><a name=\"ProjectGenerationCommandLine\"><\/a>Project generation using CMake in command line<\/h2>\n<p>On all platforms you can also use the comand line to generate VcProj (Windows) or Makefiles (Linux)<\/p>\n<ol>\n<li>Set <a href=\"#EnvironmentVariables\">environment variable<\/a>&nbsp;and make sure &lt;CMake Installation Dir&gt;\/bin is in the $PATH environment variable (so you can run CMake command from everywhere in your command line window).<\/li>\n<li>Create a new folder for binaries in which you will run the <strong>CMake<\/strong> command. This folder <strong>must not<\/strong> be inside of the $OIVHOME\/examples folder.\n<ol>\n<li><em>cd ${OIVHOME}<\/em><\/li>\n<li><em>mkdir buildDemo_release<\/em><\/li>\n<\/ol>\n<\/li>\n<li><em>go inside this new folder : cd&nbsp;buildDemo_release<\/em><\/li>\n<\/ol>\n<ol start=\"4\">\n<li><em>Type the following command line <\/em>\n<ol>\n<li><em><u>On Linux:<\/u><\/em> <span style=\"font-size: 14px;\">cmake -G \"Unix Makefiles\" -DCMAKE_BUILD_TYPE=Release $OIVHOME\/examples<\/span><\/li>\n<li><em><u>On windows:<\/u><\/em> <span style=\"font-size: 14px;\">cmake -DCMAKE_BUILD_TYPE=Release -G &lt;Generator Name&gt;* $OIVHOME\/examples<\/span><\/li>\n<\/ol>\n<p class=\"rteindent2\">*&lt;Generator Name&gt;: on Windows to define the generator you must use:<\/p>\n<ul>\n<li>Visual Studio 2013 for VC12 (Open Inventor 9.9.x only)<\/li>\n<li>Visual Studio 2015 for VC14 (Open Inventor 9.9.x and 10)<\/li>\n<li>Visual Studio 2017 for VC15 (Open Inventor 9.9.x and 10)<\/li>\n<\/ul>\n<p class=\"rteindent2\">add <strong>Win64<\/strong>&nbsp;if you want to generate 64 bit vcproj.<\/p>\n<p class=\"rteindent2\">So, for example, to generate VS 2015 64 bit vcproj the command line would be :<\/p>\n<pre class=\"rtecenter rteindent3\"><span style=\"font-size: 14px;\">cmake -DCMAKE_BUILD_TYPE=Release -G \"Visual Studio 14 2015 Win64\" %OIVHOME%\/examples<\/span><\/pre>\n<p class=\"rteindent1\">If you have <a href=\"#CmakeErrorTips\">cmake errors<\/a>&nbsp;please refer to cmake-gui chapter.<\/p>\n<h2><a name=\"CreatingModifyingProject\"><\/a>Creating\/Modifying project<\/h2>\n<ul>\n<li>To modify an existing project, edit the CMakeLists.txt file located in the source folder of the demos.<br \/>\n<u>Do not edit the project files<\/u>, Makefiles or Visual studio project files (.vcproj\/.sln or .vcxproj\/.sln) directly, as <strong>CMake <\/strong>manages dependencies and they are rebuilt automatically when CMakeLists.txt files are changed.<\/li>\n<\/ul>\n<ul>\n<li>To create new project or solution, see the CMakeLists.txt file for existing examples, or go to <a href=\"http:\/\/www.cmake.org\/\">CMake official documentation website<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction PrerequisitesEnvironment variables Project generation using CMake GUI Windows Linux Project generation using CMake in command line Creating\/Modifying project Introduction&hellip;<\/p>\n","protected":false},"author":3,"featured_media":0,"parent":63,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-144","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/developer.openinventor.com\/index.php\/wp-json\/wp\/v2\/pages\/144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/developer.openinventor.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/developer.openinventor.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/developer.openinventor.com\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/developer.openinventor.com\/index.php\/wp-json\/wp\/v2\/comments?post=144"}],"version-history":[{"count":7,"href":"https:\/\/developer.openinventor.com\/index.php\/wp-json\/wp\/v2\/pages\/144\/revisions"}],"predecessor-version":[{"id":482,"href":"https:\/\/developer.openinventor.com\/index.php\/wp-json\/wp\/v2\/pages\/144\/revisions\/482"}],"up":[{"embeddable":true,"href":"https:\/\/developer.openinventor.com\/index.php\/wp-json\/wp\/v2\/pages\/63"}],"wp:attachment":[{"href":"https:\/\/developer.openinventor.com\/index.php\/wp-json\/wp\/v2\/media?parent=144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}