<div dir="ltr">As a follow-up to my own question, I was able to go a little bit further VTK's build process.<div><br></div><div>The error I've pasted (<span style="font-family:monospace,monospace;font-size:12.8px">Could NOT find OSMesa)</span><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">was fixed by compiling mesa with </font></span><span style="font-size:12.8px"><font face="monospace, monospace">--enable-osmesa</font><font face="arial, helvetica, sans-serif">. For this I created a file named named <i>mesa_%.bbappend</i> in my layer's <i>recipes-graphics/mesa/</i> directory. That might not be the optimal solution (or even a working one) but at least the build process went a little bit further.</font></span></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif"><br></font></span></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">The error I'm getting now is one that I have seen last week when trying multiple things in the Yocto build system.</font></span></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif"><br></font></span></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">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 <i>cross-compilation</i>.</font></span></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif"><br></font></span></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px">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 (<a href="https://github.com/mferland/meta-vtk/blob/master/recipes-vtk/vtk/files/0001-vtkCompileTools-Add-a-CompileTools-group.patch">https://github.com/mferland/meta-vtk/blob/master/recipes-vtk/vtk/files/0001-vtkCompileTools-Add-a-CompileTools-group.patch</a>) 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.</span></font></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px"><br></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px">This post by Tim Thirion describe a new (as of VTK 6.2.0) way to cross-compile for Android or iOS: </span></font><span style="font-size:12.8px;font-family:arial,helvetica,sans-serif"><a href="http://www.kitware.com/blog/home/post/860">http://www.kitware.com/blog/home/post/860</a></span></div><div><span style="font-size:12.8px;font-family:arial,helvetica,sans-serif">I haven't looked yet in VTK's CMakeLists.txt what these options do but could that be a lead?</span></div><div><span style="font-size:12.8px;font-family:arial,helvetica,sans-serif"><br></span></div><div><span style="font-size:12.8px;font-family:arial,helvetica,sans-serif">As a reference, here is how cmake was called by bitbake:</span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span style="font-size:12.8px"><font face="monospace, monospace">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</font></span></blockquote><div><br></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px">Note the -</span></font><span style="font-family:monospace,monospace;font-size:12.8px">DCMAKE_TOOLCHAIN_FILE</span><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif"> points to a file with this content (automatically created by bitbake):</font></span></div><div><span style="font-size:12.8px"><font face="monospace, monospace"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"># CMake system name must be something like "Linux".<br># This is important for cross-compiling.<br>set( CMAKE_SYSTEM_NAME Linux )<br>set( CMAKE_SYSTEM_PROCESSOR x86_64 )<br>set( CMAKE_C_COMPILER x86_64-poky-linux-gcc )<br>set( CMAKE_CXX_COMPILER x86_64-poky-linux-g++ )<br>set( CMAKE_ASM_COMPILER x86_64-poky-linux-gcc )<br>set( CMAKE_AR x86_64-poky-linux-ar CACHE FILEPATH "Archiver" )<br>set( CMAKE_C_FLAGS " -m64 -march=corei7 -mtune=corei7 -mfpmath=sse -msse4.2  --sysroot=/home/nbigaouette/Codes/git/yocto/yocto-ctm<br>s.git/build/tmp/sysroots/intel-corei7-64  -O2 -pipe -g -feliminate-unused-debug-types" CACHE STRING "CFLAGS" )<br>set( CMAKE_CXX_FLAGS " -m64 -march=corei7 -mtune=corei7 -mfpmath=sse -msse4.2  --sysroot=/home/nbigaouette/Codes/git/yocto/yocto-c<br>tms.git/build/tmp/sysroots/intel-corei7-64  -O2 -pipe -g -feliminate-unused-debug-types -fvisibility-inlines-hidden" CACHE STRING<br>"CXXFLAGS" )<br>set( CMAKE_ASM_FLAGS " -m64 -march=corei7 -mtune=corei7 -mfpmath=sse -msse4.2  --sysroot=/home/nbigaouette/Codes/git/yocto/yocto-c<br>tms.git/build/tmp/sysroots/intel-corei7-64  -O2 -pipe -g -feliminate-unused-debug-types" CACHE STRING "ASM FLAGS" )<br>set( CMAKE_C_FLAGS_RELEASE "-O2 -pipe -g -feliminate-unused-debug-types  -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG" CAC<br>HE STRING "CFLAGS for release" )<br>set( CMAKE_CXX_FLAGS_RELEASE "-O2 -pipe -g -feliminate-unused-debug-types  -O2 -pipe -g -feliminate-unused-debug-types -fvisibilit<br>y-inlines-hidden -DNDEBUG" CACHE STRING "CXXFLAGS for release" )<br>set( CMAKE_ASM_FLAGS_RELEASE "-O2 -pipe -g -feliminate-unused-debug-types  -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG" C<br>ACHE STRING "ASM FLAGS for release" )<br>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" )<br>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" )<br># only search in the paths provided so cmake doesnt pick<br># up libraries and tools from the native build machine<br>set( CMAKE_FIND_ROOT_PATH /home/nbigaouette/yocto/build/tmp/sysroots/intel-corei7-64 /home/nbigaouette/yocto/build/tmp/sysroots/x86_64-linux    )<br>set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )<br>set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )<br>set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )<br>set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )<br># Use qt.conf settings<br>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 )<br># We need to set the rpath to the correct directory as cmake does not provide any<br># directory as rpath by default<br>set( CMAKE_INSTALL_RPATH  )<br># Use native cmake modules<br>list(APPEND CMAKE_MODULE_PATH "/home/nbigaouette/yocto/build/tmp/sysroots/intel-corei7-64/usr/share/cmake/Modules/")<br># add for non /usr/lib libdir, e.g. /usr/lib64<br>set( CMAKE_LIBRARY_PATH /usr/lib /lib)</blockquote></font></span></div><div><br></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px"><br></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px">The cmake command above fails with:</span></font></div><div><span style="font-size:12.8px"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="monospace, monospace">-- Looking for include file pthread.h<br></font><font face="monospace, monospace">-- Looking for include file pthread.h - found</font><font face="monospace, monospace"><br></font><font face="monospace, monospace">-- Looking for include file pthread.h - found<br></font><font face="monospace, monospace">-- Configuring incomplete, errors occurred!<br></font><font face="monospace, monospace">See also "/home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/build/CMakeFiles/CMakeOutput.log".<br></font><font face="monospace, monospace">See also "/home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/build/CMakeFiles/CMakeError.log".</font><font face="monospace, monospace"><br></font><font face="monospace, monospace">-- Configuring incomplete, errors occurred!<br></font><font face="monospace, monospace">See also "/home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/build/CMakeFiles/CMakeOutput.log".<br></font><font face="monospace, monospace">See also "/home/nbigaouette/yocto/build/tmp/work/corei7-64-poky-linux/vtk/7.0.0.rc1+gitAUTOINC+bfbdc62b93-r0/build/CMakeFiles/CMakeError.log".</font></blockquote><div style="font-family:arial,helvetica,sans-serif"><br></div><div style="font-family:arial,helvetica,sans-serif">which is not really helpful.</div></span></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif"><br></font></span></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">The content of CMakeOutput.log is here: </font></span><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px"><a href="http://hastebin.com/okelazekop.vhdl">http://hastebin.com/okelazekop.vhdl</a></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px">The content of CMakeError.log is here: <a href="http://hastebin.com/yivijemupi.pl">http://hastebin.com/yivijemupi.pl</a></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="font-size:12.8px"><br></span></font></div><div>Any clue or suggestion as to how to cross-compile VTK?</div><div><br></div><div>Thanks!</div><div><br></div><div>Regards,</div><div><br></div><div>Nicolas</div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif"><br></font></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-21 14:20 GMT-05:00 Nicolas Bigaouette <span dir="ltr"><<a href="mailto:nbigaouette@gmail.com" target="_blank">nbigaouette@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I'm working on a project that integrates Qt's QML with VTK. I inspired myself from this code to integrate VTK into QML:</div><div><a href="https://gist.github.com/nocnokneo/c3fb01bb7ecaf437f7d6" target="_blank">https://gist.github.com/nocnokneo/c3fb01bb7ecaf437f7d6</a><br></div><div><br></div><div>For testing purpose, I was able to run the application (QML + VTK) under a Ubuntu 15.10 Server install which does <i>not</i> 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 <a href="http://doc.qt.io/qt-5/embedded-linux.html" target="_blank">http://doc.qt.io/qt-5/embedded-linux.html</a>).</div><div><br></div><div>This project is meant to run on a device of which the OS is built using Yocto <i>without </i>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).</div><div><br></div><div>The only recipes I've found for VTK on Yocto is this one from Marc Ferland: <a href="https://github.com/mferland/meta-vtk" target="_blank">https://github.com/mferland/meta-vtk</a></div><div>Unfortunately:</div><div>1) It is 2 years old and applies for an old release of VTK</div><div>2) It assumes that Yocto is including X11 (through the DISTRO_FEATURES="x11")</div><div>3) It is targeting OpenEmbedded (instead of Yocto)</div><div><br></div><div>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.</div><div><br></div><div>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:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><font face="monospace, monospace">| CMake Error at CMake/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):</font></div></div><div><div><font face="monospace, monospace">|   Could NOT find OSMesa (missing: OSMESA_LIBRARY OSMESA_INCLUDE_DIR)</font></div></div><div><div><font face="monospace, monospace">| Call Stack (most recent call first):</font></div></div><div><div><font face="monospace, monospace">|   CMake/FindPackageHandleStandardArgs.cmake:288 (_FPHSA_FAILURE_MESSAGE)</font></div></div><div><div><font face="monospace, monospace">|   CMake/FindOSMesa.cmake:45 (find_package_handle_standard_args)</font></div></div><div><div><font face="monospace, monospace">|   CMake/vtkOpenGL.cmake:59 (find_package)</font></div></div><div><div><font face="monospace, monospace">|   ThirdParty/glew/vtkglew/CMakeLists.txt:3 (include)</font></div></div></blockquote><div><br></div><div><br></div><div>My questions are:</div><div>1) Can I compile VTK <i>without </i>having any X11 libraries?</div><div>2) What does the cmake flag VTK_USE_X do?</div><div>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 <a href="https://gist.github.com/nocnokneo/c3fb01bb7ecaf437f7d6" target="_blank">https://gist.github.com/nocnokneo/c3fb01bb7ecaf437f7d6</a>)? </div><div>4) How come I was able to run my QML+VTK example on the Qt platform EGLFS on a distro without X11?</div><div><br></div><div>Thanks for any clarification!</div><div><br></div><div>Regards,</div><div><br></div><div>Nicolas</div><div><br></div></div>
</blockquote></div><br></div>