Compiler and library support for the ISO C++ 2011 standard
I am trying to create an i2c communication in raspbery Pi(debian wheezy) using Qt creator with rpi-hw library. I successfully compiled and installed the rpi-hw library in my linux system. But when I try to include this in my Qt. Got the following errors.
/usr/include/c++/4.7/bits/c++0x_warning.h:32: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
/usr/include/rpi-hw.hpp:159: In file included from /usr/include/rpi-hw.hpp:159:0,
/home/pi/untitled/main.cpp:2: from ../untitled/main.cpp:2:
/usr/include/rpi-hw/types.hpp:32: error: 'std::int8_t' has not been declared
/usr/include/rpi-hw/types.hpp:33: error: 'std::int16_t' has not been declared
/usr/include/rpi-hw/types.hpp:34: error: 'std::int32_t' has not been declared
/usr/include/rpi-hw/types.hpp:35: error: 'std::int64_t' has not been declared
/usr/include/rpi-hw/types.hpp:37: error: 'std::uint8_t' has not been declared
Any one know how to fix this in my Qt creator. I tried to add -std=gnu++11 in Projects->Build Steps-> Additional arguments but no luck
Please help.
Re: Compiler and library support for the ISO C++ 2011 standard
Add to the .pro file
Cheers,
_
Re: Compiler and library support for the ISO C++ 2011 standard
Quote:
Originally Posted by
anda_skoa
Add to the .pro file
Cheers,
_
I tried with CONFIG += c++11 in my .pro file but still the same error is showing.
My .pro file will looks like this
Code:
TEMPLATE = app
CONFIG += console
CONFIG -= qt
CONFIG += C++11
SOURCES += main.cpp
#unix:!macx:!symbian: LIBS += -L$$PWD/../Desktop/Rpi-hw-master/build/ -lrpihw
#INCLUDEPATH += $$PWD/../Desktop/Rpi-hw-master/include/rpi-hw
#DEPENDPATH += $$PWD/../Desktop/Rpi-hw-master/include/rpi-hw
unix:!macx:!symbian: LIBS += -lrpihw
and my CPP file
Code:
#include <iostream>
#include <rpi-hw.hpp>
#include <rpi-hw/driver/i2c.hpp>
using namespace std;
using namespace rpihw;
#define ID_I2C_SLAVE_ADDRESS 0x20
#define ID_I2C_DEV_PATH "/dev/i2c-0"
int main()
{
rpihw::driver::i2c objI2C(ID_I2C_DEV_PATH, ID_I2C_SLAVE_ADDRESS);
char *chData;
int iSize=0;
objI2C.write(chData, iSize);
cout << "Hello World!" << endl;
return 0;
}
Re: Compiler and library support for the ISO C++ 2011 standard
I solved it myself by adding the following in my PRO files
QMAKE_CXXFLAGS += -std=c++11
Determine which flags are required by compiler (and it looks like the error message makes two suggestions). I am posting this here for any one who need this in future.