Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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.
Posted
Comments
Sergey Alexandrovich Kryukov 6-May-14 1:44am    
What's the point of your question?! The errors shown for C++ prior to C++11 are irrelevant to the problem.
You should have shown the errors you have after you added -std=gnu+11 or -std=c++11. Wasn't that obvious? When you say "no luck", you should have explained what went wrong.
—SA
Arun Kumar K S 6-May-14 3:28am    
I tried to add -std=gnu++11 in Projects->Build Steps-> Additional arguments in Qt creator but that didn't solved the error.
Sergey Alexandrovich Kryukov 6-May-14 3:30am    
We already knew that. Well, if you don't want to report these important detail on the errors you get, don't... :-) But aren't you trying to get some help?
—SA
Arun Kumar K S 6-May-14 3:41am    
When I add -std=gnu++11 the compiler output like this<br>
 <br>
<br>
07:36:03: The process "/usr/bin/qmake-qt4" exited with code 1.<br>
Error while building/deploying project untitled (target: Embedded Linux)<br>
When executing step 'qmake'

I added LIBS += -lrpihw library in pro file


and my main function is

#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;
}

and my RPi-hw library from https://github.com/Wicker25/Rpi-hw

Do I need to add any more information

1 solution

I use the following in my PRO files


Quote:
QMAKE_CXXFLAGS += -std=c++0x


Determine which flags are required by your compiler (and it looks like your error message makes two suggestions).
 
Share this answer
 
Comments
Arun Kumar K S 9-May-14 1:41am    
Many thanks...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900