Flatpak-builder can't find my include dir of .cpp,.h

there’s prob an easy answer to this but i’m tired of bangin my head on the same wall.

here’s my dirs:
~/src/pcheetah has a dir for each qt c++ executable
~/src/pcheetah/initme/main.cpp …etc
~/src/pcheetah/pcheetah/main.cpp my top level executable that runs the others
~/src/stv/os.h
~/src/stv/os.cpp …common classes, etc etc

now i’m pretty new to linux. I just made a softlink in each dir (~/src/pcheetah/initme/stv → which points to ~/src/stv)

so my manifest file, build dir and repo dir are in ~/src/pcheetah - named _app, _repo, _mani (a json file)

_mani has:

{
 "__cli": 'flatpak-builder --repo=_repo --subject="pcheetah `date`" --ccache --force-clean _app _mani',
 
 "app-id":  "app.shazel.pcheetah",
 "sdk":     "org.kde.Sdk",
 "runtime": "org.kde.Platform",
 "runtime-version":          "6.6",
 "command": "pcheetah",
 "modules": [
  {
   "name": "initme",
   "buildsystem": "cmake-ninja",
   "config-opts": ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"],
   "sources": [{ "type": "dir", "path": "initme" }, { "type": "dir", "path": "initme/stv" }]
  },
  {
   "name": "pcheetah",
   "buildsystem": "cmake-ninja",
   "config-opts": ["-DCMAKE_BUILD_TYPE=RelWithDebInfo"],
   "sources": [{ "type": "dir", "path": "pcheetah" }]
  }
 ],
 "finish-args": [
  "--share=ipc",
  "--socket=x11",
  "--socket=wayland",
  "--filesystem=host",
  "--device=dri"
 ]
}

And i kick flatpak-builder with:
flatpak-builder --repo=_repo --subject=“pcheetah date” --ccache --force-clean _app _mani -v

Here’s my CMakeLists.txt for initme

cmake_minimum_required(VERSION 3.5)
project(initme VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6          REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
set(PROJECT_SOURCES
        initme.cpp
        initme.h
        initme.ui
        stv/os.cpp
        stv/ui.cpp
)
qt_add_executable(initme rc/rc.qrc
    MANUAL_FINALIZATION
    ${PROJECT_SOURCES}
)
target_include_directories(initme PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}:stv")
target_link_libraries(initme PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
install(TARGETS initme
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
qt_finalize_executable(initme)

And this initme (and pcheetah and all of em) compile just fine in qtcreator.

But ole flatpak-builder gives me:

(a buncha stuff that looks totally great but then)

-- Configuring done (1.5s)
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt6Core/Qt6CoreMacros.cmake:603 (add_executable):
  Cannot find source file:

    stv/os.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
  .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
  .f95 .f03 .hip .ispc
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Qt6Core/Qt6CoreMacros.cmake:564 (_qt_internal_create_executable)
  /usr/lib/x86_64-linux-gnu/cmake/Qt6Core/Qt6CoreMacros.cmake:777 (qt6_add_executable)
  CMakeLists.txt:23 (qt_add_executable)


-- Generating done (0.0s)
CMake Generate step failed.  Build files cannot be regenerated correctly.
Error: module initme: Child process exited with code 1
FB: Unmounting read-only fs: fusermount -uz /home/sh/src/pcheetah/.flatpak-builder/rofiles/rofiles-diXdns

So the dang thing ain’t finding my stv dir
I’ve tried using relative path …/…/stv/whatev.cpp

So cmake within qtcreator is ok with everything but not cmake within flatpak-builder…

Well, techically, qtcreator compiles just fine, but the executable won’t find the flatpak runtime shared libs.

If somebody can fill me in about the PROPER way to get flatpak-builder / cmake able to find my stv dir… Pleeeease

…Steve

First of all: Please format your text. It’s not easy to follow an unknown setup & your formatting makes it unfortunately even harder. Put your files & console output into blockquotes or preformatted text & your setup becomes much easier to understand (bonus points if you format the json).

I think that’s your problem. Flatpak runs everything in a sandbox, including the build process of flatpak-builder. Directory & file sources will be copied into the build folder (see flatpak-manifest)

   Directory sources

       type
           "dir"

       path (string)
           The path of a local directory whose content will be copied into
           the source dir. Note that directory sources don't currently
           support caching, so they will be rebuilt each time.

As a result, I suspect your link targets simply don’t exist while building.

flatpak-builder provides some options to debug & investigate the build environment (--stop-at & --build-shell). You can use this to take a look at what’s happening:

Initialize the build directory:
flatpak-builder --stop-at=initme --force-clean _app _mani -v

Start a shell in the build environment:
flatpak-builder --build-shell=initme _app _mani -v

sorry about my formatting - i spruced it up a little.

My manifest for module initme has 2 dirs in sources.
The main one - initme and the stv one - stv both of type dir.

I would thiiink that the stv dir would make it in so stv/os.cpp and stv/ui.cpp could be found. I’ll try the tracing things you mentioned.

Thanks for your help !

well i ran the 2 commands and looked in the resulting build dir (_app)

First command just clears it out i guess.

Second command didn’t start any subshell or whatever.
I looked in _app and didn’t see much of anything interesting.
just got this:

sh@pengo:~/src/pcheetah$ flatpak-builder --build-shell=initme _app _mani -v
FB: Running: git config --get user.email
FB: Running: git config --get user.name
FB: Running: flatpak info --arch=x86_64 --show-commit org.kde.Sdk 6.6
FB: Running: flatpak info --show-location --arch=x86_64 org.kde.Sdk 6.6
FB: Running: flatpak info --arch=x86_64 --show-commit org.kde.Platform 6.6
Downloading sources
FB: Mounting read-only fs: rofiles-fuse /home/sh/src/pcheetah/_app /home/sh/src/pcheetah/.flatpak-builder/rofiles/rofiles-diXdns
========================================================================
Building module initme in /home/sh/src/pcheetah/.flatpak-builder/build/initme-2
========================================================================
FB: Running: flatpak build --die-with-parent --env=FLATPAK_BUILDER_BUILDDIR=/run/build/initme --nofilesystem=host:reset --filesystem=/media/sh/bu/x/src_kub/pcheetah/.flatpak-builder/build/initme-2 --bind-mount=/home/sh/src/pcheetah/.flatpak-builder/build/initme-2=/media/sh/bu/x/src_kub/pcheetah/.flatpak-builder/build/initme-2 --bind-mount=/run/build/initme=/media/sh/bu/x/src_kub/pcheetah/.flatpak-builder/build/initme-2 --build-dir=/run/build/initme --bind-mount=/run/ccache=/home/sh/src/pcheetah/.flatpak-builder/ccache --env=SOURCE_DATE_EPOCH=1706985370 '--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=20 /home/sh/src/pcheetah/.flatpak-builder/rofiles/rofiles-diXdns cmake '-DCMAKE_INSTALL_PREFIX:PATH='\''/app'\''' -G Ninja . -DCMAKE_BUILD_TYPE=RelWithDebInfo
-- 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
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE  
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
-- Found WrapOpenGL: TRUE  
-- Found XKB: /usr/lib/x86_64-linux-gnu/libxkbcommon.so (found suitable version "1.5.0", minimum required is "0.5.0") 
-- Found WrapVulkanHeaders: /usr/include  
-- Configuring done (1.1s)
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt6Core/Qt6CoreMacros.cmake:603 (add_executable):
  Cannot find source file:

    stv/os.cpp

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm
  .ccm .cxxm .c++m .h .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90
  .f95 .f03 .hip .ispc
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/Qt6Core/Qt6CoreMacros.cmake:564 (_qt_internal_create_executable)
  /usr/lib/x86_64-linux-gnu/cmake/Qt6Core/Qt6CoreMacros.cmake:777 (qt6_add_executable)
  CMakeLists.txt:23 (qt_add_executable)


-- Generating done (0.0s)
CMake Generate step failed.  Build files cannot be regenerated correctly.
Failed to setup module: module initme: Child process exited with code 1
FB: Unmounting read-only fs: fusermount -uz /home/sh/src/pcheetah/.flatpak-builder/rofiles/rofiles-diXdns

Ok I’ve come across this:
https://github.com/flatpak/qt-flatpak-demo/blob/master/CMakeLists.txt

This CMakeLists.txt looks radically different than what qtcreator makes.

I’m not having a great time followin’ these docs. When it comes to putting a qt executable into flatpak, there sure isn’t much detail.

I’d really like to find a qt6 demo app if anyone knows of one.

Sorry to be all helpless n stuff.

I mean it sure can’t be uncommon to have a src/distribute/app/main.cpp that uses a src/somelib/whatever.cpp

I guess I should just do a git source type. But I kinda prefer to build before I commit it to git.

It seems that --build-shell stops after the configuration step (Issue). I didn’t catch this because I tried it with a simple example without a configuration step.

But flatpak-builder just uses flatpak build, you can run your own commands according the verbose log. This should work as well if (the build folder must have been previously initialized by flatpak-builder, maybe you have to adjust the initme-2 build folder):

flatpak build --die-with-parent --env=FLATPAK_BUILDER_BUILDDIR=/run/build/initme --nofilesystem=host:reset --filesystem=/media/sh/bu/x/src_kub/pcheetah/.flatpak-builder/build/initme-2 --bind-mount=/home/sh/src/pcheetah/.flatpak-builder/build/initme-2=/media/sh/bu/x/src_kub/pcheetah/.flatpak-builder/build/initme-2 --bind-mount=/run/build/initme=/media/sh/bu/x/src_kub/pcheetah/.flatpak-builder/build/initme-2 --build-dir=/run/build/initme --bind-mount=/run/ccache=/home/sh/src/pcheetah/.flatpak-builder/ccache _app bash

There seems to be an additional bind-mount in the sandbox from /media/sh/… to /home/sh/…. I don’t think this would change anything, but just to take notice. The actual build happens with the files from /media/sh/….

--filesystem=/media/sh/bu/x/src_kub/pcheetah/.flatpak-builder/build/initme-2
--bind-mount=/home/sh/src/pcheetah/.flatpak-builder/build/initme-2=/media/sh/bu/x/src_kub/pcheetah/.flatpak-builder/build/initme-2
--bind-mount=/run/build/initme=/media/sh/bu/x/src_kub/pcheetah/.flatpak-builder/build/initme-2

You can also just browse the build files in the local folder without the sandbox:

/home/sh/src/pcheetah/.flatpak-builder/build/initme-2

If there are any soft-links outside this folder then the files will be missing inside the sandbox (even when they can be locally resolved).

Maybe you’ll find one in the GitHub repos, most will use the KDE runtime:
https://github.com/search?q=org%3Aflathub+org.kde.Sdk&type=code

THANK YOU !! you have given me victoryyyyy !!

I was confused thinking things were going on in my _app dir when they were ACTUALLY going on in my .flatpak-builder/build dir - SHOISH !!

And my new manifest (which I need to fill out for all my other modules) is now:
_mani

{
 "_cli": '
flatpak-builder -v --ccache --force-clean --repo=_repo _app _mani
         ',
 "app-id":  "app.shazel.pcheetah",
 "command":            "pcheetah",
 "sdk":     "org.kde.Sdk",
 "runtime": "org.kde.Platform",
 "runtime-version":          "6.6",
 "modules": [
  {
   "name": "initme",
   "buildsystem": "cmake-ninja",
   "config-opts": ["-DCMAKE_BUILD_TYPE=Release"],
   "sources": [
    {"type": "dir", "path": "initme"},
    {"type": "dir", "path": "../stv", "dest": "stv"}
   ]
  },
  {
   "name": "pcheetah",
   "buildsystem": "cmake-ninja",
   "config-opts": ["-DCMAKE_BUILD_TYPE=Release"],
   "sources": [
    {"type": "dir", "path": "pcheetah"},
    {"type": "dir", "path": "../stv", "dest": "stv"}
   ]
  }
 ],
 "finish-args": [
  "--share=ipc",
  "--socket=x11",
  "--socket=wayland",
  "--filesystem=host",
  "--device=dri"
 ]
}

So now my stv common .h and .cpp dir is put into the build dir in dir “stv” which my code can reference. It was jamming em all into the same dir but that “dest” argument (which seems to be nowhere in the flatpak docs, right?) fixes everything for me. cmake built initme !! (then died with pcheetah but i can get that fixed)

This unfortunately changes my source code’s include lines, but oh well, at least I’m back on track and can try to fix that later.

It strikes me that the flatpak docs just are not there yet.
But I guess linux devs enjoy junk like that or somethin?
I’m new to linux (used to be a windows dev but windowsupdate drove me away).
So my assessment of linux devs could be wrong :confused:

Ok - thanks much !