orangepi-xunlong / wiringOP

wiringPi for Orange Pi
GNU Lesser General Public License v3.0
415 stars 192 forks source link

gcc can't compile blink example in Orange Pi Zero #41

Closed Chandler-Kluser closed 2 years ago

Chandler-Kluser commented 2 years ago

Trying to compile the example blink.c to the Orange Pi Zero: Captura-de-tela-de-2021-12-10-12-24-22.png

This is what I get from gcc:

root@orangepizero:~/blink# gcc main.c -o blink -lwiringPi -lwiringPiDev
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/10/../../../libwiringPi.so: undefined reference to `crypt'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/10/../../../libwiringPi.so: undefined reference to `rint'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/10/../../../libwiringPi.so: undefined reference to `pthread_join'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/10/../../../libwiringPi.so: undefined reference to `pthread_create'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/10/../../../libwiringPi.so: undefined reference to `pow'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/10/../../../libwiringPi.so: undefined reference to `shm_open'
/usr/bin/ld: /usr/lib/gcc/arm-linux-gnueabihf/10/../../../libwiringPi.so: undefined reference to `pthread_cancel'
collect2: error: ld returned 1 exit status
alexgubanow commented 2 years ago

Hi @Chandler-Kluser you are missing linker options, to be precise libraries. Please try add following args to gcc command: -lcrypto -lrt -lpthread Please close issue, once fix confirmed.

Chandler-Kluser commented 2 years ago

Haven't tried this, I have flashed another image, run apt update & apt upgrade as root before compiling it.

Problem solved, thanks to @alexgubanow