bitbank2 / ss_oled

Simple and small library to control 1-bpp OLED displays (Linux + Arduino)
GNU General Public License v3.0
190 stars 34 forks source link

how to install the lib on the Raspberry Pi? (Raspi OS Stretch) #48

Closed dsyleixa closed 3 years ago

dsyleixa commented 3 years ago

hi, how to install the lib on the Raspberry Pi? (Raspi OS Stretch)

bitbank2 commented 3 years ago

In the linux folder is a makefile which will build a standard static library. You'll link it to your code by adding -lss_oled to your linker flags.

dsyleixa commented 3 years ago

I tried that but it failed: I copied the ss_oled folder into /home/pi, then cd ss_oled then cd linux

pi@PiStr:~/ss_oled/linux $ make
make: Warnung: Datei „makefile“ hat hat in der Zukunft liegende Änderungszeit 6835
cc -c -Wall -O2 -I../src -D_LINUX_ ss_oled.c
In file included from ../src/ss_oled.cpp:47:0,
                 from ss_oled.c:4:
../src/ss_oled.h:4:25: fatal error: BitBang_I2C.h: Datei oder Verzeichnis nicht gefunden
 #include <BitBang_I2C.h>
                         ^
compilation terminated.
makefile:12: die Regel für Ziel „ss_oled.o“ scheiterte
make: *** [ss_oled.o] Fehler 1

I checked, but in ssoled/linux/ both ss_oled .h and ss_oled.cpp are present though.

bitbank2 commented 3 years ago

You need to build BitBang_I2C first; it will install the include file so that it can be found by ss_oled.

dsyleixa commented 3 years ago

How shall I do "build BitBang_I2C first;" ?

bitbank2 commented 3 years ago

git clone https://github.com/bitbank2/BitBang_I2C cd BitBang_I2C/linux make

dsyleixa commented 3 years ago

aah, the other lib in the other repo...

ok, there was just 1 issue then about the clock (mine is actually correct though):

pi@PiStr:~/BitBang_I2C/linux $ make
make: Warnung: Datei „makefile“ hat hat in der Zukunft liegende Änderungszeit 7015
cc -c -Wall -O2 -I../src -D_LINUX_ BitBang_I2C.c
ar -rc libBitBang_I2C.a BitBang_I2C.o ;\
sudo cp libBitBang_I2C.a /usr/local/lib ;\
sudo cp ../src/BitBang_I2C.h /usr/local/include
make: Warnung: Mit der Uhr stimmt etwas nicht. 
         Der Bauauftrag könnte unvollständig sein.
dsyleixa commented 3 years ago

then again make in the ss_oled folder: same date issue:

pi@PiStr:~/ss_oled/linux $ make
make: Warnung: Datei „makefile“ hat hat in der Zukunft liegende Änderungszeit 4578
cc -c -Wall -O2 -I../src -D_LINUX_ ss_oled.c
ar -rc libss_oled.a ss_oled.o ;\
sudo cp libss_oled.a /usr/local/lib ;\
sudo cp ../src/ss_oled.h /usr/local/include
make: Warnung: Mit der Uhr stimmt etwas nicht. 
         Der Bauauftrag könnte unvollständig sein.
bitbank2 commented 3 years ago

I'm sorry, but this isn't a bug in the library or makefile. Github issues are not meant for tutoring people on how to use Linux.

I don't know German and I'm not sure what that error is about.

dsyleixa commented 3 years ago

it says that the makefile has a wrong date, but then it's probably a mistake in the github repo.

so update: into which directory do I have to copy ss_oled.h and the entire ss_oled folder that the lnker finds it by

include

g++ -o -lss_oled ? perhaps /usr/include? or /usr/include/libraries?

dsyleixa commented 3 years ago

if I start compilation of "sample.c" in the linux folder itself in /home/pi/ss_oled/linux then it fails:

g++ -Wall -I/opt/vc/include -o  "sample" "sample.c" -pthread -I/opt/vc/include -lshapes -lwiringPi -lpigpio -lrt $(pkg-config eigen3 --cflags) -lreadline -lss_oled (im Verzeichnis: /home/pi/ss_oled/linux)
sample.c: In function ‘int main(int, char**)’:
sample.c:35:68: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
   oledWriteString(&ssoled, 0,0,1,"SS_OLED Library!",FONT_NORMAL,0,1);
                                                                    ^
sample.c:36:55: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
   oledWriteString(&ssoled, 0,3,2,"BIG!",FONT_LARGE,0,1);
                                                       ^
sample.c:37:57: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
   oledWriteString(&ssoled, 0,0,5,"Small", FONT_SMALL,0,1);
                                                         ^
/tmp/cc5dlFhB.o: In function `main':
sample.c:(.text+0xa8): undefined reference to `oledInit(ssoleds*, int, int, int, int, int, int, int, int, int)'
sample.c:(.text+0xe8): undefined reference to `oledSetBackBuffer(ssoleds*, unsigned char*)'
sample.c:(.text+0xf8): undefined reference to `oledFill(ssoleds*, unsigned char, int)'
sample.c:(.text+0x13c): undefined reference to `oledWriteString(ssoleds*, int, int, int, char*, int, int, int)'
sample.c:(.text+0x170): undefined reference to `oledWriteString(ssoleds*, int, int, int, char*, int, int, int)'
sample.c:(.text+0x1a4): undefined reference to `oledWriteString(ssoleds*, int, int, int, char*, int, int, int)'
sample.c:(.text+0x1d8): undefined reference to `oledWriteString(ssoleds*, int, int, int, char*, int, int, int)'
sample.c:(.text+0x20c): undefined reference to `oledSetPixel(ssoleds*, int, int, unsigned char, int)'
sample.c:(.text+0x230): undefined reference to `oledSetPixel(ssoleds*, int, int, unsigned char, int)'
sample.c:(.text+0x258): undefined reference to `oledPower(ssoleds*, unsigned char)'
collect2: error: ld returned 1 exit status
Kompilierung fehlgeschlagen.
bitbank2 commented 3 years ago

That error makes no sense. There's not an error in the repo. You need to run the makefile which will copy the library (.a) and (.h) files into the proper linux directories to be found by other projects. You do not need to manually copy anything. 1) make BitBang_I2C 2) make ss_oled 3) make your project

dsyleixa commented 3 years ago
make BitBang_I2C <== did that
make ss_oled <== did that

make your project <== compiled my file by the command line:

g++ -Wall -I/opt/vc/include -o "sample" "sample.c" -pthread -I/opt/vc/include -lshapes -lwiringPi -lpigpio -lrt $(pkg-config eigen3 --cflags) -lreadline -lss_oled

bitbank2 commented 3 years ago

This is definitely the wrong place to be chatting back and forth. contact me on Twitter Direct Messaging (@fast_code_r_us)

dsyleixa commented 3 years ago

I don't have a twitter account

dsyleixa commented 3 years ago

perhaps into which directory do I have to copy ss_oled.h and the entire ss_oled folder additionally so that the linker finds it by

include

g++ -o -lss_oled ? perhaps /usr/include? or /usr/include/libraries?

bitbank2 commented 3 years ago

Have you successfully built the simple examples (C) using the provided makefile?

dsyleixa commented 3 years ago

I have typed "make" in the linux folder, but there are no executables, just libss_oled.a // << typo makefile make_samples multi_oled.h sample.c sample.o speed_test.c ss_oled.c ss_oled.o

bitbank2 commented 3 years ago

make -f make_samples You need to look a little better

dsyleixa commented 3 years ago

sorry, I never use make by myself...

so, update:


pi@PiStr:~/ss_oled/linux $ make -f make_samples
make: Warnung: Datei „make_samples“ hat hat in der Zukunft liegende Änderungszeit 2849
cc -c -Wall -O2 -D_LINUX_ sample.c
cc sample.o -lss_oled -lpigpio -lBitBang_I2C -lm -lpthread -o sample
cc -c -Wall -O2 -D_LINUX_ multi_oled.c
cc multi_oled.o -lss_oled -lpigpio -lBitBang_I2C -lm -lpthread -o multi
cc -c -Wall -O2 -D_LINUX_ speed_test.c
cc speed_test.o -lss_oled -lpigpio -lBitBang_I2C -lm -lpthread -o speed
make: Warnung: Mit der Uhr stimmt etwas nicht. 
         Der Bauauftrag könnte unvollständig sein.
pi@PiStr:~/ss_oled/linux $ ./sample
2021-04-18 19:55:40 initCheckPermitted: 
+---------------------------------------------------------+
|Sorry, you don't have permission to run this program.    |
|Try running as root, e.g. precede the command with sudo. |
+---------------------------------------------------------+

pigpio failed to initialize
2021-04-18 19:55:40 initCheckPermitted: 
+---------------------------------------------------------+
|Sorry, you don't have permission to run this program.    |
|Try running as root, e.g. precede the command with sudo. |
+---------------------------------------------------------+

pigpio failed to initialize
2021-04-18 19:55:40 initCheckPermitted: 
+---------------------------------------------------------+
|Sorry, you don't have permission to run this program.    |
|Try running as root, e.g. precede the command with sudo. |
+---------------------------------------------------------+

pigpio failed to initialize
Unable to initialize I2C bus 0-2, please check your connections and verify the device address by typing 'i2cdetect -y <channel>
dsyleixa commented 3 years ago

ah, ok sudo needed... now it shows the "hello" screen! Thank you, looking forward!

dsyleixa commented 3 years ago

...but still failes when trying to compile just from the terminal by command line g++ -o -lss_oled ..... (see https://github.com/bitbank2/ss_oled/issues/48#issuecomment-822029621)

bitbank2 commented 3 years ago

My library is C code, not C++. The function names get 'mangled' by C++ compared to C, that's why it won't link. You need to find the solution to that problem. Github issues is not a tutoring service.

dsyleixa commented 3 years ago

ok, I need that oled lib also for my g++ projects to be included. So I'm afraid I have to abandon that, unfortunately.

bitbank2 commented 3 years ago

You really do need a lot of help. You can easily link ss_oled (as C code) with your C++ project. All you need to do is add 'extern "C"' to the function names. You need to read a bit more on C/C++ programming.

dsyleixa commented 3 years ago

well, as stated, I'm a beginner, and I do not know all that stuff. I just need a lib to be #included into my .c and .cpp program files (like e.g. wiringPi or pigpio , which are also plain C but can be easily linked also into C++ programs), but thank you very much.

bitbank2 commented 3 years ago

As I stated repeatedly. Your lack of experience in programming is not a valid reason to spam my github issues. You opened an issue for a problem which does not exist - I closed it. Then you opened another issue for a problem which does not exist - I closed it. Now you want me to teach you how to program. This is the problem with your activities here, not the fact that you need help.

dsyleixa commented 3 years ago

no, I don't want you to teach me anything, and I am not spamming. My attempts for installing failed because the instructions were unclear to me, and now as it turns out that I can't use the lib I have to abandon it. Sorry for the inconvenience.

bitbank2 commented 3 years ago

You don't have to abandon it. As I said, you just need to learn a bit more about C/C++ interfacing. It's an extremely simple problem to fix. Also, this library is not well documented because I abandoned it a long time ago. Current efforts for controlling 1-bit displays have moved to my OneBitDisplay library. It has a very detailed Wiki and lots of examples/instructions.

dsyleixa commented 3 years ago

checked it meanwhile, but the wrapper

if defined (__cplusplus)

} / extern C /

endif

is already written in the ss_OLED.h file

I again tried to rebuild by make -f make_samples(with or without sudo) but now even that failes because "make" can't find ss_OLED.h any more. I give up, actually a really extensive installation description is needed, especially for people using Linux and g++