Can't read GPIO pins. ofxGPIO does not compile

Hi. RaspberryPi B, 512MB, 800Mhz, minibian.

I’ve coppied folder oxfGPIO to openFrameworks/addons
then

cd openFrameworks/addons/ofxGPIO/example-read-write
make

…and i got this:

../../../addons/ofxGPIO/src/smbus.cpp: In function ‘__s32 i2c_smbus_write_quick(int, __u8)’:
../../../addons/ofxGPIO/src/smbus.cpp:36:62: error: ‘NULL’ was not declared in this scope
     return i2c_smbus_access(file, value, 0, I2C_SMBUS_QUICK, NULL);
                                                              ^
../../../addons/ofxGPIO/src/smbus.cpp: In function ‘__s32 i2c_smbus_write_byte(int, __u8)’:
../../../addons/ofxGPIO/src/smbus.cpp:54:33: error: ‘NULL’ was not declared in this scope
                 I2C_SMBUS_BYTE, NULL);
                                 ^
../../../addons/ofxGPIO/src/smbus.cpp: In function ‘__s32 i2c_smbus_write_quick(int, __u8)’:
../../../addons/ofxGPIO/src/smbus.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
../../../addons/ofxGPIO/src/smbus.cpp: In function ‘__s32 i2c_smbus_write_byte(int, __u8)’:
../../../addons/ofxGPIO/src/smbus.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
../../../libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:335: recipe for target '../../../addons/obj/linuxarmv6l/Release/ofxGPIO/src/smbus.o' failed
make[1]: *** [../../../addons/obj/linuxarmv6l/Release/ofxGPIO/src/smbus.o] Error 1
make[1]: Leaving directory '/root/openFrameworks/addons/ofxGPIO/example-read-write'
../../../libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk:126: recipe for target 'Release' failed
make: *** [Release] Error 2

Hi mattc,

I can not help you with oxfGPIO, but I did several projects with wiringPi, which is easy to use and has a great website (http://wiringpi.com/) with explanations. I don’t know if you can switch, but I’ll describe nevertheless:

Just install wiringPi like described on the webpage (I did this on Pi B+ and Pi2 on different raspbians without ever any problems).
Then in the config.make of your OF app uncomment the line:
PROJECT_LDFLAGS=-Wl,-rpath=./libs (around line 80)

and add the line
PROJECT_LDFLAGS += -lwiringPi

Then in your ofApp.h add
#include “wiringPi.h”

That’s alrerady it.

1 Like

Thank you for your reply!
I had wiringPi installed but couldn’t use I didn’t know about changes in config.make.
Now it works perfectly!

Hi @mattc,

I read just now this alert, if you want to solve the problem before the release of ofxGPIO2
then just include in your source '#include <cstddef>' or replace ‘NULL’ with ‘nullptr’.

This happens when you use outdated definitions for C++11.

soon there will be a new release of ofxGPIO compatible with C++11 and jessie raspberry!

good day!

1 Like