My SDL2 C++ app as flatpak

Hello. I’m trying to make a flatpak version of my app. It depends on these libraries:

  • SDL2
  • SDL_mixer
  • GLEW

Should I add that libraries as modules in my flatpak manifest file? I have tried to run flatpak-builder here com.myapps.ScreenDemo.yaml and it finds SDL2 and sdl_mixer from my system, but it fails trying to find glew. Weird, because I have it installed and my app runs fine

I also have another question: I have more than one target in my CMake project, how can I indicate what target I want to build as flatpak? Because my base project is my engine, then the apps are in subfolders. For this test, I’m trying to build only one as flatpak

My manifest file:

id: com.myapps.ScreenDemo
runtime: org.freedesktop.Platform
runtime-version: '23.08'
sdk: org.freedesktop.Sdk
command: ScreenDemo-Linux64-GNU_Debug
# rename-desktop-file: ScreenDemo.desktop
# rename-icon: ScreenDemo

modules:
  - name: ScreenDemo
    buildsystem: cmake
    config-opts:
      - -DCMAKE_BUILD_TYPE=Debug
      # - -DCMAKE_INSTALL_PREFIX=/app/bin # required ?
    build-commands:
      # Lo que yo tengo que hacer en mi caso, es especificar el TARGET!
      - cmake --build . --target ScreenDemo-Linux64-GNU_Debug
    builddir: true
    # Copy data files here ???
    # post-install:
    sources:
      - type: dir
        path: /home/paul/Programming/proyectos/MyApps

finish-args:
  # share IPC namespace with the host (necessary for X11)
  - --share=ipc
  # show windows using X11, if Wayland is not available,
  # overrides x11 socket permission
  - --socket=fallback-x11
  # Wayland access
  - --socket=wayland
  # OpenGL rendering
  - --device=dri
  # Audio
  - --socket=pulseaudio

The error:

Downloading sources
Initializing build dir
Committing stage init to cache
Starting build of com.myapps.ScreenDemo
========================================================================
Building module ScreenDemo in /home/paul/Programming/proyectos/MyApps/platform/flatpaks/ScreenDemo/.flatpak-builder/build/ScreenDemo-1
========================================================================
-- The CXX compiler identification is GNU 13.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SDL2: /usr/lib/x86_64-linux-gnu/libSDL2.so (found version "2.28.5") 
CMake Warning (dev) at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (SDL2main)
  does not match the name of the calling package (SDL2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/sdl2/FindSDL2.cmake:318 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:84 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found SDL2main: /usr/lib/x86_64-linux-gnu/libSDL2main.a (found version "2.28.5") 
CMake Warning (dev) at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (SDL2main)
  does not match the name of the calling package (SDL2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/sdl2/FindSDL2.cmake:318 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  cmake/sdl2/FindSDL2_mixer.cmake:112 (find_package)
  CMakeLists.txt:86 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found SDL2_mixer: /usr/lib/x86_64-linux-gnu/libSDL2_mixer.so (found version "2.6.3") 
CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find GLEW (missing: GLEW_INCLUDE_DIRS GLEW_LIBRARIES)
Call Stack (most recent call first):
  /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.28/Modules/FindGLEW.cmake:242 (find_package_handle_standard_args)
  CMakeLists.txt:88 (find_package)


-- Configuring incomplete, errors occurred!
Error: module ScreenDemo: Child process exited with code 1

That’s not how flatpak works, it likely finds these from the freedesktop.Platform you are using. Stuff thats missing like glew needs to be added as modules, in the case of glew you can use the prepared one from GitHub - flathub/shared-modules: Common Flatpak modules that can be used as a git submodule if you need it unmodified.

1 Like

I will try that, thanks

Am I setting the app target correctly? What is the exact command flatpak-builder runs for CMake builds by default under the hood?

Hello
I successfully added glew and glu (seems to be a requirement for glew) from the repository, it worked fine

-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /run/build/ScreenDemo/_flatpak_build

But the other problem remains. Flatpak builder is installing files from my other apps, and at the end, it cannot find my executable. That’s because the target is not correctly defined

Running: pwd
/run/build/ScreenDemo/_flatpak_build
Running: cmake --build . --target ScreenDemo-Linux64-GNU_Debug
[ 96%] Built target Engine-Static-Linux64-GNU_Debug
[100%] Built target ScreenDemo-Linux64-GNU_Debug
[ 89%] Built target Engine-Static-Linux64-GNU_Debug
[ 91%] Built target fontcvt-Linux64-GNU_Debug
[ 94%] Built target Pasen-Linux64-GNU_Debug
[ 97%] Built target ScreenDemo-Linux64-GNU_Debug
[100%] Built target Terreno-Linux64-GNU_Debug
Install the project...
-- Install configuration: "Debug"
-- Installing: /app/lib/libEngine-Static-Linux64-GNU_Debug.a
-- Installing: /run/build/ScreenDemo/bin/install/Pasen/Pasen-Linux64-GNU_Debug
-- Installing: /run/build/ScreenDemo/bin/install/Pasen/Pasen
-- Installing: /run/build/ScreenDemo/bin/install/Pasen/Pasen/pasen_log.txt
-- Installing: /run/build/ScreenDemo/bin/install/Pasen/Pasen/pasen_config.cfg
-- Installing: /run/build/ScreenDemo/bin/install/Pasen/Pasen/textures
-- Installing: /run/build/ScreenDemo/bin/install/Pasen/Pasen/textures/copy-icon.png
-- Installing: /run/build/ScreenDemo/bin/install/ScreenDemo/ScreenDemo-Linux64-GNU_Debug
-- Installing: /run/build/ScreenDemo/bin/install/ScreenDemo/ScreenDemo
-- Installing: /run/build/ScreenDemo/bin/install/ScreenDemo/ScreenDemo/screen_demo_log.txt
-- Installing: /run/build/ScreenDemo/bin/install/ScreenDemo/ScreenDemo/sounds
-- Installing: /run/build/ScreenDemo/bin/install/ScreenDemo/ScreenDemo/sounds/388046__paep3nguin__beep_up.wav
-- Installing: /run/build/ScreenDemo/bin/install/ScreenDemo/ScreenDemo/sounds/388047__paep3nguin__beep_down.wav
-- Installing: /run/build/ScreenDemo/bin/install/ScreenDemo/ScreenDemo/screen_demo_config.cfg
-- Installing: /run/build/ScreenDemo/bin/install/Terreno/Terreno-Linux64-GNU_Debug
-- Installing: /run/build/ScreenDemo/bin/install/Terreno/Terreno
-- Installing: /run/build/ScreenDemo/bin/install/Terreno/Terreno/textures
-- Installing: /run/build/ScreenDemo/bin/install/Terreno/Terreno/textures/tileset_sci-fi.png
-- Installing: /run/build/ScreenDemo/bin/install/Terreno/Terreno/textures/estatua_mi_foto.png
-- Installing: /run/build/ScreenDemo/bin/install/Terreno/Terreno/textures/karl.png
-- Installing: /run/build/ScreenDemo/bin/install/Terreno/Terreno/terreno_config.cfg
-- Installing: /run/build/ScreenDemo/bin/install/Terreno/Terreno/terreno_log.txt
-- Installing: /run/build/ScreenDemo/bin/install/Terreno/Terreno/temp_test_sheet.pepon_sheet
Committing stage build-ScreenDemo to cache
Cleaning up
Removing files/lib/pkgconfig/glu.pc
Removing files/lib/pkgconfig/glew.pc
Removing files/lib/pkgconfig
Removing files/lib/libGLU.a
Removing files/lib/libGLEW.a
Removing files/include/GL/wglew.h
Removing files/include/GL/glxew.h
Removing files/include/GL/glu.h
Removing files/include/GL/glew.h
Removing files/include/GL
Removing files/include
Committing stage cleanup to cache
Finishing app
Error: Command 'ScreenDemo-Linux64-GNU_Debug' not found

Terreno and Pasen are my other apps I build with the same engine. I only want to compile the ScreenDemo-Linux64-GNU_Debug target. How can I do that?

Also, my default install folder is bin/install, should I change that? How?

I have found a post that may solve the target issue. It seems CMake builds all targets when something is installed. It can be disabled using CMAKE_SKIP_INSTALL_ALL_DEPENDENCY — CMake 3.28.3 Documentation

But now it doesn’t find glew anymore
I have updated the flathub shared modules:

git submodule update --remote --merge

Error:

-- Found SDL2_mixer: /usr/lib/x86_64-linux-gnu/libSDL2_mixer.so (found version "2.6.3") 
CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find GLEW (missing: GLEW_INCLUDE_DIRS GLEW_LIBRARIES)
Call Stack (most recent call first):
  /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.28/Modules/FindGLEW.cmake:242 (find_package_handle_standard_args)
  CMakeLists.txt:85 (find_package)


-- Configuring incomplete, errors occurred!
Error: module ScreenDemo: Child process exited with code 1

My manifest:

id: com.my_engine.ScreenDemo
runtime: org.freedesktop.Platform
runtime-version: '23.08'
sdk: org.freedesktop.Sdk
command: ScreenDemo-Linux64-GNU_Debug
# rename-desktop-file: ScreenDemo.desktop
# rename-icon: ScreenDemo

modules:
  - shared-modules/glu/glu-9.json
  - name: glu

  - shared-modules/glew/glew.json
  - name: glew

  - name: ScreenDemo
    buildsystem: cmake
    config-opts:
      - -DCMAKE_BUILD_TYPE=Debug
      - -DCMAKE_INSTALL_PREFIX=/app/bin # correct? or should it be /run/build?
    build-commands:
      - pwd # Just to check
      - cmake --build . --target ScreenDemo-Linux64-GNU_Debug
    builddir: true
    # Copy data files here ???
    # post-install:
    sources:
      - type: dir
        path: /home/paul/Programming/proyectos/X

finish-args:
  - --socket=wayland
  - --socket=fallback-x11
  - --share=ipc
  - --device=dri
  - --socket=pulseaudio
      - -DCMAKE_INSTALL_PREFIX=/app/bin # correct? or should it be /run/build?

The prefix should be /app, but you don’t need to set it; flatpak-builder will do that automatically.

I’m not sure the proper way to specify a target, but mixing flatpak-builder’s cmake support with manual calls to cmake probably isn’t going to work well.

If you set make-args to the target name, that may work. That will make flatpak-builder pass that string to make (or ninja if you use the ‘cmake-ninja’ buildsystem).

Hello chrisawi. It now starts compiling again!
But the problem of the target remains
Not only every app is built, but it also tries to install to the path I have set in my CMake files (bin/install)

Some output:
You can see, the library is installed at the correct path, but the other apps are also installed, and to the incorrect path

Install the project...
-- Install configuration: "Debug"
-- Installing: /app/lib/libEngine-Static-Linux64-GNU_Debug.a
-- Installing: /run/build/ScreenDemo/bin/install/Pasen/Pasen-Linux64-GNU_Debug
-- Installing: /run/build/ScreenDemo/bin/install/ScreenDemo/ScreenDemo-Linux64-GNU_Debug
-- Installing: /run/build/ScreenDemo/bin/install/Terreno/Terreno-Linux64-GNU_Debug

What I have tried in the manifest

config-opts:
      - -DCMAKE_BUILD_TYPE=Debug
      # Tried with and without this next one
      - -DCMAKE_INSTALL_PREFIX=/app
    build-commands:
      # With and without this
      - cmake --build . --target ScreenDemo-Linux64-GNU_Debug
    make-args:
      # Tried both of these
      --target ScreenDemo-Linux64-GNU_Debug
      - ScreenDemo-Linux64-GNU_Debug

You can add -v to flatpak-builder then it logs the build commands it’s running (flatpak-builder -v …) (reference).

I’m not sure I correctly understand what you mean, but flatpak-builder only builds the way it’s specified by the build system. You are responsible to define the correct destinations (which should be based on the install prefix).

This is how I build my engine, the folder is specified because it’s very convenient for me to testing my apps in my computer

# Output directory for the engine library and executables
set(X_PATH_BINARY_FILES "${X_SOURCE_DIR}/bin")
# Installation path
set(X_INSTALLATION_PATH "${X_PATH_BINARY_FILES}/install")

# Compile as static library
add_library(${X_LIBRARY_TARGET} STATIC)
# Set static library output directory
set_target_properties(${X_LIBRARY_TARGET} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${X_PATH_BINARY_FILES})

# Don't make the install target depend on the 'all' target
# https://stackoverflow.com/questions/17164731/installing-only-one-target-and-its-dependencies-out-of-a-complex-project-with
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)

install(TARGETS ${X_LIBRARY_TARGET} OPTIONAL RUNTIME DESTINATION ${X_INSTALLATION_PATH})

Complete verbose output:

flatpak-builder here -v --force-clean com.x_engine.ScreenDemo.yaml
FB: Running: git config --get user.email
FB: Running: git config --get user.name
Emptying app dir 'here'
FB: Running: flatpak info --arch=x86_64 --show-commit org.freedesktop.Sdk 23.08
FB: Running: flatpak info --show-location --arch=x86_64 org.freedesktop.Sdk 23.08
FB: Running: flatpak info --arch=x86_64 --show-commit org.freedesktop.Platform 23.08
Downloading sources
Starting build of com.x_engine.ScreenDemo
Cache hit for glu, skipping build
Skipping module glu-2 (no sources)
Cache hit for glew, skipping build
Skipping module glew-2 (no sources)
Cache miss, checking out last cache hit
FB: Mounting read-only fs: rofiles-fuse /home/paul/Programming/proyectos/X/platform/flatpaks/ScreenDemo/here /home/paul/Programming/proyectos/X/platform/flatpaks/ScreenDemo/.flatpak-builder/rofiles/rofiles-Rw0MkC
========================================================================
Building module ScreenDemo in /home/paul/Programming/proyectos/X/platform/flatpaks/ScreenDemo/.flatpak-builder/build/ScreenDemo-9
========================================================================
FB: Running: flatpak build --die-with-parent --env=FLATPAK_BUILDER_BUILDDIR=/run/build/ScreenDemo --nofilesystem=host:reset --filesystem=/home/paul/Programming/proyectos/X/platform/flatpaks/ScreenDemo/.flatpak-builder/build/ScreenDemo-9 --bind-mount=/run/build/ScreenDemo=/home/paul/Programming/proyectos/X/platform/flatpaks/ScreenDemo/.flatpak-builder/build/ScreenDemo-9 --build-dir=/run/build/ScreenDemo/_flatpak_build --bind-mount=/run/ccache=/home/paul/Programming/proyectos/X/platform/flatpaks/ScreenDemo/.flatpak-builder/ccache --env=SOURCE_DATE_EPOCH=1707682502 '--env=CFLAGS=-O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer ' '--env=CXXFLAGS=-O2 -pipe -g -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer ' '--env=LDFLAGS=-L/app/lib -Wl,-z,relro,-z,now -Wl,--as-needed ' --env=CCACHE_DIR=/run/ccache/disabled --env=PATH=/app/bin:/usr/bin --env=LD_LIBRARY_PATH=/app/lib --env=PKG_CONFIG_PATH=/app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig --env=FLATPAK_BUILDER_N_JOBS=4 /home/paul/Programming/proyectos/X/platform/flatpaks/ScreenDemo/.flatpak-builder/rofiles/rofiles-Rw0MkC cmake '-DCMAKE_INSTALL_PREFIX:PATH='\''/app'\''' -G 'Unix Makefiles' .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/run/build
-- The CXX compiler identification is GNU 13.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SDL2: /usr/lib/x86_64-linux-gnu/libSDL2.so (found version "2.28.5") 
CMake Warning (dev) at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (SDL2main)
  does not match the name of the calling package (SDL2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/sdl2/FindSDL2.cmake:318 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:81 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found SDL2main: /usr/lib/x86_64-linux-gnu/libSDL2main.a (found version "2.28.5") 
CMake Warning (dev) at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
  The package name passed to `find_package_handle_standard_args` (SDL2main)
  does not match the name of the calling package (SDL2).  This can lead to
  problems in calling code that expects `find_package` result variables
  (e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
  cmake/sdl2/FindSDL2.cmake:318 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  cmake/sdl2/FindSDL2_mixer.cmake:112 (find_package)
  CMakeLists.txt:83 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found SDL2_mixer: /usr/lib/x86_64-linux-gnu/libSDL2_mixer.so (found version "2.6.3") 
CMake Error at /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find GLEW (missing: GLEW_INCLUDE_DIRS GLEW_LIBRARIES)
Call Stack (most recent call first):
  /usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.28/Modules/FindGLEW.cmake:242 (find_package_handle_standard_args)
  CMakeLists.txt:85 (find_package)


-- Configuring incomplete, errors occurred!
Error: module ScreenDemo: Child process exited with code 1
FB: Unmounting read-only fs: fusermount -uz /home/paul/Programming/proyectos/X/platform/flatpaks/ScreenDemo/.flatpak-builder/rofiles/rofiles-Rw0MkC

Latest changes to the manifest:

modules:
  - shared-modules/glu/glu-9.json
  - name: glu

  - shared-modules/glew/glew.json
  - name: glew
  - name: ScreenDemo
    buildsystem: cmake
    config-opts:
      - -DCMAKE_BUILD_TYPE=Debug
      - -DCMAKE_INSTALL_PREFIX=/run/build
    build-commands:
      - cmake --build . --target ScreenDemo-Linux64-GNU_Debug
      # cmake --install . --prefix /run/build
    make-args:
      - ScreenDemo-Linux64-GNU_Debug
    builddir: true
    sources:
      - type: dir
        path: /home/paul/Programming/proyectos/X

Everything the application provides must be put into /app (that’s why it gets always automatically set). Though I’m not sure why your build is now failing.

I can only recommend to change your build to install into the provided install prefix. It’s not flatpak specific, probably all distributions expect this behaviour. Set the default to what you like but don’t ignore the value if provided.

And you should check the output of the build:

Skipping module glu-2 (no sources)
Skipping module glew-2 (no sources)

You added two empty modules. The provided shared-modules already contain the whole definition (I think you can’t actually add anything to a included manifest, you’d have to edit the json files).

I think this should work, but you’ll have to check the actual build commands:

modules:
  - shared-modules/glu/glu-9.json
  - shared-modules/glew/glew.json
  - name: ScreenDemo
    buildsystem: cmake
    config-opts:
      - -DCMAKE_BUILD_TYPE=Debug
    make-args:
      - --target ScreenDemo-Linux64-GNU_Debug
    builddir: true
    sources:
      - type: dir
        path: /home/paul/Programming/proyectos/X
1 Like

I don’t need to specify the name, I see. Ok, this worked great!

Here I just put the app name, because this is a parameter for make, not for CMake, and it worked fine

I have tried a lot of things, but it never finds my app. It seems there is no way to select a single target for the build, and no way to select the installation path. Latest manifest

- name: ScreenDemo
    buildsystem: cmake
    config-opts:
      - -DCMAKE_BUILD_TYPE=Debug
      - -DCMAKE_INSTALL_PREFIX=/app
    build-commands:
      - cmake --build . --target ScreenDemo-Linux64-GNU_Debug
      - cmake --install . --prefix /app
    # These commands are only for make, not for CMake
    make-args:
      - ScreenDemo-Linux64-GNU_Debug
    builddir: true
    sources:
      - type: dir
        path: /home/paul/Programming/proyectos/X

Should I set the buildsystem to ‘simple’ and pass every parameter to CMake in my own way?

I’m still not sure I understand what you mean. flatpak-builder never searches for your app. Your data is either found in /app (especially the command must be in /app/bin/ScreenDemo-Linux64-GNU_Debug*) or not found in any other place. You cannot change this behaviour. Your buildsystem and/or manifest are responsible to put the files in the correct locations. There are some additional folders which you must adhere to, see Requirements & Conventions.

* You could create a script instead which executes another command in a different location within /app.

I don’t understand which command should receive the target? If I’m not mistaken, your current build should look something like this:

cmake <config-opts>
make <make-args>
cmake --build . --target ScreenDemo-Linux64-GNU_Debug
cmake --install . --prefix /app
make install <make-install-args>

Usually an application does not define any build-commands because flatpak-builder will run configure, make & make install (or the equivalent of the buildsystem). Via the corresponding arrays you can pass additional options (check this with flatpak-builder -v).

Of course, you can try a manual way, this removes any build commands run by flatpak. There are also more options in the manifest you can use to customize the other buildsystems, for example to manually move files into /app):

install-rule (string)
Name of the rule passed to make for the install phase, default is install

no-make-install (boolean)
Don’t run the make install (or equivalent) stage

post-install (array of strings)
An array of shell commands that are run after the install phase. Can for example clean up the install dir, or install extra files.

I’m sorry if I wasn’t clear enough. I’m trying to say that CMake is taking the install path I have setup in my CMake file. It should be overridable from the command line, but it does not seem to be working. Please take a look at this section of the log:

-- Installing: /run/build/ScreenDemo/bin/install/ScreenDemo/ScreenDemo-Linux64-GNU_Debug

That bin/install/ScreenDemo/ portion of the path is what I set in the CMake file for my regular builds (not flatpak). But then you can see that

-- Installing: /app/lib/libX-Static-Linux64-GNU_Debug.a

My engine (static library, dependency for all my apps) seems to be installed to the correct place (/app/lib). So, I guess the app should be installed in the /run/build/ folder. Then the final error message says this:

Committing stage cleanup to cache
Finishing app
Error: Command 'ScreenDemo-Linux64-GNU_Debug' not found

I guess the builder is using /run/build as a temporary, then it copy/moves the executable to /app. Is this correct?

That’s correct. It’s where the sources are put & the build is run from.

That’s not correct, flatpak-builder doesn’t know anything about your build. It only executes the build commands (e.g. cmake, make, make install & somewhere in between what’s defined in build-commands & post-install) & sets the prefix to /app.

As I have said: It’s your responsibility to install all needed files into the /app prefix (especially to put the binary into /app/bin).

Your build seems to install the files into the source dir (/run/build/<MODULE>), that’s not correct.

# Output directory for the engine library and executables
set(X_PATH_BINARY_FILES "${X_SOURCE_DIR}/bin")

Either update your CMake files to use the install prefix (set via -DCMAKE_INSTALL_PREFIX=/app) or manually move the files in the manifest (see the options from the documentation I’ve mentioned).

I guess CMake puts the library into the correct location. Basically all Linux applications install their files into /bin, /lib, etc. inside the prefix (/usr for normal packaging, /app for flatpak), so it should be the default behavior. But I don’t know enough about your build or CMake.

1 Like

I see. Now I have a better understanding of how flatpak-builder works. Thanks
I will try to do that and report back

Another question: if my app expects to read a file from the “data” folder, I should install/copy that folder into /app, right? So it ends up like that: /app/data. Is this correct?