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!