- Prerequisites
- Simple setup
- To Compile and run an existing sample application
- To create a new demo project named 'CoolNewDemo'
- To Compile all samples
- Visual Studio Code support
-
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!
-
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
-
Decide what API's you want to compile and run apps for then install them using one of the guides below.
-
Start a terminal (ctrl+alt t) in the DemoFramework folder
-
Run the
prepare.sh
file located in the root of the framework folder to configure the necessary environment variables and paths. Please beware that theprepare.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
-
One of these (they are mutually exclusive):
-
Mesa OpenGL ES 2 (might not run OpenGL ES 3 apps)
sudo apt-get install libgles2-mesa-dev
-
-
Continue the normal setup.
Install the Vulkan SDK, See the official SDK guide
-
Follow the documentation
-
Ensure that you run the
setup-env.sh
as recommended by the documentation. -
Ensure that the LIBRARY_PATH is set for GCC
export LIBRARY_PATH=$VULKAN_SDK/lib:$LIBRARY_PATH
-
Continue the normal setup.
- Download and install a OpenCL implementation. Beware we depend on cmake's find_package support to locate the installed OpenCL implementation.
- Continue the normal setup.
-
Install the required packages
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
-
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
-
Create a sdk directory
mkdir ~/sdk cd ~/sdk
-
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
-
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
-
Ensure that the OpenCV 4 headers are where they used to be
sudo ln -s /usr/local/include/opencv4/opencv2/ /usr/local/include/opencv2
-
Ensure that you can locate the OpenCV .so files
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
-
Continue the normal setup.
- Follow the guide for setting up OpenCL and OpenCV support. (need OpenCV4.2)
- Continue the normal setup.
The build chain will download and compile a OpenVX implementation.
The general approach will be:
-
Make sure that you performed the simple setup, including the API's the sample need.
-
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 -
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.
In this example we will utilize the GLES2.S06_Texturing app.
-
Make sure that you performed the simple setup, including installing and configuring a OpenGLES emulator.
-
Change directory to the sample directory:
cd DemoApps/GLES2/S06_Texturing
-
Build and run the application
FslBuildRun.py
-
Make sure that you performed the simple setup including the additional OpenGL ES setup.
-
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. -
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
-
Change directory to the newly created project folder 'CoolNewDemo'
cd CoolNewDemo
-
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.
In this example we will create a GLES2 app called CoolNewDemo.
-
Make sure that you performed the simple setup including the additional OpenGL ES setup.
-
Change directory to the GLES2 sample directory:
cd DemoApps/GLES2
-
Create the project template using the FslBuildNew.py script
FslBuildNew.py GLES2 CoolNewDemo
-
Change directory to the newly created project folder 'CoolNewDemo'
cd CoolNewDemo
-
Compile the project
FslBuild.py
-
Make sure that you performed the simple setup.
-
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.
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 existsettings.json
contains the cmake configuration required to build the project.
- Visual Studio Code
- Visual Studio Code Extensions:
- Recommended visual studio code extensions:
In this example we will utilize the GLES2.S06_Texturing app.
-
Make sure that you performed the simple setup.
-
Change directory to the sample directory:
cd DemoApps/GLES2/S06_Texturing
-
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.
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"