Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

CMake cross compiler problem with pkg_check_modules for some packages

Hello!

Introduction

I'm trying to cross compile opencv trough crosstool-ng, and I'm having problems, I cannot good compile it (I can compile It but without GTK2, when I try to find the neccesary packages (GTK2 in this case), cmake cannot find them.

Test through find_package

To understand what is happening, I run a test of my own CMakeList.txt (CMakeLists.txt) with my toolchain.cmake file, and the results are:

find_package( GTK2 REQUIRED ),

=> Found

Also, if I try from the terminal:

cmake -DCMAKE_TOOLCHAIN_FILE=~/x-tools/my-toolchain.cmake --find-package -DNAME=GTK2 -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST

=> GTK2 found.

Test through pkg_check_modules

Then the method find_package seems to work, but OpenCV uses pkg_check_modules (another method using .pc files) I made a CMakeLists.txt with the function:

find_package(PkgConfig)

pkg_check_modules (GTK2 glib-2.0)

message("${PKG_CONFIG_FOUND}")

=> Not found

Additional content:

The CMakeLists.txt of openCV uses internally pkg_check_modules, and as I can see, it doesn't work. In my computer, CMake can find and stand for some libraries but not for all, I'm having problems with pkg_check_modules. Also, if I try with another libraries, I can find them (as example, GLib). Both gtk+-2.0.pc and glib-2.0.pc files are in the same directory, and the final libraries are in the same destination folder, by that, I don't think that is a PATH configuration error. I cannot hardcode them because I need to cross compile more packages later

If I run these tests on target, I can find all packages (and all files on the next directories are synced), also I have repaired the incorrect symbolic links

/lib /usr/include /usr/lib /usr/local/include /usr/local/lib /usr/share/pkg-config

In my toolchain.cmake file:

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/lib/aarch64-linux-gnu/pkgconfig" )

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/share/pkgconfig" )

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/lib/pkgconfig" )

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/opt/ocv/lib/pkgconfig" )

And the contents of my .pc files

$ find . -name glib-2.0.pc

./usr/lib/aarch64-linux-gnu/pkgconfig/glib-2.0.pc

$ find . -name gtk+-2.0.pc

./usr/lib/aarch64-linux-gnu/pkgconfig/gtk+-2.0.pc

And it contents: $ cat glib-2.0.pc prefix=/usr exec_prefix=${prefix} libdir=${prefix}/lib/aarch64-linux-gnu includedir=${prefix}/include

glib_genmarshal=glib-genmarshal gobject_query=gobject-query glib_mkenums=glib-mkenums

Name: GLib Description: C Utility Library Version: 2.48.2 Requires.private: libpcre Libs: -L${libdir} -lglib-2.0 Libs.private: -pthread -lpcre
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include

cat gtk+-2.0:

prefix=/usr exec_prefix=${prefix} libdir=/usr/lib/aarch64-linux-gnu includedir=${prefix}/include target=x11

gtk_binary_version=2.10.0 gtk_host=aarch64-unknown-linux-gnu

Name: GTK+ Description: GTK+ Graphical UI Library (${target} target) Version: 2.24.30 Requires: gdk-${target}-2.0 atk cairo gdk-pixbuf-2.0 gio-2.0 pangoft2 Libs: -L${libdir} -lgtk-${target}-2.0 Cflags: -I${includedir}/gtk-2.0

Also, If I try with the dependencies of GTK2, I have problems with some of them, such as cairo and gdk-x11-2.0, Note that cairo.pc is in the same directory of glib-2.0.pc and gtk+-2.0.pc.

How can I debug these results and how can I fix it? Some suggestions? Thanks for all!

CMake cross compiler problem with pkg_check_modules for some packages

Hello!

Introduction

I'm trying to cross compile opencv trough crosstool-ng, and I'm having problems, I cannot good compile it (I can compile It but without GTK2, when I try to find the neccesary packages (GTK2 in this case), cmake cannot find them.

Test through find_package

To understand what is happening, I run a test of my own CMakeList.txt (CMakeLists.txt) with my toolchain.cmake file, and the results are:

find_package( GTK2 REQUIRED ),

=> Found

Also, if I try from the terminal:

cmake -DCMAKE_TOOLCHAIN_FILE=~/x-tools/my-toolchain.cmake --find-package -DNAME=GTK2 -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST

=> GTK2 found.

Test through pkg_check_modules

Then the method find_package seems to work, but OpenCV uses pkg_check_modules (another method using .pc files) I made a CMakeLists.txt with the function:

find_package(PkgConfig)

pkg_check_modules (GTK2 glib-2.0)

message("${PKG_CONFIG_FOUND}")

=> Not found

Additional content:

The CMakeLists.txt of openCV uses internally pkg_check_modules, and as I can see, it doesn't work. In my computer, CMake can find and stand for some libraries but not for all, I'm having problems with pkg_check_modules. Also, if I try with another libraries, I can find them (as example, GLib). Both gtk+-2.0.pc and glib-2.0.pc files are in the same directory, and the final libraries are in the same destination folder, by that, I don't think that is a PATH configuration error. I cannot hardcode them because I need to cross compile more packages later

If I run these tests on target, I can find all packages (and all files on the next directories are synced), also I have repaired the incorrect symbolic links

/lib /usr/include /usr/lib /usr/local/include /usr/local/lib /usr/share/pkg-config

In my toolchain.cmake file:

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/lib/aarch64-linux-gnu/pkgconfig" )

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/share/pkgconfig" )

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/lib/pkgconfig" )

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/opt/ocv/lib/pkgconfig" )

And the contents of my .pc files

$ find . -name glib-2.0.pc

./usr/lib/aarch64-linux-gnu/pkgconfig/glib-2.0.pc

$ find . -name gtk+-2.0.pc

./usr/lib/aarch64-linux-gnu/pkgconfig/gtk+-2.0.pc

And it contents: $ cat glib-2.0.pc prefix=/usr exec_prefix=${prefix} libdir=${prefix}/lib/aarch64-linux-gnu includedir=${prefix}/include

glib_genmarshal=glib-genmarshal gobject_query=gobject-query glib_mkenums=glib-mkenums

Name: GLib Description: C Utility Library Version: 2.48.2 Requires.private: libpcre Libs: -L${libdir} -lglib-2.0 Libs.private: -pthread -lpcre
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include

cat gtk+-2.0:

prefix=/usr exec_prefix=${prefix} libdir=/usr/lib/aarch64-linux-gnu includedir=${prefix}/include target=x11

gtk_binary_version=2.10.0 gtk_host=aarch64-unknown-linux-gnu

Name: GTK+ Description: GTK+ Graphical UI Library (${target} target) Version: 2.24.30 Requires: gdk-${target}-2.0 atk cairo gdk-pixbuf-2.0 gio-2.0 pangoft2 Libs: -L${libdir} -lgtk-${target}-2.0 Cflags: -I${includedir}/gtk-2.0

Also, If I try with the dependencies of GTK2, I have problems with some of them, such as cairo and gdk-x11-2.0, Note that cairo.pc is in the same directory of glib-2.0.pc and gtk+-2.0.pc.

How can I debug these results and how can I fix it? Some suggestions? Thanks for all!

Edit: Added information:

In order to discard that the path's of pkg-config are mixed with my original root filesystem (/), I have tried to move some .pc file in the directory /opt/ocv/lib/pkgconfig/test.pc, and I cannot found it with pkg_check_modules(), but If I put in the directory ${RPI_ROOTFS}/opt/ocv/lib/pkgconfig, I can found it.

click to hide/show revision 3
None

updated 2017-12-08 13:52:49 -0600

berak gravatar image

CMake cross compiler problem with pkg_check_modules for some packages

Hello!

Introduction

I'm trying to cross compile opencv trough crosstool-ng, and I'm having problems, I cannot good compile it (I can compile It but without GTK2, when I try to find the neccesary packages (GTK2 in this case), cmake cannot find them.

Test through find_package

To understand what is happening, I run a test of my own CMakeList.txt (CMakeLists.txt) with my toolchain.cmake file, and the results are:

find_package( GTK2 REQUIRED ),

=> Found

Also, if I try from the terminal:

cmake -DCMAKE_TOOLCHAIN_FILE=~/x-tools/my-toolchain.cmake --find-package -DNAME=GTK2 -DCOMPILER_ID=GNU -DLANGUAGE=CXX  -DMODE=EXIST

-DMODE=EXIST => GTK2 found.

found.

Test through pkg_check_modules

Then the method find_package seems to work, but OpenCV uses pkg_check_modules (another method using .pc files) I made a CMakeLists.txt with the function:

find_package(PkgConfig)

find_package(PkgConfig)

pkg_check_modules (GTK2 glib-2.0)

message("${PKG_CONFIG_FOUND}")

glib-2.0) message("${PKG_CONFIG_FOUND}") => Not found

found

Additional content:

The CMakeLists.txt of openCV uses internally pkg_check_modules, and as I can see, it doesn't work. In my computer, CMake can find and stand for some libraries but not for all, I'm having problems with pkg_check_modules. Also, if I try with another libraries, I can find them (as example, GLib). Both gtk+-2.0.pc and glib-2.0.pc files are in the same directory, and the final libraries are in the same destination folder, by that, I don't think that is a PATH configuration error. I cannot hardcode them because I need to cross compile more packages later

If I run these tests on target, I can find all packages (and all files on the next directories are synced), also I have repaired the incorrect symbolic links

/lib
/usr/include
/usr/lib
/usr/local/include
/usr/local/lib
/usr/share/pkg-config

/usr/share/pkg-config

In my toolchain.cmake file:

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/lib/aarch64-linux-gnu/pkgconfig" )

) set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/share/pkgconfig" )

) set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/lib/pkgconfig" )

) set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/opt/ocv/lib/pkgconfig" )

)

And the contents of my .pc files

$ find . -name glib-2.0.pc

./usr/lib/aarch64-linux-gnu/pkgconfig/glib-2.0.pc

glib-2.0.pc ./usr/lib/aarch64-linux-gnu/pkgconfig/glib-2.0.pc $ find . -name gtk+-2.0.pc

./usr/lib/aarch64-linux-gnu/pkgconfig/gtk+-2.0.pc

gtk+-2.0.pc ./usr/lib/aarch64-linux-gnu/pkgconfig/gtk+-2.0.pc

And it contents: contents:

$ cat glib-2.0.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/aarch64-linux-gnu
includedir=${prefix}/include

includedir=${prefix}/include glib_genmarshal=glib-genmarshal gobject_query=gobject-query glib_mkenums=glib-mkenums

glib_mkenums=glib-mkenums Name: GLib Description: C Utility Library Version: 2.48.2 Requires.private: libpcre Libs: -L${libdir} -lglib-2.0 Libs.private: -pthread -lpcre
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include

-I${libdir}/glib-2.0/include cat gtk+-2.0:

gtk+-2.0: prefix=/usr exec_prefix=${prefix} libdir=/usr/lib/aarch64-linux-gnu includedir=${prefix}/include target=x11

target=x11 gtk_binary_version=2.10.0 gtk_host=aarch64-unknown-linux-gnu

gtk_host=aarch64-unknown-linux-gnu Name: GTK+ Description: GTK+ Graphical UI Library (${target} target) Version: 2.24.30 Requires: gdk-${target}-2.0 atk cairo gdk-pixbuf-2.0 gio-2.0 pangoft2 Libs: -L${libdir} -lgtk-${target}-2.0 Cflags: -I${includedir}/gtk-2.0

-I${includedir}/gtk-2.0

Also, If I try with the dependencies of GTK2, I have problems with some of them, such as cairo and gdk-x11-2.0, Note that cairo.pc is in the same directory of glib-2.0.pc and gtk+-2.0.pc.

How can I debug these results and how can I fix it? Some suggestions? Thanks for all!

Edit: Added information:

In order to discard that the path's of pkg-config are mixed with my original root filesystem (/), I have tried to move some .pc file in the directory /opt/ocv/lib/pkgconfig/test.pc, and I cannot found it with pkg_check_modules(), but If I put in the directory ${RPI_ROOTFS}/opt/ocv/lib/pkgconfig, I can found it.

CMake cross compiler problem with pkg_check_modules for some packages

Hello!

Introduction

I'm trying to cross compile opencv trough crosstool-ng, and I'm having problems, I cannot good compile it (I can compile It but without GTK2, when I try to find the neccesary packages (GTK2 in this case), cmake cannot find them.

Test through find_package

To understand what is happening, I run a test of my own CMakeList.txt (CMakeLists.txt) with my toolchain.cmake file, and the results are:

find_package( GTK2 REQUIRED ),

=> Found

Also, if I try from the terminal:

cmake -DCMAKE_TOOLCHAIN_FILE=~/x-tools/my-toolchain.cmake --find-package -DNAME=GTK2 -DCOMPILER_ID=GNU -DLANGUAGE=CXX  -DMODE=EXIST

=> GTK2 found.

Test through pkg_check_modules

Then the method find_package seems to work, but OpenCV uses pkg_check_modules (another method using .pc files) I made a CMakeLists.txt with the function:

find_package(PkgConfig)

pkg_check_modules (GTK2 glib-2.0)
gtk+-2.0)

message("${PKG_CONFIG_FOUND}")

=> Not found

Additional content:

The CMakeLists.txt of openCV uses internally pkg_check_modules, and as I can see, it doesn't work. In my computer, CMake can find and stand for some libraries but not for all, I'm having problems with pkg_check_modules. Also, if I try with another libraries, I can find them (as example, GLib). Both gtk+-2.0.pc and glib-2.0.pc files are in the same directory, and the final libraries are in the same destination folder, by that, I don't think that is a PATH configuration error. I cannot hardcode them because I need to cross compile more packages later

If I run these tests on target, I can find all packages (and all files on the next directories are synced), also I have repaired the incorrect symbolic links

/lib
/usr/include
/usr/lib
/usr/local/include
/usr/local/lib
/usr/share/pkg-config

In my toolchain.cmake file:

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/lib/aarch64-linux-gnu/pkgconfig" )

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/share/pkgconfig" )

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/usr/lib/pkgconfig" )

set( RPI_PKGCONFIG_LIBDIR "${RPI_PKGCONFIG_LIBDIR}:${RPI_ROOTFS}/opt/ocv/lib/pkgconfig" )

And the contents of my .pc files

$ find . -name glib-2.0.pc

./usr/lib/aarch64-linux-gnu/pkgconfig/glib-2.0.pc

$ find . -name gtk+-2.0.pc

./usr/lib/aarch64-linux-gnu/pkgconfig/gtk+-2.0.pc

And it contents:

$ cat glib-2.0.pc
prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/lib/aarch64-linux-gnu
includedir=${prefix}/include

glib_genmarshal=glib-genmarshal
gobject_query=gobject-query
glib_mkenums=glib-mkenums

Name: GLib
Description: C Utility Library
Version: 2.48.2
Requires.private: libpcre
Libs: -L${libdir} -lglib-2.0 
Libs.private: -pthread  -lpcre    
Cflags: -I${includedir}/glib-2.0 -I${libdir}/glib-2.0/include
 

$ cat gtk+-2.0: gtk+-2.0.pc

prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib/aarch64-linux-gnu
includedir=${prefix}/include
target=x11

gtk_binary_version=2.10.0
gtk_host=aarch64-unknown-linux-gnu

Name: GTK+
Description: GTK+ Graphical UI Library (${target} target)
Version: 2.24.30
Requires: gdk-${target}-2.0 atk cairo gdk-pixbuf-2.0 gio-2.0 pangoft2
Libs: -L${libdir} -lgtk-${target}-2.0 
Cflags: -I${includedir}/gtk-2.0

Also, If I try with the dependencies of GTK2, I have problems with some of them, such as cairo and gdk-x11-2.0, Note that cairo.pc is in the same directory of glib-2.0.pc and gtk+-2.0.pc.

How can I debug these results and how can I fix it? Some suggestions? Thanks for all!