树莓派4上编译grblcontrol

问题描述

近段时间一直在做雕刻机这方面,刚好买了一个树莓派4,想着将grblcontrol放到树莓派4上运行。grblcontrol本身就可以在Linux下编译运行(得益于QT的跨平台)。之后我也在Ubuntu下编译了,完美运行。于是想着在树莓派上运行也是很简单的。。。。。


首先配置树莓派4的qt开发环境,本想着使用交叉编译,但是感觉太麻烦了,于是放弃。。。。。。直接在树莓派4上编译。
1、更新树莓派

sudo apt-get update
sudo apt-get upgrade
sudo rpi-update

2、安装qt5

sudo apt-get install qt5-default
sudo apt-get install qtcreator

3、准备工作
grblcontrol使用了串口和OpenGL,树莓派本身以及有了OpenGL,但是缺少qt5的串口模块,因此需要单独安装串口模块。

sudo apt-get install libqt5serialport5-dev libudev-dev

4、开始编译
使用命令行,进入grblcontrol源码的上层目录,创建一个build文件夹,之后使用qmake读取pro文件,再执行make即可。

mkdir build
cd build
qmake ../src/candle.pro
make

。。。。。。。。。。。于是报错一大堆。
首先就是找不到GLES/gl.h文件。但是使用find命令却可以找到,说明环境变量的配置有问题,但是在摸索了一段时间之后发现搞不定。。。。。。。。,但是问题还是要解决的。既然树莓派4本身已经支持了OpenGL,那么就不需要使用OpenGL es了。于是准备绕过OpenGL es,使用OpenGL。查看了文件,发现文件中是查看是否定义了一个GLES的宏来判断的,这个宏定义的位置在pro文件中

contains(QT_CONFIG, opengles.) {
    warning("GL ES detected. VAO will be disabled.")
    #DEFINES += GLES
    INSTALLS += target
    target.path = /home/pi
}

在这里将这个宏去掉,即可。
继续编译,发现又出现问题

<command-line>: note: this is the location of the previous definition
../src/widgets/glwidget.cpp: In member function ‘virtual void GLWidget::paintEvent(QPaintEvent*)’:
../src/widgets/glwidget.cpp:433:14: error: ‘GL_PROGRAM_POINT_SIZE’ was not declared in this scope
     glEnable(GL_PROGRAM_POINT_SIZE);
              ^~~~~~~~~~~~~~~~~~~~~
../src/widgets/glwidget.cpp:433:14: note: suggested alternative: ‘GL_PROGRAM_PIPELINE’
     glEnable(GL_PROGRAM_POINT_SIZE);
              ^~~~~~~~~~~~~~~~~~~~~
              GL_PROGRAM_PIPELINE
../src/widgets/glwidget.cpp:437:30: error: ‘GL_MULTISAMPLE’ was not declared in this scope
         if (m_msaa) glEnable(GL_MULTISAMPLE); else {
                              ^~~~~~~~~~~~~~
../src/widgets/glwidget.cpp:437:30: note: suggested alternative: ‘GL_MULTISAMPLES_NV’
         if (m_msaa) glEnable(GL_MULTISAMPLE); else {
                              ^~~~~~~~~~~~~~
                              GL_MULTISAMPLES_NV
../src/widgets/glwidget.cpp:438:20: error: ‘GL_LINE_SMOOTH_HINT’ was not declared in this scope
             glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
                    ^~~~~~~~~~~~~~~~~~~
../src/widgets/glwidget.cpp:438:20: note: suggested alternative: ‘GL_LINE_STRIP’
             glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
                    ^~~~~~~~~~~~~~~~~~~
                    GL_LINE_STRIP
../src/widgets/glwidget.cpp:439:22: error: ‘GL_LINE_SMOOTH’ was not declared in this scope
             glEnable(GL_LINE_SMOOTH);
                      ^~~~~~~~~~~~~~
../src/widgets/glwidget.cpp:439:22: note: suggested alternative: ‘GL_LINE_LOOP’
             glEnable(GL_LINE_SMOOTH);
                      ^~~~~~~~~~~~~~
                      GL_LINE_LOOP
../src/widgets/glwidget.cpp:440:20: error: ‘GL_POINT_SMOOTH_HINT’ was not declared in this scope
             glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
                    ^~~~~~~~~~~~~~~~~~~~
../src/widgets/glwidget.cpp:440:20: note: suggested alternative: ‘GL_POINT_NV’
             glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
                    ^~~~~~~~~~~~~~~~~~~~
                    GL_POINT_NV
../src/widgets/glwidget.cpp:441:22: error: ‘GL_POINT_SMOOTH’ was not declared in this scope
             glEnable(GL_POINT_SMOOTH);
                      ^~~~~~~~~~~~~~~
../src/widgets/glwidget.cpp:441:22: note: suggested alternative: ‘GL_POINT_NV’
             glEnable(GL_POINT_SMOOTH);
                      ^~~~~~~~~~~~~~~
                      GL_POINT_NV
../src/widgets/glwidget.cpp:472:15: error: ‘GL_MULTISAMPLE’ was not declared in this scope
     glDisable(GL_MULTISAMPLE);
               ^~~~~~~~~~~~~~
../src/widgets/glwidget.cpp:472:15: note: suggested alternative: ‘GL_MULTISAMPLES_NV’
     glDisable(GL_MULTISAMPLE);
               ^~~~~~~~~~~~~~
               GL_MULTISAMPLES_NV
../src/widgets/glwidget.cpp:473:15: error: ‘GL_LINE_SMOOTH’ was not declared in this scope
     glDisable(GL_LINE_SMOOTH);
               ^~~~~~~~~~~~~~
../src/widgets/glwidget.cpp:473:15: note: suggested alternative: ‘GL_LINE_LOOP’
     glDisable(GL_LINE_SMOOTH);
               ^~~~~~~~~~~~~~
               GL_LINE_LOOP
make: *** [Makefile:921: glwidget.o] Error 1

可能是OpenGL的版本问题(不是很清楚),按照上面的提示,将对应的错误修改即可。

最后编译,完美通过。

你可能感兴趣的:(GRBL学习)