Skip to content

Latest commit

 

History

History
368 lines (249 loc) · 11.7 KB

Setup_guide_ubuntu22.04.md

File metadata and controls

368 lines (249 loc) · 11.7 KB

Setup guide Ubuntu 22.04

Table of contents

Prerequisites

  • Ubuntu22.04 64 bit

  • Build tools and xrand

    sudo apt-get install build-essential libxrandr-dev ninja-build

    Beware we now use ninja-build as the default build system instead of make!

  • CMake 3.16 or newer

    sudo apt-get install cmake
  • Python 3.6+ To be able run python scripts, they are not needed to build. It should be part of the default Ubuntu install.

  • DevIL (Developer's Image Library)

    sudo apt-get install libdevil-dev
  • Assimp (Open Asset Import Library) Is now downloaded and build from source when needed. So its no longer necessary to run "sudo apt-get install libassimp-dev".

  • Download the source from git.

For OpenGL ES, OpenCL, OpenCV, OpenVX and Vulkan support additional packages are required, see below.

It's also a good idea to read the introduction to the FslBuild toolchain


Simple setup

  1. Decide what API's you want to compile and run apps for then install them using one of the guides below.

  2. Start a terminal (ctrl+alt t) in the DemoFramework folder

  3. Run the prepare.sh file located in the root of the framework folder to configure the necessary environment variables and paths. Please beware that the prepare.sh file requires the current working directory to be the root of your demoframework folder to function (which is also the folder it resides in).

    source prepare.sh

Add OpenGL ES support

  1. One of these (they are mutually exclusive):

  2. Continue the normal setup.

Add Vulkan support

Install the Vulkan SDK, See the official SDK guide

  1. Download the Vulkan sdk

  2. Follow the documentation

  3. Ensure that you run the setup-env.sh as recommended by the documentation.

  4. Ensure that the LIBRARY_PATH is set for GCC

    export LIBRARY_PATH=$VULKAN_SDK/lib:$LIBRARY_PATH
  5. Continue the normal setup.

Add OpenCL support

  1. Download and install a OpenCL implementation. Beware we depend on cmake's find_package support to locate the installed OpenCL implementation.
  2. Continue the normal setup.

Add OpenCV support

  1. Install the required packages

    sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
  2. Install the optional packages

    sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
  3. Create a sdk directory

    mkdir ~/sdk
    cd ~/sdk
  4. Download the 4.6.0 release for ubuntu, unzip it, remove the download, enter the directory

    wget https://github.com/opencv/opencv/archive/4.6.0.zip
    unzip 4.6.0.zip
    rm 4.6.0.zip
    cd opencv-4.6.0
  5. Build OpenCV

    mkdir release
    cd release
    cmake -GNinja -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
    ninja -j $(nproc)
    sudo ninja install
  6. Ensure that the OpenCV 4 headers are where they used to be

    sudo ln -s /usr/local/include/opencv4/opencv2/ /usr/local/include/opencv2
  7. Ensure that you can locate the OpenCV .so files

    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
  8. Continue the normal setup.


Add OpenVX support

  1. Follow the guide for setting up OpenCL and OpenCV support. (need OpenCV4.2)
  2. Continue the normal setup.

The build chain will download and compile a OpenVX implementation.


To Compile and run an existing sample application

The general approach will be:

  1. Make sure that you performed the simple setup, including the API's the sample need.

  2. Change directory to the sample directory:

    cd DemoApps/<MAIN-API-NAME>/<SAMPLE-NAME>

    Example MAIN-API-NAME's: GLES2, GLES3, OpenCL, Vulkan.

    Type dir to see the dir choice.

    Example SAMPLE-NAME's: Bloom, S06_Texturing.

    Type dir after entering a API folder to see the list of samples

  3. Build and run the application

    FslBuildRun.py

The following commands are also pretty useful to know.

Command Description
FslBuild.py To build the example.
FslBuildRun.py To build and run the example.
FslBuild.py --ListVariants List all the build variants that can be specified.
FslBuildInfo.py --ListRequirements To list the samples requirements.
FslBuild.py -c open2 Experimental Open the project in Visual Studio Code

It is also recommended to check out the README.md and Example.jpg that is included with all samples.

Note:

If you add source files to a project or change the Fsl.gen file then run the FslBuildGen.py script in the project root folder to regenerate the various build files or just make sure you always use the FslBuild.py script as it automatically adds files and regenerate build files as needed.

To Compile and run an existing GLES2 sample application

In this example we will utilize the GLES2.S06_Texturing app.

  1. Make sure that you performed the simple setup, including installing and configuring a OpenGLES emulator.

  2. Change directory to the sample directory:

    cd DemoApps/GLES2/S06_Texturing
  3. Build and run the application

    FslBuildRun.py

To create a new demo project named 'CoolNewDemo'

  1. Make sure that you performed the simple setup including the additional OpenGL ES setup.

  2. Change directory to the appropriate sample directory:

    cd DemoApps/<MAIN-API-NAME>

    Example MAIN-API-NAME's: GLES2, GLES3, OpenCL, Vulkan.

    Type dir to see the dir choice.

  3. Create the project template using the FslBuildNew.py script

    FslBuildNew.py <TEMPLATE-NAME> CoolNewDemo

    Example TEMPLATE-NAME's: GLES2, GLES3, OpenCL1_2, OpenCV4, Vulkan.

    To get a full list run FslBuildNew.py . . --List

  4. Change directory to the newly created project folder 'CoolNewDemo'

    cd CoolNewDemo
  5. Compile the project

    FslBuild.py

Note:

If you add source files to a project or change the Fsl.gen file then run the FslBuildGen.py script in the project root folder to regenerate the various build files or just make sure you always use the FslBuild.py script as it automatically adds files and regenerate build files as needed.

So to create a new GLES2 demo project named 'CoolNewDemo'

In this example we will create a GLES2 app called CoolNewDemo.

  1. Make sure that you performed the simple setup including the additional OpenGL ES setup.

  2. Change directory to the GLES2 sample directory:

    cd DemoApps/GLES2
  3. Create the project template using the FslBuildNew.py script

    FslBuildNew.py GLES2 CoolNewDemo
  4. Change directory to the newly created project folder 'CoolNewDemo'

    cd CoolNewDemo
  5. Compile the project

    FslBuild.py

To Compile all samples

  1. Make sure that you performed the simple setup.

  2. Compile everything (a good rule of thumb for '--BuildThreads N' is number of cpu cores * 2)

    FslBuild.py -t sdk --BuildThreads 2

    Beware the FslBuild scripts will chose a sensible default for --BuildThreads if its not supplied.


Visual Studio Code support

There is now experimental visual studio code support. To support visual studio code we generate/patch the configuration files stored under .vscode.

  • launch.json contains the configuration used to launch the executable if one exist
  • settings.json contains the cmake configuration required to build the project.

VS Code Prerequisites

To Compile and run an existing sample application using VSCode

In this example we will utilize the GLES2.S06_Texturing app.

  1. Make sure that you performed the simple setup.

  2. Change directory to the sample directory:

    cd DemoApps/GLES2/S06_Texturing
  3. Open the project in visual studio code

    FslBuild.py -c open2

    This should launch visual studio code configured for the app.

BEWARE: Visual Studio Code has its own setting for debug/release build which is configured in the bottom blue line. BEWARE: Make sure you use the correct launch script. "FslBuild-Windows" for windows and "FslBuild-Ubuntu" for ubuntu.

Visual Studio Code Wayland Issues Workaround

On newer version of Ubuntu using wayland Visual Studio Code might have issues with the title bar and other windows not being clickable. For some the following workaround works

FslBuild.py -c open2 --CommandArgs="--enable-features=UseOzonePlatform,WaylandWindowDecorations --ozone-platform=wayland"