Compiling C with wiringPi on Mate 20.x

I have installed correctly as per wiki instructions wiringPi on my M5.

It seems the installation went well since I can use commands such as:

gpio readall

However when I try to compile a simple program as follows:

gcc -Wall -lwiringPi -lwiringPiDev blink.c -o blink

I get many errors including:

"undefined reference to ‘wiringPiSetup’

It seems I am missing a link somewhere but where?

Here is an update to the above. In order to compile properly c code which includes wiring pi do:

gcc -Wall -o ~/Documents/blink-bpi ~/Documents/blink-bpi.c -lwiringPi -lm -lcrypt -lrt

Some of the above options do not seem to be needed, at least for the blink.c program but may be needed when your c code includes other wiringpi options.

Also so far the, resulting compiled file needs to be run with sudo.

sudo ./blink