I have a project that I'm trying to build on an arm64 architecture. I'm on Ubuntu 18.04, so I use qemu to cross-build. I'm using the following instructions to emulate an arm64 environment :
sudo apt-get install debootstrap qemu-user-static schroot
sudo qemu-debootstrap --arch=arm64 bionic arm64-ubuntu
echo "[arm64-ubuntu]
description=Ubuntu 16.04 Xenial (arm64)
directory=$(pwd)/arm64-ubuntu
root-users=$(whoami)
users=$(whoami)
type=directory" | sudo tee /etc/schroot/chroot.d/arm64-ubuntu
schroot -c arm64-ubuntu -u root
It works, and when I'm in the emulated environment I can then install all I need with the following commands :
add-apt-repository universe
add-apt-repository "deb http://ports.ubuntu.com/ubuntu-ports bionic-updates main universe"
apt update && apt full-upgrade
sudo apt install cmake pkg-config libglib2.0-dev libgstreamer1.0-dev libgstrtspserver-1.0-dev
Again, it works and everything seems to install normally. But then when I run :
cmake ..
I get the following error :
(arm64-ubuntu)root@me-mypc:/home/me/Projets/embedded/vespa/build# cmake ..
-- Configuring done
CMake Error in CMakeLists.txt:
Imported target "PkgConfig::gst" includes non-existent path
"/usr/lib/x86_64-linux-gnu/glib-2.0/include"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
CMake Error in CMakeLists.txt:
Imported target "PkgConfig::gst" includes non-existent path
"/usr/lib/x86_64-linux-gnu/glib-2.0/include"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
-- Generating done
-- Build files have been written to: /home/me/Projets/embedded/vespa/build
As the files have been built anyway I can still try to make the package :
make package
But the I get an error saying :
(arm64-ubuntu)root@me-mypc-5590:/home/me/Projets/embedded/vespa/build# make package
Scanning dependencies of target vespa
[ 50%] Building C object CMakeFiles/vespa.dir/src/main.c.o
In file included from /usr/include/glib-2.0/glib/galloca.h:32:0,
from /usr/include/glib-2.0/glib.h:30,
from /usr/include/glib-2.0/gobject/gbinding.h:28,
from /usr/include/glib-2.0/glib-object.h:23,
from /usr/include/glib-2.0/gio/gioenums.h:28,
from /usr/include/glib-2.0/gio/giotypes.h:28,
from /usr/include/glib-2.0/gio/gio.h:26,
from /home/path_to_project/src/main.c:3:
/usr/include/glib-2.0/glib/gtypes.h:32:10: fatal error: glibconfig.h: No such file or directory
#include <glibconfig.h>
^~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/vespa.dir/build.make:62: recipe for target 'CMakeFiles/vespa.dir/src/main.c.o' failed
make[2]: *** [CMakeFiles/vespa.dir/src/main.c.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/vespa.dir/all' failed
make[1]: *** [CMakeFiles/vespa.dir/all] Error 2
Makefile:151: recipe for target 'all' failed
make: *** [all] Error 2
Unless I'm wrong, it would seem that the cmake error prevents the project to build correctly. So I think the error comes from there. And indeed when I try to check if the glib2.0 lib has been correctly installed, I can see that there is no /usr/lib/x86_64-linux-gnu/ directory. I don't understand why this directory isn't automatically created with the emulated environment. I tried to create it by installing gcc manually but even then the dependancies aren't installed in it. I even tried to copy manually all the required dependancies, and it partially worked, as the cmake command succeeded, but the make command failed, saying it lacked libraries that were installed.
Here is the CMakeLists I'm using :
cmake_minimum_required(VERSION 3.10)
project(
vespa
VERSION 0.2.0
LANGUAGES C
)
find_package(PkgConfig)
pkg_check_modules(
gst REQUIRED IMPORTED_TARGET
gstreamer-1.0
gstreamer-rtsp-server-1.0
gstreamer-rtsp-1.0
)
pkg_check_modules(
glib REQUIRED IMPORTED_TARGET
glib-2.0
)
add_executable(
vespa
src/main.c
)
target_link_libraries(
vespa
PUBLIC
m
PkgConfig::gst
PkgConfig::glib
)
install(
TARGETS vespa
DESTINATION bin
)
set_property(TARGET vespa PROPERTY VERSION ${vespa_VERSION})
set_property(TARGET vespa PROPERTY SOVERSION ${vespa_VERSION_MAJOR})
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libgstrtspserver-1.0-0 (>= 1.14.0-1)")
include(CPack)
I know the error doesn't come from the files I use, or from the commands I'm using, as it worked for everyone else who tried it.
I don't understand what makes it fail on my pc.
************** EDIT ***************
The comments from Tarmo (thank you) made me look in another direction and I think I understand the problem better.
As I said, when trying to run :
cmake ..
CMake tells me it tries to find "/usr/lib/x86_64-linux-gnu/glib-2.0/include". Which doesn't exist, because in this emulated arm64 environment, an x86_64 path doesn't exist.
So I tried to locate the glib using :
pkg-config --cflags glib-2.0
And it returned :
-I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include
Which seems logic to me, in an arm64 environment.
So it would seem pkg-config locates glib correctly in cmd line, but not when used in the CMakeLists. I don't understand why.