2

Good day and happy new year! I actually have a lot of difficulties to solve an issue that I have, may be due to my lacke of knowloedge with C++

I dowloaded and installed a library, on a Raspberry Zero W, to get Radio package and another one to display message on a OLED LCD. RadioHead OLED Both work fine independently.

However, when I receive a Radio data on my Raspberry, I would like to display it on my LCD display.

Let me to provide you the maximum of detail:

First keep in mind that after installing ArduiPi_OLED, some files are copied in /usr/local/include and usr/local/lib/

/usr/local/lib $ ls -ls
total 144
 0 lrwxrwxrwx 1 root staff    22 Jan  6 22:54 ArduiPi_OLED.so.1 -> libArduiPi_OLED.so.1.0
 0 lrwxrwxrwx 1 root staff    37 Jan  6 22:54 libArduiPi_OLED.so -> /usr/local/lib/libArduiPi_OLED.so.1.0
 0 lrwxrwxrwx 1 root staff    37 Jan  6 22:54 libArduiPi_OLED.so.1 -> /usr/local/lib/libArduiPi_OLED.so.1.0
64 -rwxr-xr-x 1 root staff 62692 Jan  6 22:54 libArduiPi_OLED.so.1.0
68 -rw-r--r-- 1 root staff 67576 Jan  7 19:41 libbcm2835.a
 4 drwxrwsr-x 3 root staff  4096 Sep  7 17:39 pypy2.7
 4 drwxrwsr-x 4 root staff  4096 Dec 31 01:08 python2.7
 4 drwxrwsr-x 3 root staff  4096 Sep  7 17:02 python3.5

/usr/local/inlcude:

ls -ls /usr/local/include/
total 100
 4 -rw-r--r-- 1 root staff  3931 Jan  6 22:54 Adafruit_GFX.h
 8 -rw-r--r-- 1 root staff  7272 Jan  6 22:54 ArduiPi_OLED.h
 4 -rw-r--r-- 1 root staff  2474 Jan  6 22:54 ArduiPi_OLED_lib.h
84 -rw-r--r-- 1 root staff 82921 Jan  7 19:41 bcm2835.h

To lunch the script which will listen the data sent by the Radio sender module, I launch the following script after compiling it rf95_server (and it works fine)

As I want to print some small text from the received Radio package, I started by adding the folloiwing in rf95_server.cpp

// For OLED LCD
#include "ArduiPi_OLED_lib.h"
#include "Adafruit_GFX.h"
#include "ArduiPi_OLED.h"
#include <getopt.h>
// Instantiate the display
ArduiPi_OLED display;

and then I compiled from

cd RadioHead/examples/raspi/rf95
sudo make

Unfortunately, my terminal printed me the following message:

g++ rf95_server.o RH_RF95.o RasPi.o RHHardwareSPI.o RHGenericDriver.o RHGenericSPI.o RHSPIDriver.o -lbcm2835 -o rf95_server rf95_server.o: In function __static_initialization_and_destruction_0(int, int)': rf95_server.cpp:(.text+0x438): undefined reference to ArduiPi_OLED::ArduiPi_OLED()' rf95_server.o: In function Adafruit_GFX::~Adafruit_GFX()': rf95_server.cpp:(.text._ZN12Adafruit_GFXD2Ev[_ZN12Adafruit_GFXD5Ev]+0x30): undefined reference tovtable for Adafruit_GFX' rf95_server.o: In function ArduiPi_OLED::~ArduiPi_OLED()': rf95_server.cpp:(.text._ZN12ArduiPi_OLEDD2Ev[_ZN12ArduiPi_OLEDD5Ev]+0x38): undefined reference tovtable for ArduiPi_OLED' collect2: error: ld returned 1 exit status Makefile:45: recipe for target 'rf95_server' failed make: *** [rf95_server] Error 1

If I comment the following

ArduiPi_OLED display;

There is no error message.

I supposed that the problem is because my rf95_server.cpp can not find a reference to the ArduiPi_OLED library and this is my problem because I do not know how to do it.

First I look to add an option to my make command as

sudo make -I [path-of-ArduiPi_OLED]

I do not know if -I is the correct I do not know how to format the path

  1. /usr/local/inlcude?
  2. /usr/local/bin?
  3. ~/Soft/RadioHead/example/raspi/rf95?

I also tried to modify the Makefile by adding the following before INCLUDE and by modifying the INCLUDE line as the following:

OLEDBASE = ../../../../ArduiPi_OLED
INCLUDE = -I$(RADIOHEADBASE) -I$(OLEDBASE)

but none of this works.

So my question: How can I include ArduiPi_OLED to a rf95_server.cpp script which "belong" to radioHead?

Many Many thank for you help

martin10
  • 187
  • 3
  • 16

1 Answers1

2

I think you forgot to link against the ArduiPi_OLED library. You need to modify your LIBS variable in your makefile:

LIBS = -lbcm2835 -lArduiPi_OLED

Also if you include the library headers with #include <ArduiPi_OLED.h> the compiler will automatically look for the headers in the system paths like /usr/local/include. (See this thread for example)

Mike van Dyke
  • 2,724
  • 3
  • 16
  • 31
  • Dear Mike, Great! Thank a lot. It's help but it generate a new message error: //usr/local/lib/libArduiPi_OLED.so : référence indéfinie vers « i2c_smbus_write_i2c_block_data » //usr/local/lib/libArduiPi_OLED.so : référence indéfinie vers « i2c_smbus_write_word_data » //usr/local/lib/libArduiPi_OLED.so : référence indéfinie vers « i2c_smbus_write_byte_data ». Should I do similar? The problem I do not have such file in /usr/local/include – martin10 Jan 08 '18 at 20:12
  • Dear Mike, No it works, I can compile!!! The problem were somewhere else. Previously I install some Python library to display message on my OLED. But I was trying to use the OLD with c++ as well. I also observed an issue with OLED stating somehting about i2c_smbus, as well. I reinstalled my Raspbery from scratch without Python and I applied your proposition and I can compile the RadioLibrary. So that great, thank for your solution and I will continue!!. Cheers – martin10 Jan 08 '18 at 22:33