Glib-object.h No such file or directory


I am attempting to build a snap using the cmake plugin, but the glib header file does not appear to be included in the CMakeList.txt. I would prefer to not modify the build file directly, and I’ve installed libglib2.0-dev which includes the header file as seen below. Is there a cmake parameter that I can use to include the correct header files?

:: [  2%] Building CXX object src/helper/CMakeFiles/corectrl_helper.dir/polkit.cpp.o        
:: In file included from /usr/include/polkit-1/polkit/polkit.h:27,                          
::                  from /root/parts/corectrl/src/src/helper/polkit.cpp:7:                  
:: /usr/include/polkit-1/polkit/polkittypes.h:25:10: fatal error: glib-object.h: No such file or directory                                                                               
::    25 | #include <glib-object.h>                                                         
::       |          ^~~~~~~~~~~~~~~                                                         
:: compilation terminated.                                                                  
:: gmake[2]: *** [src/helper/CMakeFiles/corectrl_helperkiller.dir/build.make:104: src/helper/CMakeFiles/corectrl_helperkiller.dir/polkit.cpp.o] Error 1                                  
:: gmake[1]: *** [CMakeFiles/Makefile2:254: src/helper/CMakeFiles/corectrl_helperkiller.dir/all] Error 2                                                                                 
:: gmake[1]: *** Waiting for unfinished jobs....                                            
:: In file included from /usr/include/polkit-1/polkit/polkit.h:27,                          
::                  from /root/parts/corectrl/src/src/helper/polkit.cpp:7:                  
:: /usr/include/polkit-1/polkit/polkittypes.h:25:10: fatal error: glib-object.h: No such file or directory                                                                               
::    25 | #include <glib-object.h>                                                         
::       |          ^~~~~~~~~~~~~~~                                                         
:: compilation terminated.                                                                  
:: gmake[2]: *** [src/helper/CMakeFiles/corectrl_helper.dir/build.make:104: src/helper/CMakeFiles/corectrl_helper.dir/polkit.cpp.o] Error 1                                              
:: gmake[1]: *** [CMakeFiles/Makefile2:280: src/helper/CMakeFiles/corectrl_helper.dir/all] Error 2                                                                                       
:: Consolidate compiler generated dependencies of target corectrl_lib                       
:: [ 88%] Built target corectrl_lib                                                         
:: gmake: *** [Makefile:136: all] Error 2                                                   
Failed to run the build script for part 'corectrl'.                                         
Launching shell on build environment...                                                     
snapcraft-ryujinx-on-amd64-for-amd64-7865019 ../project# ls /root/parts/corectrl/install/usr/include/glib-2.0/glib-object.h 

how exactly did you do this … preferably you want that package name listed in your build-packages: so it gets dynamically added to your build environment …

Ya that is what I have as seen here. Would this be a package bug then?

is there an particular reason you override DCMAKE_PREFIX_PATH instead of letting snapcraft set it or simply have your project use the default ?

That was a workaround for an issue that I faced with libqt5charts5-dev as cmake was not detecting it correctly

CMake Error at /snap/kde-frameworks-5-102-qt-5-15-8-core22-sd/current/usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:28 (find_package):
  Could not find a package configuration file provided by "Qt5Charts" with
  any of the following names:
  Add the installation prefix of "Qt5Charts" to CMAKE_PREFIX_PATH or set
  "Qt5Charts_DIR" to a directory containing one of the above files.  If
  "Qt5Charts" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:36 (find_package)
-- Configuring incomplete, errors occurred!

@orga do you have any thoughts on that?

According to the documentation, that path looks incorrect

You want something like (but I don’t see a reason for you to need to override it):

I am not sure why the errors occur within the cmake project itself, but as a general comment, I would remove all the -dev packages in stage-packages and put them in build-packages. If it still fails, you can always set CFLAGS with pkg-config manually.

After defining, DCMAKE_SYSTEM_PREFIX_PATH, I unfortunately run into the same issue, but now with a bunch of warnings related to duplicate libs. The kf5-5-105-qt-5-15-9-core22-sdk snap includes that header file as well, but for whatever reason, its not getting included.

It appears that this issue is resolved on the edge channel of snapcraft.

Turns out there was an issue with the the file path having additional characters appended to it: /build/snapcraft-kf5-5-105-qt-5-15-9-core22-sdk-2e7900f550f8a72051821685f02618e0/