The error message says to add libGL to the linker line. Did you do that?
How about this:https://wiki.archlinux.org/index.php/Fan_Speed_Control
It builds fine here. Look at that line in configure, what is there? Mine has the first half of what is in your error message, but not the second half - it looks like something got tacked on to the end of some lines in your configure script.
Also check /etc/profile and /etc/rc.local
You don't want to merge them, you just want to replace one with a link to the other. `man ln`
The actual errors would help - and the compile command you are using.That code compiles and runs fine here.
`pacman -S linux-headers`