Unable to cross-compile using CLion - GL/gl.h missing - Yes the packages are installed
-
First off, I do have all the OpenGL dev packages installed and the headers are located at /usr/include. I am trying to cross compile for an iMX8 development board. The board is running Boot2QT fine. I can successfully compile my sample project and install the application using QT Creator. I don't like QT Creator very much, and I am very used to IntelliJ IDEs, so I am attempting to use CLion. I converted the .pro to a CMakeLists.txt, and everything seems ok. My environment is also setup in CLion. The compilation goes along well until it fails to find GL/gl.h. Any suggestions are welcome.
CMakeLists.txt:
project( weatherinfo) cmake_minimum_required( VERSION 3.1 ) set( CMAKE_CXX_STANDARD 17 ) set( CMAKE_INCLUDE_CURRENT_DIR ON ) set( CMAKE_AUTOMOC ON ) set( CMAKE_AUTOUIC ON ) set( CMAKE_AUTORCC ON) set( CMAKE_BUILD_TYPE Release ) set( CMAKE_PREFIX_PATH "/home/strongadmin/Qt/5.12.10/gcc_64/") add_definitions ( -Wall ) find_package ( Qt5Core REQUIRED ) find_package ( Qt5Network REQUIRED ) find_package ( Qt5Positioning REQUIRED ) find_package ( Qt5Qml REQUIRED ) find_package ( Qt5Quick REQUIRED ) find_package ( Qt5SerialPort REQUIRED ) set ( weatherinfo_SRCS main.cpp appmodel.cpp weatherinfo.qrc ) add_executable ( weatherinfo ${weatherinfo_SRCS} ) target_link_libraries ( weatherinfo Qt5::Core Qt5::Network Qt5::Positioning Qt5::Qml Qt5::Quick Qt5::SerialPort)
I have tried changing the above CMAKE_PREFIX_PATH to the sysroot for the yocto project but I get various errors. Also I cannot find any GL/gl.h in the yocto SDK sysroot. I assume that is fine since i can successfully compile in QT Creator and install without any problems.
Here is the error:
====================[ Build | weatherinfo | Debug ]============================= /opt/b2qt/2.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/cmake --build /home/strongadmin/yocto/qt-projects/weatherinfo/cmake-build-debug --target weatherinfo -- -j 12 [ 11%] Automatic MOC for target weatherinfo [ 11%] Built target weatherinfo_autogen [ 22%] Generating qrc_weatherinfo.cpp [ 33%] Generating moc_appmodel.cpp Scanning dependencies of target weatherinfo [ 44%] Building CXX object CMakeFiles/weatherinfo.dir/qrc_weatherinfo.cpp.o [ 55%] Building CXX object CMakeFiles/weatherinfo.dir/main.cpp.o [ 66%] Building CXX object CMakeFiles/weatherinfo.dir/appmodel.cpp.o [ 88%] Building CXX object CMakeFiles/weatherinfo.dir/moc_appmodel.cpp.o [ 88%] Building CXX object CMakeFiles/weatherinfo.dir/weatherinfo_autogen/mocs_compilation.cpp.o In file included from /home/strongadmin/Qt/5.12.10/gcc_64/include/QtQuick/qsggeometry.h:44:0, from /home/strongadmin/Qt/5.12.10/gcc_64/include/QtQuick/qsgnode.h:43, from /home/strongadmin/Qt/5.12.10/gcc_64/include/QtQuick/qsgrendererinterface.h:43, from /home/strongadmin/Qt/5.12.10/gcc_64/include/QtQuick/qquickwindow.h:44, from /home/strongadmin/Qt/5.12.10/gcc_64/include/QtQuick/qquickview.h:43, from /home/strongadmin/Qt/5.12.10/gcc_64/include/QtQuick/QQuickView:1, from /home/strongadmin/yocto/qt-projects/weatherinfo/main.cpp:52: /home/strongadmin/Qt/5.12.10/gcc_64/include/QtGui/qopengl.h:141:13: fatal error: GL/gl.h: No such file or directory # include <GL/gl.h> ^~~~~~~~~ compilation terminated. make[3]: *** [CMakeFiles/weatherinfo.dir/build.make:88: CMakeFiles/weatherinfo.dir/main.cpp.o] Error 1 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [CMakeFiles/Makefile2:68: CMakeFiles/weatherinfo.dir/all] Error 2 make[1]: *** [CMakeFiles/Makefile2:80: CMakeFiles/weatherinfo.dir/rule] Error 2 make: *** [Makefile:118: weatherinfo] Error 2
Also adding find_package (OpenGL REQUIRED) fails:
CMake Error at /opt/b2qt/2.5.3/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:137 (message): Could NOT find OpenGL (missing: OPENGL_opengl_LIBRARY OPENGL_glx_LIBRARY) Call Stack (most recent call first): /opt/b2qt/2.5.3/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.10/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE) /opt/b2qt/2.5.3/sysroots/x86_64-pokysdk-linux/usr/share/cmake-3.10/Modules/FindOpenGL.cmake:369 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:16 (find_package)
I also fails the same way when I use the embedded CLion CMake.
-
Ok I have solved the problem. I was already using:
source /opt/b2qt/2.5.3/environment-setup-aarch64-poky-linux
to setup the environment before I launched Clion, but apparently there were some sub scripts that run making an alias of cmake with:
alias cmake="cmake -DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake"
Clion ignores this alias, so I had to add those flags to the cmake options area in Clion under Build, Execution, Deployment -> Cmake -> Cmake options, I also had to fill in the variable $OECORE_NATIVE_SYSROOT, as clion could not resolve that. Here is what I added:
-DCMAKE_TOOLCHAIN_FILE=/opt/b2qt/2.5.3/sysroots/x86_64-pokysdk-linux/usr/share/cmake/OEToolchainConfig.cmake
After that everything was compiling perfectly fine.