Building my first flatpak

It did just as much when I did have the file, but it simply refuses to tell me where it want/expects that file.
Anything that want to be that cryptic and depends on mind-reading, is just not for me :frowning:

That file needs to be in the bin inside your app folder.

So in /app/bin inside of your flatpak

That is good to know.
Still, I am thinking that if I wanted to port a C++ app to Linux, I should not have to install all of the flatpak project on my machine just to allow me to look behind the ‘curtain’ so that I can decipher the built-in secret passages and places.
I do have a CMake project which builds the app without a problem, but that same CMake project proves indigestible to flatpak and just labeling something a ‘cmake’ build-system is a bit deceptive :frowning:
It would se.em I might as well recommend a virtual box running some version of Windows and have my app installed there.
I understand you are trying to help me and I very much appreciate that. :+1:

The source you have posted fails on a missing install command due to your makefile. Don’t think that’s a flatpak problem.

We discussed the missing ‘install’ target, which I added several days back, but that did not help, if only because I have no idea where to install what.
Just having a target is pointless, unless it points to the right place for the expected data and I have not seen any helpful feedback on that from flatpak, I’m sorry.

I see that keepassxc uses cmake’s CMAKE_INSTALL_BINDIR variable to tell them where to put their binaries. (the variable they defined is later used here)

Some more on this here:
https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html

If you don’t need to install just set no-make-install: true as mentioned in the man page Flatpak Builder Command Reference - Flatpak documentation

I do appreciate all your help.
Unfortunately, by now, I am so far down the frustration rabbit hole with my manifest file in shambles because of all the failed attempts at making progress, that I will have to start all over.
FWIW, looking through the Flatpak site and selecting the CMake projects to browse through

I see only 4 CMake projects, and I did not find anything helpful there

@razzeee: eventually I will have to install the results, so sooner or later I will have to sort that part out in any case. For a start I will disable the ‘install’ part.

I have setup my own local git repo to make it easier to move back and forth, but when nothing seems to work and one does not make any positive progress, it is hard to spend the time to document exactly what did NOT work just because there is so much of that.

More like 500 according to Code search results · GitHub but that includes cmake-ninja (which is still cmake I guess) and there are some module builds.

Correct, but you probably don’t want to do that from the makefile in the case of the flatpak build, but that’s just my gut feeling

Understandable, same happens to me

By now, having started over, I have the following install script:

#!/bin/bash

# Install flatpak-builder - already installed on Mint
#sudo apt -y install flatpak-builder


# Create Manifest file
cat > org.cmlife.cmlife.yml  <<EOL
app-id: org.cmlife.cmlife
runtime: org.freedesktop.Platform
runtime-version: '22.08'
sdk: org.freedesktop.Sdk
command: life
#rename-icon: life
#rename-desktop-file: life.desktop

finish-args:
  - --socket=fallback-x11
  - --socket=wayland
  - --share=ipc
#  - --filesystem=xdg-documents
#  - --env=PWS_HELPDIR=/app/share/passwordsafe/help/

modules:
# Note: the order of modules is important as the builder works its way
# in a linear fashion - any dependencies need to be satisfied when 
# the process tries to build a module

  - name: wxwidgets
    rm-configure: true
    config-opts:
      - --with-libpng
      - --with-zlib
      - --with-cxx=14
      - --disable-sdltest
      - --disable-webview
      - --disable-webviewwebkit
      - --disable-ribbon
      - --disable-propgrid
      - --disable-richtext
      - --with-expat=builtin
      - --with-libiconv=/usr
    cleanup:
#      - /bin
#      - /include
#      - /lib/cmake
#      - /lib/wx
#      - /share

    sources:
#      - type: git   # from: https://github.com/flathub/org.audacityteam.Audacity/blob/master/org.audacityteam.Audacity.yaml
#        url: https://github.com/wxWidgets/wxWidgets.git
#        tag: v3.1.5
        
      - type: archive
        url: https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2.1/wxWidgets-3.2.2.1.tar.bz2
        sha256: dffcb6be71296fff4b7f8840eb1b510178f57aa2eb236b20da41182009242c02
        x-checker-data:
          type: anitya
          project-id: 5150
          stable-only: true
          url-template: https://github.com/wxWidgets/wxWidgets/releases/download/v/wxWidgets-.tar.bz2

  - name: life
    buildsystem: cmake-ninja
    #buildsystem: cmake
    config-opts:
      - -DCMAKE_BUILD_TYPE=RelWithDebInfo
#      - -DCMAKE_INSTALL_LIBDIR=/app/lib
#      - -DAUDACITY_BUILD_LEVEL=2
#      - -Dgtk=gtk+-3.0
#      - -Dglib=glib-2.0
      - -DwxWidgets_INCLUDE_DIRS=/app/include/wx-3.1;/app/lib/wx/include/gtk3-unicode-3.1
      - -DwxWidgets_CXX_FLAGS=-pthread
#      - -DwxWidgets_DEFINITIONS_GENERAL=WXUSINGDLL;__WXGTK__;_FILE_OFFSET_BITS=64
      - -DwxWidgets_LIBRARIES=-lwx_gtk3u_xrc-3.1;-lwx_gtk3u_html-3.1;-lwx_gtk3u_qa-3.1;-lwx_gtk3u_core-3.1;-lwx_baseu_xml-3.1;-lwx_baseu_net-3.1;-lwx_baseu-3.1
#      -DCMAKE_INSTALL_PREFIX="/app/bin"
#      -DFLATPAK=ON
#      -DCMAKE_BUILD_TYPE="Release"
#      -DBUILD_SHARED=OFF
    sources:
      - type: "dir"
        path: "../"

EOL

# Build flatpak
#flatpak-builder -v --force-clean build-dir --disable-cache org.cmlife.cmlife.yml
f#latpak-builder --user --verbose  --build-only --force-clean build-dir   org.cmlife.cmlife.yml
flatpak-builder --user --verbose --force-clean build-dir   org.cmlife.cmlife.yml

#flatpak-builder --verbose --force-clean build-dir   org.cmlife.cmlife.yml
## install locally
#flatpak-builder --verbose --install  --build-only --force-clean build-dir   org.cmlife.cmlife.yml
## show manifest only
#flatpak-builder --verbose --show-manifest org.cmlife.cmlife.yml

with a lot of unused junk, but I don’t want to strip to avoid error.
Same goes for the current base CMakelists.txt


#############################################################################
# Name:        life CMakeListst.txt
# Purpose:     CMake file for the life demo to be the base for the Cross-platform
#              template following the example from:
#              https://www.justdevtutorials.com/post/wxwidgets-cmake/
# Author:      A. Wiegert
# Created:     2018-03-22
# Copyright:   (c) 2018  A. Wiegert
# Licence:     wxWidgets licence
# using the ideas from:
# https://crascit.com/2016/01/31/enhanced-source-file-handling-with-target_sources/
#############################################################################

#
# This file is was derived from both the minimal example CMake file
# wxBUILD_SAMPLES option when using cmake on the library
# as well as the template from D:\pkg\cmake\tmplt\wx_cmake_template
#

# Declare the minimum required CMake version
# Note Windows version is much higher
cmake_minimum_required(VERSION 3.6 FATAL_ERROR )

# Name the project
project(life LANGUAGES CXX )
# set global variables
# see also: https://matgomes.com/setting-cpp-standard-cmake/
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS Off)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static" )

# if these are uncommented, 'life ' is built in 
# /home/arnold/Public/flatpak/flcmlife/flatpak/build-dir/files/bin
# but will not run - seems to link dynamically
#arnold@CarboMint:~/Public/flatpak/flcmlife/flatpak/build-dir/files/bin$ ./life
#./life: error while loading shared libraries: libwx_baseu-3.2.so.0: cannot open shared object file: No such file or directory
#arnold@CarboMint:~/Public/flatpak/flcmlife/flatpak/build-dir/files/bin$ 
if( NOT CMAKE_BUILD_TYPE )
  set( CMAKE_BUILD_TYPE Release )
endif( NOT CMAKE_BUILD_TYPE )

add_definitions(-DwxUSE_UNICODE -DwxUNICODE)
# NEEDS '/' rather than '\\'
# NO trailing '/' 
# seems CMake does not like to have both defined
set( wxWidgets_ROOT_DIR "D:/MSVC2022/wxWidgets-3.2.2" )
set( wxWidgets_LIB_DIR  "D:/MSVC2022/wxWidgets-3.2.2/lib" )

# Request the required wxWidgets libs
find_package(wxWidgets 3.2 COMPONENTS adv aui base core html media net qa stc xml xrc REQUIRED)

IF(wxWidgets_FOUND)
  MESSAGE(  "wxWidgets 3.2.1 found!")
ELSE(wxWidgets_FOUND)
   # For convenience. When we cannot continue, inform the user
   MESSAGE( FATAL_ERROR "wxWidgets 3.2.1  not found!")
ENDIF(wxWidgets_FOUND)

# Include the wxWidgets use file to initialize various settings
# created by the find_wxWidgets process????
if(wxWidgets_USE_FILE)
  include( ${wxWidgets_USE_FILE} )
endif()

# Define a variable containing a list of source files for the project
set(SRC_FILES
    life.cpp
    game.cpp
    dialogs.cpp
    reader.cpp
    )

set ( HEADERS
    life.h
    game.h
    dialogs.h
    )
if(WIN32)
    # Include a RC file for windows
    list(APPEND SRC_FILES life.rc) 
endif()

# Define the build target for the executable
if(APPLE)
    # create bundle on apple compiles
    add_executable(main MACOSX_BUNDLE ${SRCS})

    # Set a custom plist file for the app bundle - needed for Mac OS Retina display
    set_target_properties(main PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
else()
    # the WIN32 is needed for Windows in order for it to look for WinMain
    # instead of the main function. This is ignored on other systems,
    # so it works on all platforms
    add_executable(${PROJECT_NAME} WIN32 ${SRC_FILES} ${HEADERS} )
    set_property(TARGET ${PROJECT_NAME} PROPERTY
       MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

#add_executable(${PROJECT_NAME} WIN32 ${SRC_FILES} ${HEADERS})
#set_property(TARGET ${PROJECT_NAME} PROPERTY
#    MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
 

# Link required libraries to the executable
if(WIN32)
#target_link_libraries(${PROJECT_NAME}  libcurl)
#target_link_libraries(${PROJECT_NAME} winhttp)
endif()

target_link_libraries( ${PROJECT_NAME} ${wxWidgets_LIBRARIES} -static)

install( TARGETS life 
  RUNTIME
  CONFIGURATIONS release
  DESTINATION "bin" )

# --------------------------- eof ------------------------

Some of the options I have copied from one of the public wxWidgets projects Audacity and most seem unused in any case - surprisingly detected and spelled out in the builder output.
Again, linking the final executable fails because the linker can’t find the wxWidgets libraries


[5/5] Linking CXX executable life
FAILED: life 
: && /usr/bin/c++ -O2 -g -pipe -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 -pthread -pthread -O2 -g -DNDEBUG -static CMakeFiles/life.dir/life.cpp.o CMakeFiles/life.dir/game.cpp.o CMakeFiles/life.dir/dialogs.cpp.o CMakeFiles/life.dir/reader.cpp.o -o life  -L/app/lib  -pthread  -lwx_gtk3u_aui-3.2  -lwx_baseu-3.2  -lwx_gtk3u_core-3.2  -lwx_gtk3u_html-3.2  -lwx_gtk3u_media-3.2  -lwx_baseu_net-3.2  -lwx_gtk3u_qa-3.2  -lwx_gtk3u_stc-3.2  -lwx_baseu_xml-3.2  -lwx_gtk3u_xrc-3.2  -static && :
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lwx_gtk3u_aui-3.2: No such file or directory
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lwx_baseu-3.2: No such file or directory
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lwx_gtk3u_core-3.2: No such file or directory
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lwx_gtk3u_html-3.2: No such file or directory
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lwx_gtk3u_media-3.2: No such file or directory
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lwx_baseu_net-3.2: No such file or directory
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lwx_gtk3u_qa-3.2: No such file or directory
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lwx_gtk3u_stc-3.2: No such file or directory
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lwx_baseu_xml-3.2: No such file or directory
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lwx_gtk3u_xrc-3.2: No such file or directory
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: cannot find -lm: No such file or directory
collect2: error: ld returned 1 exit status

The question this raises right now:

  • the builder does find the wxWidgets libraries, but the linker cannot. Why?
    possibly because CMake uses a findwxWidgets function and does find the libraries
  • how do I tell flatpak builder where to find these libraries