Results 1 to 4 of 4

Thread: QT and SPI on Raspberry PI (include files problem)

  1. #1
    Join Date
    Jul 2018
    Posts
    3
    Qt products
    Qt5

    Default QT and SPI on Raspberry PI (include files problem)

    Hi,

    I am trying to use SPI bus on Raspberry wit Qt framework but without 3rd party libraries.

    I have tried to implement simple loopback test (https://www.raspberrypi.org/document.../spi/README.md) but I have got following errors:
    Qt Code:
    1. /usr/include/c++/6/bits/stl_algo.h:59: In file included from /usr/include/c++/6/bits/stl_algo.h:59:0,
    2. /usr/include/c++/6/algorithm:62: from /usr/include/c++/6/algorithm:62,
    3. /usr/include/arm-linux-gnueabihf/qt5/QtCore/qglobal.h:94: from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qglobal.h:94,
    4. /usr/include/arm-linux-gnueabihf/qt5/QtGui/qwindowdefs.h:43: from /usr/include/arm-linux-gnueabihf/qt5/QtGui/qwindowdefs.h:43,
    5. /usr/include/arm-linux-gnueabihf/qt5/QtWidgets/qwidget.h:43: from /usr/include/arm-linux-gnueabihf/qt5/QtWidgets/qwidget.h:43,
    6. /usr/include/arm-linux-gnueabihf/qt5/QtWidgets/qmainwindow.h:43: from /usr/include/arm-linux-gnueabihf/qt5/QtWidgets/qmainwindow.h:43,
    7. /usr/include/arm-linux-gnueabihf/qt5/QtWidgets/QMainWindow:1: from /usr/include/arm-linux-gnueabihf/qt5/QtWidgets/QMainWindow:1,
    8. /home/pi/MyAppFolder/application/MyApp/mainwindow.h:14: from ../MyApp/mainwindow.h:14,
    9. /home/pi/MyAppFolder/application/MyApp/main.cpp:1: from ../MyApp/main.cpp:1:
    10. /usr/include/c++/6/cstdlib:75: error: stdlib.h: No such file or directory
    11. #include_next <stdlib.h>
    To copy to clipboard, switch view to plain text mode 


    My .pro file is:
    Qt Code:
    1. #-------------------------------------------------
    2. #
    3. # Project created by QtCreator 2018-06-13T08:59:05
    4. #
    5. #-------------------------------------------------
    6.  
    7. QT += core gui
    8.  
    9. greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    10.  
    11. TARGET = MyApp
    12. TEMPLATE = app
    13.  
    14. # The following define makes your compiler emit warnings if you use
    15. # any feature of Qt which as been marked as deprecated (the exact warnings
    16. # depend on your compiler). Please consult the documentation of the
    17. # deprecated API in order to know how to port your code away from it.
    18. DEFINES += QT_DEPRECATED_WARNINGS
    19.  
    20. # You can also make your code fail to compile if you use deprecated APIs.
    21. # In order to do so, uncomment the following line.
    22. # You can also select to disable deprecated APIs only up to a certain version of Qt.
    23. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
    24.  
    25.  
    26. SOURCES += main.cpp\
    27. mainwindow.cpp \
    28. cbc.cpp \
    29. spi.cpp
    30.  
    31. HEADERS += mainwindow.h \
    32. cbc.h
    33.  
    34. FORMS += mainwindow.ui
    35.  
    36. #LIBS+=-L/usr/local/lib -lwiringPi
    37.  
    38. INCLUDEPATH+=/usr/include
    To copy to clipboard, switch view to plain text mode 

    My includes are:
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <stdint.h>
    5. #include <unistd.h>
    6. #include <stdio.h>
    7. #include <stdlib.h>
    8. #include <getopt.h>
    9. #include <fcntl.h>
    10. #include <linux/ioctl.h> //in spidev_test it is <sys/ioctl.h> but i don't have this header in sys folfder
    11. #include <linux/types.h>
    12. #include <linux/spi/spidev.h>
    13.  
    14. #include <QMainWindow>
    15. #include "qmessagebox.h"
    16. #include "qstorageinfo.h"
    17. #include "qstring.h"
    18. #include "qtextstream.h"
    19. //#include </root/wiringPi/wiringPi/wiringPiSPI.h>
    20. //#include </root/wiringPi/wiringPi/wiringPi.h>
    To copy to clipboard, switch view to plain text mode 

    If I remove INCLUDEPATH+=/usr/include from .pro file then include files can not be located.

    Can someone help me with this error.

    P.S. Another solution to this problem can be example of usage of wiringPiSPI for spidev1.0

    Thanks in advance!

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QT and SPI on Raspberry PI (include files problem)

    /usr/include/c++/6/cstdlib:75: error: stdlib.h: No such file or directory
    #include_next <stdlib.h>
    Your problem does not seem to be an issue with SPI but with your STL includes.
    Try using the form:
    Qt Code:
    1. //#include <stdint.h>
    2. //#include <unistd.h>
    3. //#include <stdio.h>
    4. //#include <stdlib.h>
    5. //#include <getopt.h>
    6. //#include <fcntl.h>
    7.  
    8. #include <stdint>
    9. #include <unistd>
    10. #include <stdio>
    11. #include <stdlib>
    12. #include <getopt>
    13. #include <fcntl>
    To copy to clipboard, switch view to plain text mode 

    And see if it helps.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jul 2018
    Posts
    3
    Qt products
    Qt5

    Default Re: QT and SPI on Raspberry PI (include files problem)

    Quote Originally Posted by high_flyer View Post
    Your problem does not seem to be an issue with SPI but with your STL includes.
    Try using the form:
    Qt Code:
    1. //#include <stdint.h>
    2. //#include <unistd.h>
    3. //#include <stdio.h>
    4. //#include <stdlib.h>
    5. //#include <getopt.h>
    6. //#include <fcntl.h>
    7.  
    8. #include <stdint>
    9. #include <unistd>
    10. #include <stdio>
    11. #include <stdlib>
    12. #include <getopt>
    13. #include <fcntl>
    To copy to clipboard, switch view to plain text mode 

    And see if it helps.

    Thank you for your reply.

    I have tried your solution but then I have got following error:

    Qt Code:
    1. In file included from ../MyApp/main.cpp:1:0:
    2. stdint: No such file or directory
    To copy to clipboard, switch view to plain text mode 

    I agree that the problem is with including standard headers but I do not know how to resolve this issue.

    Did I correctly write line in .pro file?
    Qt Code:
    1. INCLUDEPATH+=/usr/include
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jul 2018
    Posts
    3
    Qt products
    Qt5

    Default Re: QT and SPI on Raspberry PI (include files problem)

    I have solved the problem with STL includes.

    The INCLUDEPATH+=/usr/include line should be removed, but this path should be added to Tools->Options->C++->File Naming->Search Paths (add /usr/include).

    For SPI header linux/ioctl.h must be changed to sys/ioctl.h like in original spidev_test.c.

    After this modification I successfully tested SPI but now I am facing other problems with it. I can not call close() function and I can not change spidev1.0 mode to 1. I know that this is not a topic for this forum, so I will ask it somewhere elese but if someone has any ideas about my problem, please write.

    Best regards.

Similar Threads

  1. Replies: 5
    Last Post: 30th October 2012, 09:52
  2. Problem in Qt3D include files
    By lni in forum Qt Programming
    Replies: 0
    Last Post: 17th August 2011, 14:05
  3. Combining include files
    By marcvanriet in forum General Programming
    Replies: 12
    Last Post: 17th October 2010, 10:55
  4. qmake: include files?
    By Doug Broadwell in forum Newbie
    Replies: 2
    Last Post: 17th May 2007, 00:34
  5. problem with include files
    By JR in forum General Discussion
    Replies: 2
    Last Post: 22nd December 2006, 21:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.