Hello everyone!!
I have installed the Wiring Pi library in my RPi3, using a git from the official site. However, I get the same error whenever I try to compile ANY C FILE (including the examples from the library).
So, for example, if I want to compile the blink.c example (which just blinks an LED):
nicolas@nicolas-X510UAR:~/wiringPi/examples$ gcc blink.c -o blink -lwiringPi
I get:
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwiringPi.so: undefined reference to `crypt'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwiringPi.so: undefined reference to `rint'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwiringPi.so: undefined reference to `pthread_join'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwiringPi.so: undefined reference to `pthread_create'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwiringPi.so: undefined reference to `pow'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwiringPi.so: undefined reference to `shm_open'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libwiringPi.so: undefined reference to `pthread_cancel'
collect2: error: ld returned 1 exit status
What I am supposed to do? I have already re installed and built the library, and it does not change.
Please help!! Thank you!!!!!!!!
Re: Error when compiling a .c file using WiringPi library
Perhaps
gcc -pthread blink.c -o blink -lwiringPi
gcc -pthread blink.c -o blink -lwiringPi
Re: Error when compiling a .c file using WiringPi library
You need to learn to use the manual pages...
man crypt...
Note the last line "Link with -lcrypt"
So now we have "gcc -pthread blink.c -o blink -lcrypt -lm -lrt -lwiringPi"
The order of the libraries might be wrong, but give that a try ans see what you get....
PeterO
man crypt...
Code: Select all
CRYPT(3) Linux Programmer's Manual CRYPT(3)
NAME
crypt, crypt_r - password and data encryption
SYNOPSIS
#define _XOPEN_SOURCE /* See feature_test_macros(7) */
#include <unistd.h>
char *crypt(const char *key, const char *salt);
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <crypt.h>
char *crypt_r(const char *key, const char *salt,
struct crypt_data *data);
Link with -lcrypt.
Code: Select all
RINT(3) Linux Programmer's Manual RINT(3)
NAME
nearbyint, nearbyintf, nearbyintl, rint, rintf, rintl - round to near‐
est integer
SYNOPSIS
#include <math.h>
double nearbyint(double x);
float nearbyintf(float x);
long double nearbyintl(long double x);
double rint(double x);
float rintf(float x);
long double rintl(long double x);
Link with -lm.
Code: Select all
POW(3) Linux Programmer's Manual POW(3)
NAME
pow, powf, powl - power functions
SYNOPSIS
#include <math.h>
double pow(double x, double y);
float powf(float x, float y);
long double powl(long double x, long double y);
Link with -lm.
Code: Select all
SHM_OPEN(3) Linux Programmer's Manual SHM_OPEN(3)
NAME
shm_open, shm_unlink - create/open or unlink POSIX shared memory
objects
SYNOPSIS
#include <sys/mman.h>
#include <sys/stat.h> /* For mode constants */
#include <fcntl.h> /* For O_* constants */
int shm_open(const char *name, int oflag, mode_t mode);
int shm_unlink(const char *name);
Link with -lrt.
The order of the libraries might be wrong, but give that a try ans see what you get....
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson
Re: Error when compiling a .c file using WiringPi library
Thanks to all of you, sorry for such a stupid question ( I imagine it is).
It worked with:
nicolas@nicolas-X510UAR:~/wiringPi/examples$ gcc blink.c -o blink -pthread -lwiringPi -lm -lrt -lcrypt
Now, I just cant understand why it stopped working from one day to the other, as i did not have to link these functions before.
Thanks
It worked with:
nicolas@nicolas-X510UAR:~/wiringPi/examples$ gcc blink.c -o blink -pthread -lwiringPi -lm -lrt -lcrypt
Now, I just cant understand why it stopped working from one day to the other, as i did not have to link these functions before.
Thanks
Re: Error when compiling a .c file using WiringPi library
You might have been able to just use -pthread. The libraries which are automatically loaded change from time to time, not randomly, but as the libraries which need them are themselves updated.
Re: Error when compiling a .c file using WiringPi library
It did not seem to work with p thread only. Alright, thank you for the info!