I'm trying to cross compile webkit.
In my toolchain file I set:
set(CMAKE_SYSROOT "/opt/cross-pi-gcc/arm-linux-gnueabihf/sysroot")
During configuration I specify the install dir
-DCMAKE_INSTALL_PREFIX:PATH=/opt/cross-pi-gcc/arm-linux-gnueabihf/sysroot/usr
One of the CMakeLists of the package generate a pkg-config *.PC file which contains:
prefix=/opt/cross-pi-gcc/arm-linux-gnueabihf/sysroot/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: wpe-1.0
Description: The wpe library
Version: 1.8.0
Requires: xkbcommon
Cflags: -I${includedir}/wpe-1.0
Libs: -L${libdir} -lwpe-1.0
This is wrong, the pkg-config cflags should point to /usr on the target not the sysroot path.
The source of the pkgconfig file, which is edited using cmake's configure_file:
prefix=#CMAKE_INSTALL_PREFIX#
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: wpe-#WPE_API_VERSION#
Description: The wpe library
Version: #PROJECT_VERSION#
Requires: xkbcommon
Cflags: -I${includedir}/wpe-#WPE_API_VERSION#
Libs: -L${libdir} -lwpe-#WPE_API_VERSION#
Am I using CMAKE_INSTALL_PREFIX correctly? Or can it be somehow relative CMAKE_SYSROOT?
Related
CMake complains about "No package 'systemd' found" though I have installed systemd on docker container of Ubuntu 20.04. Why cmake is not able to detect the installed pkg
root#e8208b70072e:/opt/dev/sysrepo/build# cmake ..
-- ietf-yang-library revision: 2019-01-04
-- Sysrepo repository: /etc/sysrepo
-- Startup data path: /etc/sysrepo/data
-- Notification path: /etc/sysrepo/data/notif
-- YANG module path: /etc/sysrepo/yang
-- SR plugins path: /usr/local/lib/sysrepo/plugins
-- SRPD plugins path: /usr/local/lib/sysrepo-plugind/plugins
Package systemd was not found in the pkg-config search path.
Perhaps you should add the directory containing `systemd.pc'
to the PKG_CONFIG_PATH environment variable
No package 'systemd' found
-- Could NOT find LibSystemd (missing: SYSTEMD_UNIT_DIR)
CMake Warning at CMakeLists.txt:349 (message):
Disabling sysrepo-plugind systemd support because libsystemd was not found.
-- Configuring done
-- Generating done
-- Build files have been written to: /opt/dev/sysrepo/build
Installed files can be seen below
root#e8208b70072e:/opt/dev# find / -name *libsystemd*
/var/lib/dpkg/info/libsystemd0:amd64.md5sums
/var/lib/dpkg/info/libsystemd0:amd64.shlibs
/var/lib/dpkg/info/libsystemd0:amd64.symbols
/var/lib/dpkg/info/libsystemd0:amd64.list
/var/lib/dpkg/info/libsystemd0:amd64.triggers
/var/lib/dpkg/info/libsystemd-dev:amd64.md5sums
/var/lib/dpkg/info/libsystemd-dev:amd64.list
/usr/share/doc/libsystemd0
/usr/share/doc/libsystemd-dev
/usr/lib/x86_64-linux-gnu/libsystemd.so.0
/usr/lib/x86_64-linux-gnu/libsystemd.so.0.28.0
/usr/lib/x86_64-linux-gnu/libsystemd.so
/usr/lib/x86_64-linux-gnu/pkgconfig/libsystemd.pc
I have a C project using meson.
The meson file looks like this:
project('camtool', 'c', version : '0.0.1',default_options : ['c_std=c11'])
cxx = meson.get_compiler('c')
systemd_dep = cxx.find_library('systemd')
pthread_dep = cxx.find_library('pthread')
inc = include_directories('include')
subdir('include')
subdir('src')
executable('camtool', './src/test.c',
include_directories : inc,
dependencies : [systemd_dep,pthread_dep])
and my src/test.c looks like this:
#include <stdio.h>
int main() {
// printf() displays the string inside quotation
printf("Hello, World!")
return 0;
}
The output of meson build is:
DEPRECATION: c_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.
DEPRECATION: c_link_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.
DEPRECATION: cpp_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.
DEPRECATION: cpp_link_args in the [properties] section of the machine file is deprecated, use the [built-in options] section.
Using 'PKG_CONFIG_PATH' from environment with value: '/opt/poky/3.1.6/sysroots/znver1-poky-linux/usr/lib/pkgconfig:/opt/poky/3.1.6/sysroots/znver1-poky-linux/usr/share/pkgconfig'
The Meson build system
Version: 0.56.0
Source dir: /workspaces/quark-v4l2
Build dir: /workspaces/quark-v4l2/build
Build type: cross build
Project name: camtool
Project version: 0.0.1
Using 'CFLAGS' from environment with value: ' -O2 -pipe -g -feliminate-unused-debug-types '
Using 'LDFLAGS' from environment with value: '-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -fstack-protector-strong -Wl,-z,relro,-z,now'
Using 'CPPFLAGS' from environment with value: ''
C compiler for the host machine: x86_64-poky-linux-gcc -m64 -march=znver1 -mno-fma -mno-avx -mno-f16c -mno-rdrnd -mno-avx2 -mno-prfchw -mno-bmi -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/poky/3.1.6/sysroots/znver1-poky-linux (gcc 9.3.0 "x86_64-poky-linux-gcc (GCC) 9.3.0")
C linker for the host machine: x86_64-poky-linux-gcc -m64 -march=znver1 -mno-fma -mno-avx -mno-f16c -mno-rdrnd -mno-avx2 -mno-prfchw -mno-bmi -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/opt/poky/3.1.6/sysroots/znver1-poky-linux ld.bfd 2.34.0.20200220
C compiler for the build machine: cc (gcc 8.3.0 "cc (Debian 8.3.0-6) 8.3.0")
C linker for the build machine: cc ld.bfd 2.31.1
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: x86_64
Target machine cpu: x86_64
Library systemd found: YES
Library pthread found: YES
Build targets in project: 1
Found ninja-1.10.0 at /opt/poky/3.1.6/sysroots/x86_64-pokysdk-linux/usr/bin/ninja
After i run meson build, i run find . | grep camtool but it does not find the binary.
Where do i find the binary produced by meson?
Okay, i found out the reason is i misunderstood some steps in meson.
Meson build seems to be a build setting generating the build folder, but not actually building anything.
To make it build, i had to run ninja from the build directory.
Running ninja gave me an error, as my test.c was missing a semicolon.
After adding the semicolon and rerunning ninja, the binary was produced
I'm trying to build celluloid, which uses meson. I ran meson, but it failed to find an appropriate version of mpv:
Determining dependency 'mpv' with pkg-config executable '/usr/bin/pkg-config'
Called `/usr/bin/pkg-config --modversion mpv` -> 1
Found CMake: /usr/bin/cmake (3.13.4)
Determining dependency 'mpv' with CMake executable '/usr/bin/cmake'
Try CMake generator: auto
Called `/usr/bin/cmake --trace-expand -DNAME=mpv .` in /tmp/celluloid-0.20/build/meson-private/cmake_mpv -> 0
Dependency mpv found: NO (tried pkgconfig and cmake)
src/meson.build:125:0: ERROR: Dependency "mpv" not found, tried pkgconfig and cmake
so I downloaded and built the latest mpv release (0.33.0), built and installed it at /opt/mpv.
Now - how do I tell meson to take mpv from this new path?
Note: The relevant snippet of the meson files seems to be:
executable('celluloid', sources,
dependencies: [
libgtk,
libgio,
meson.get_compiler('c').find_library('m', required: false),
dependency('mpv', version: '>= 1.107'),
dependency('epoxy')
],
link_with: extra_libs,
include_directories: includes,
c_args: cflags,
install: true
)
You tell meson about your dependency by letting pkgconfig know about your dependency...
and that can be done by adding your dependency's path to the PKG_CONFIG_PATH environment variable; it is delimited by colons, just like PATH, e.g. /opt/foo:/opt/extra/baz.
Remember that you may also need to add associated paths to LD_LIBRARY_PATH after building and installing with a custom-built directory.
I'm building CMake 3.12.4 from the release tarball on AIX. CMake is failing to link on the machine:
ld: 0711-781 ERROR: TOC overflow. TOC size: 65632 Maximum size: 65536
The error is detailed in the IBM technotes at ld: 0711-781 ERROR: TOC overflow. I want to add -bbigtoc linker option for the cmake recipe.
CMake's bootstrap does not appear to accept linker options for LDFLAGS as shown below.
How do I add a linker flag to the bootstrap process?
Here are the options CMake bootstrap accepts:
$ ./bootstrap --help
Usage: ./bootstrap [<options>...] [-- <cmake-options>...]
Options: [defaults in brackets after descriptions]
Configuration:
--help print this message
--version only print version information
--verbose display more information
--parallel=n bootstrap cmake in parallel, where n is
number of nodes [1]
--enable-ccache Enable ccache when building cmake
--init=FILE load FILE as script to populate cache
--system-libs use all system-installed third-party libraries
(for use only by package maintainers)
--no-system-libs use all cmake-provided third-party libraries
(default)
--system-curl use system-installed curl library
--no-system-curl use cmake-provided curl library (default)
--system-expat use system-installed expat library
--no-system-expat use cmake-provided expat library (default)
--system-jsoncpp use system-installed jsoncpp library
--no-system-jsoncpp use cmake-provided jsoncpp library (default)
--system-zlib use system-installed zlib library
--no-system-zlib use cmake-provided zlib library (default)
--system-bzip2 use system-installed bzip2 library
--no-system-bzip2 use cmake-provided bzip2 library (default)
--system-liblzma use system-installed liblzma library
--no-system-liblzma use cmake-provided liblzma library (default)
--system-libarchive use system-installed libarchive library
--no-system-libarchive use cmake-provided libarchive library (default)
--system-librhash use system-installed librhash library
--no-system-librhash use cmake-provided librhash library (default)
--system-libuv use system-installed libuv library
--no-system-libuv use cmake-provided libuv library (default)
--qt-gui build the Qt-based GUI (requires Qt >= 4.2)
--no-qt-gui do not build the Qt-based GUI (default)
--qt-qmake=<qmake> use <qmake> as the qmake executable to find Qt
--sphinx-info build Info manual with Sphinx
--sphinx-man build man pages with Sphinx
--sphinx-html build html help with Sphinx
--sphinx-qthelp build qch help with Sphinx
--sphinx-build=<sb> use <sb> as the sphinx-build executable
--sphinx-flags=<flags> pass <flags> to sphinx-build executable
Directory and file names:
--prefix=PREFIX install files in tree rooted at PREFIX
[/usr/local]
--bindir=DIR install binaries in PREFIX/DIR
[bin]
--datadir=DIR install data files in PREFIX/DIR
[share/cmake-3.12]
--docdir=DIR install documentation files in PREFIX/DIR
[doc/cmake-3.12]
--mandir=DIR install man pages files in PREFIX/DIR/manN
[man]
--xdgdatadir=DIR install XDG specific files in PREFIX/DIR
[share]
Here is the CMake link error:
cmake_build$ make VERBOSE=1
...
[ 91%] Linking CXX executable ../bin/cmake
cd /home/noloader/cmake_build/Source && /home/noloader/cmake_build/Boots
trap.cmk/cmake -E cmake_link_script CMakeFiles/cmake.dir/link.txt --verbose=1
/usr/bin/g++ -pthread -Wl,-bnoipath -Wl,-brtl -Wl,-bexpall CMakeFiles/cmake.dir
/cmakemain.cxx.o CMakeFiles/cmake.dir/cmcmd.cxx.o -o ../bin/cmake -Wl,-blibpath
:/opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/4.8.1/pthread:/opt/freeware/lib/pt
hread:/opt/freeware/lib/gcc/powerpc-ibm-aix7.1.0.0/4.8.1:/opt/freeware/lib:/usr/
lib:/lib libCMakeLib.a libCMakeServerLib.a libCMakeLib.a kwsys/libcmsys.a ../Uti
lities/cmexpat/libcmexpat.a ../Utilities/cmlibarchive/libarchive/libcmlibarchive
.a ../Utilities/cmliblzma/libcmliblzma.a ../Utilities/cmbzip2/libcmbzip2.a ../Ut
ilities/cmcompress/libcmcompress.a ../Utilities/cmcurl/lib/libcmcurl.a ../Utilit
ies/cmzlib/libcmzlib.a -lld ../Utilities/cmjsoncpp/libcmjsoncpp.a ../Utilities/c
mlibuv/libcmlibuv.a -lperfstat ../Utilities/cmlibrhash/libcmlibrhash.a
ld: 0711-781 ERROR: TOC overflow. TOC size: 65632 Maximum size: 65536
collect2: error: ld returned 12 exit status
make: 1254-004 The error code from the last command is 1.
Something like this:
export CFLAGS=...
export CXXFLAGS=...
export LDFLAGS='... -Wl,-bbigtoc'
./bootstrap ... --verbose
make VERBOSE=1 all
Also you might want to read this: http://lzsiga.users.sourceforge.net/aix-linking.html#Q0025
I am trying to build a project through a cmake generated make, where one necessary header file is /usr/local/include/poppler/poppler-config.h. However
export INCLUDE_PATH=/usr/local/include/poppler/
nor
export INCLUDE_PATH=/usr/local/include/ help, and I still get:
fatal error: poppler-config.h: No such file or directory.
What could I be missing?
I already have a pkg-config file for this dependency, which looks okay:
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: poppler
Description: PDF rendering library
Version: 0.33.0
Libs: -L${libdir} -lpoppler
Cflags: -I${includedir}/poppler
But adding it to a PKG_CONFIG_PATH environment variable doesn't help either.
Is there some cmake cache to reset for this? what should be an elegant solution?