Page 1 of 1

Getting problem when using wiringPiSetup()

Posted: Thu Apr 17, 2014 7:27 am
by hariprasad
Hai to all,
I am writing code to access the gpio from the Qt, and i was included the wiringPi library to Qt also..
Now my problem is when i write the setup function i.e wiringPiSetup() in mainwindow.cpp file and run, it is saying..

"Starting /home/pi/Desktop/Qtprojects/pi_lcd/....
wiringPiSetup: Must be root. (Did you forget sudo?)
/home/pi/Desktop/Qtprojects/pi_lcd/pi_lcd exited with code 1"

How to set the root permissions for the function or for wiringPi..
Please help me...
Thanks in advance..

Re: Getting problem when using wiringPiSetup()

Posted: Thu Apr 17, 2014 5:10 pm
by Tarcas
Call it with sudo. You need to execute your Python script as sudo python myscrypt.py
Sudo means "I want the root user to execute the following command." Think of it as meaning SuperUser (aka root) DO this.

Re: Getting problem when using wiringPiSetup()

Posted: Fri Apr 18, 2014 6:47 am
by hariprasad
Thank you for the reply..

I am writing code in Qt and i want to know how to set the root permissions for it to access..

Thanks in advance..

Re: Getting problem when using wiringPiSetup()

Posted: Sat Apr 19, 2014 5:01 am
by Tarcas
I don't know QT, but with other languages I've used, if you execute your program as root (using sudo in front of whatever command you normally use to execute it) the whole program gets root permissions, and can therefore use the GPIO functions.

So if your normal command is:
qt program
you would run it as root by executing:
sudo qt program