[vtkusers] VTK and Yocto

Nicolas Bigaouette nbigaouette at gmail.com
Mon Dec 21 21:17:49 EST 2015


As a follow-up to my own question, I was able to go a little bit further
VTK's build process.

The error I've pasted (Could NOT find OSMesa)was fixed by compiling mesa
with --enable-osmesa. For this I created a file named named
*mesa_%.bbappend* in my layer's *recipes-graphics/mesa/* directory. That
might not be the optimal solution (or even a working one) but at least the
build process went a little bit further.

The error I'm getting now is one that I have seen last week when trying
multiple things in the Yocto build system.

Running cmake fails and I have a hard time identifying the source of the
problem. The problem surely comes from not understanding properly the Yocto
build system. Even though I am building for an x86_64 NUC device from an
Ubuntu 14.04 x86_64, the compilation by bitbake/yocto is a
*cross-compilation*.

The more I think the more I believe my problems comes from badly setting up
that cross-compilation. Yocto should be doing it but VTK requires some
extra work. Marc Ferland's patch located in his layer (
https://github.com/mferland/meta-vtk/blob/master/recipes-vtk/vtk/files/0001-vtkCompileTools-Add-a-CompileTools-group.patch)
adds a "vtkCompileTools" group. Would that still be necessary to
cross-compile VTK v7.0? The patch does not apply to VTK 7; I tried to
re-create it but either the problem is elsewhere, VTK shouldn't be patched
or I'm doing it wrong.

This post by Tim Thirion describe a new (as of VTK 6.2.0) way to
cross-compile for Android or iOS: http://www.kitware.com/blog/home/post/860
I haven't looked yet in VTK's CMakeLists.txt what these options do but
could that be a lead?

As a reference, here is how cmake was called by bitbake:

> cmake
> /home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/git
> -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_BINDIR:PATH=/usr/bin
> -DCMAKE_INSTALL_SBINDIR:PATH=/usr/sbin
> -DCMAKE_INSTALL_LIBEXECDIR:PATH=/usr/lib/vtk
> -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc
> -DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=/com
> -DCMAKE_INSTALL_LOCALSTATEDIR:PATH=/var
> -DCMAKE_INSTALL_LIBDIR:PATH=/usr/lib
> -DCMAKE_INSTALL_INCLUDEDIR:PATH=/usr/include
> -DCMAKE_INSTALL_DATAROOTDIR:PATH=/usr/share -DCMAKE_INSTALL_SO_NO_EXE=0
> -DCMAKE_TOOLCHAIN_FILE=/home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/toolchain.cmake
> -DCMAKE_VERBOSE_MAKEFILE=1 -DBUILD_DOCUMENTATION:BOOL=OFF
> -DBUILD_EXAMPLES:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=ON
> -DBUILD_TESTING:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release
> -DVTK_USE_SYSTEM_EXPAT:BOOL=ON -DVTK_USE_SYSTEM_FREETYPE:BOOL=ON
> -DVTK_USE_SYSTEM_JPEG:BOOL=ON -DVTK_USE_SYSTEM_LIBXML2:BOOL=ON
> -DVTK_USE_SYSTEM_PNG:BOOL=ON -DVTK_USE_SYSTEM_ZLIB:BOOL=ON
> -DVTK_USE_SYSTEM_TIFF:BOOL=ON -DVTK_USE_SYSTEM_HDF5:BOOL=ON
> -DVTK_USE_X:BOOL=OFF -DVTK_WRAP_PYTHON:BOOL=OFF -DVTK_WRAP_JAVA:BOOL=OFF
> -DVTK_WRAP_TCL:BOOL=OFF
> -DVTKCompileTools_DIR=/home/nbigaouette/yocto/build/tmp/sysroots/x86_64-linux/usr/lib/cmake/vtk-7.0
> -DVTK_Group_Imaging:BOOL=OFF -DVTK_Group_Qt:BOOL=OFF
> -DVTK_Group_Rendering:BOOL=OFF -DVTK_Group_Views:BOOL=OFF
> -DVTK_Group_Web:BOOL=OFF -Wno-dev


Note the -DCMAKE_TOOLCHAIN_FILE points to a file with this content
(automatically created by bitbake):

> # CMake system name must be something like "Linux".
> # This is important for cross-compiling.
> set( CMAKE_SYSTEM_NAME Linux )
> set( CMAKE_SYSTEM_PROCESSOR x86_64 )
> set( CMAKE_C_COMPILER x86_64-poky-linux-gcc )
> set( CMAKE_CXX_COMPILER x86_64-poky-linux-g++ )
> set( CMAKE_ASM_COMPILER x86_64-poky-linux-gcc )
> set( CMAKE_AR x86_64-poky-linux-ar CACHE FILEPATH "Archiver" )
> set( CMAKE_C_FLAGS " -m64 -march=corei7 -mtune=corei7 -mfpmath=sse
> -msse4.2  --sysroot=/home/nbigaouette/Codes/git/yocto/yocto-ctm
> s.git/build/tmp/sysroots/intel-corei7-64  -O2 -pipe -g
> -feliminate-unused-debug-types" CACHE STRING "CFLAGS" )
> set( CMAKE_CXX_FLAGS " -m64 -march=corei7 -mtune=corei7 -mfpmath=sse
> -msse4.2  --sysroot=/home/nbigaouette/Codes/git/yocto/yocto-c
> tms.git/build/tmp/sysroots/intel-corei7-64  -O2 -pipe -g
> -feliminate-unused-debug-types -fvisibility-inlines-hidden" CACHE STRING
> "CXXFLAGS" )
> set( CMAKE_ASM_FLAGS " -m64 -march=corei7 -mtune=corei7 -mfpmath=sse
> -msse4.2  --sysroot=/home/nbigaouette/Codes/git/yocto/yocto-c
> tms.git/build/tmp/sysroots/intel-corei7-64  -O2 -pipe -g
> -feliminate-unused-debug-types" CACHE STRING "ASM FLAGS" )
> set( CMAKE_C_FLAGS_RELEASE "-O2 -pipe -g -feliminate-unused-debug-types
>  -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG" CAC
> HE STRING "CFLAGS for release" )
> set( CMAKE_CXX_FLAGS_RELEASE "-O2 -pipe -g -feliminate-unused-debug-types
>  -O2 -pipe -g -feliminate-unused-debug-types -fvisibilit
> y-inlines-hidden -DNDEBUG" CACHE STRING "CXXFLAGS for release" )
> set( CMAKE_ASM_FLAGS_RELEASE "-O2 -pipe -g -feliminate-unused-debug-types
>  -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG" C
> ACHE STRING "ASM FLAGS for release" )
> set( CMAKE_C_LINK_FLAGS " -m64 -march=corei7 -mtune=corei7 -mfpmath=sse
> -msse4.2
>  --sysroot=/home/nbigaouette/yocto/build/tmp/sysroots/intel-corei7-64
>  -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed" CACHE STRING "LDFLAGS" )
> set( CMAKE_CXX_LINK_FLAGS " -m64 -march=corei7 -mtune=corei7 -mfpmath=sse
> -msse4.2
>  --sysroot=/home/nbigaouette/yocto/build/tmp/sysroots/intel-corei7-64  -O2
> -pipe -g -feliminate-unused-debug-types -fvisibility-inlines-hidden -Wl,-O1
> -Wl,--hash-style=gnu -Wl,--as-needed" CACHE STRING "LDFLAGS" )
> # only search in the paths provided so cmake doesnt pick
> # up libraries and tools from the native build machine
> set( CMAKE_FIND_ROOT_PATH
> /home/nbigaouette/yocto/build/tmp/sysroots/intel-corei7-64
> /home/nbigaouette/yocto/build/tmp/sysroots/x86_64-linux    )
> set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
> set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
> set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
> set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
> # Use qt.conf settings
> set( ENV{QT_CONF_PATH}
> /home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/qt.conf
> )
> # We need to set the rpath to the correct directory as cmake does not
> provide any
> # directory as rpath by default
> set( CMAKE_INSTALL_RPATH  )
> # Use native cmake modules
> list(APPEND CMAKE_MODULE_PATH
> "/home/nbigaouette/yocto/build/tmp/sysroots/intel-corei7-64/usr/share/cmake/Modules/")
> # add for non /usr/lib libdir, e.g. /usr/lib64
> set( CMAKE_LIBRARY_PATH /usr/lib /lib)



The cmake command above fails with:

> -- Looking for include file pthread.h
> -- Looking for include file pthread.h - found
> -- Looking for include file pthread.h - found
> -- Configuring incomplete, errors occurred!
> See also
> "/home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/build/CMakeFiles/CMakeOutput.log".
> See also
> "/home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/build/CMakeFiles/CMakeError.log".
> -- Configuring incomplete, errors occurred!
> See also
> "/home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/build/CMakeFiles/CMakeOutput.log".
> See also
> "/home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/build/CMakeFiles/CMakeError.log".


which is not really helpful.

The content of CMakeOutput.log is here: http://hastebin.com/okelazekop.vhdl
The content of CMakeError.log is here: http://hastebin.com/yivijemupi.pl

Any clue or suggestion as to how to cross-compile VTK?

Thanks!

Regards,

Nicolas


2015-12-21 14:20 GMT-05:00 Nicolas Bigaouette <nbigaouette at gmail.com>:

> Hi all,
>
> I'm working on a project that integrates Qt's QML with VTK. I inspired
> myself from this code to integrate VTK into QML:
> https://gist.github.com/nocnokneo/c3fb01bb7ecaf437f7d6
>
> For testing purpose, I was able to run the application (QML + VTK) under a
> Ubuntu 15.10 Server install which does *not* install the X server. It
> does contain a /usr/lib/libGL.so though, which VTK seems to require, even
> if QML uses the "eglfs" platform plugin (OpenGL ES 2.0, see
> http://doc.qt.io/qt-5/embedded-linux.html).
>
> This project is meant to run on a device of which the OS is built using
> Yocto *without *X11, similarly to what Ubuntu Server provides. But while
> I could build VTK, QML and my application on my Ubuntu workstation and copy
> these files to the Ubuntu Server machine to run, I can't do this for the
> real project running from a Yocto image. I need to compile VTK (in addition
> to any other library) through the Yocto build system (bitbake).
>
> The only recipes I've found for VTK on Yocto is this one from Marc
> Ferland: https://github.com/mferland/meta-vtk
> Unfortunately:
> 1) It is 2 years old and applies for an old release of VTK
> 2) It assumes that Yocto is including X11 (through the
> DISTRO_FEATURES="x11")
> 3) It is targeting OpenEmbedded (instead of Yocto)
>
> After adapting the recipe for VTK 7.0.0.rc1, I cannot build it. From the
> original recipe, I removed dependencies on x11-related libraries
> (virtual/libx11 virtual/libgl libxt xserver-xorg-extension-glx) and
> everything Python related.
>
> What I don't understand is that recipe uses "-DVTK_USE_X:BOOL=OFF". But I
> still get errors dues to missing X11 libraries. For example, I am getting:
>
> | CMake Error at CMake/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):
> |   Could NOT find OSMesa (missing: OSMESA_LIBRARY OSMESA_INCLUDE_DIR)
> | Call Stack (most recent call first):
> |   CMake/FindPackageHandleStandardArgs.cmake:288 (_FPHSA_FAILURE_MESSAGE)
> |   CMake/FindOSMesa.cmake:45 (find_package_handle_standard_args)
> |   CMake/vtkOpenGL.cmake:59 (find_package)
> |   ThirdParty/glew/vtkglew/CMakeLists.txt:3 (include)
>
>
>
> My questions are:
> 1) Can I compile VTK *without *having any X11 libraries?
> 2) What does the cmake flag VTK_USE_X do?
> 3) Does it make sense to build VTK without x11 if I will be using VTK from
> C++ including these headers: QOpenGLFunctions, QQuickFramebufferObject,
> QOpenGLFramebufferObject, vtkGenericOpenGLRenderWindow (like at
> https://gist.github.com/nocnokneo/c3fb01bb7ecaf437f7d6)?
> 4) How come I was able to run my QML+VTK example on the Qt platform EGLFS
> on a distro without X11?
>
> Thanks for any clarification!
>
> Regards,
>
> Nicolas
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151221/9b7daed1/attachment.html>


More information about the vtkusers mailing list