I've run into a strange "undefined reference to" compile error that I cannot seem to find a resolution for. I'm trying to configure/compile PAM 1.1.6 for my Gumstix Overo using the Yocto Project generated ARM compiler (arm-poky-linux-gnueabi-gcc), but I keep getting the following error during compilation:
.libs/pam_rhosts.o: In function `pam_sm_authenticate':modules/pam_rhosts/pam_rhosts.c:117: undefined reference to `ruserok'collect2: error: ld returned 1 exit status
So, I did a some investigating and found out that during configure, the following test code is compiled and executed to determine the availability of ruserok, ruserok_af and iruserok.
/* end confdefs.h. *//* Define $2 to an innocuous variant, in case <limits.h> declares $2. For example, HP-UX 11i <limits.h> declares gettimeofday. */#define $2 innocuous_$2/* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer <limits.h> to <assert.h> if __STDC__ is defined, since<limits.h> exists even on freestanding compilers. */#ifdef __STDC__# include <limits.h>#else# include <assert.h>#endif#undef $2/* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */#ifdef __cplusplusextern "C"#endifchar $2 ();/* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */#if defined __stub_$2 || defined __stub___$2choke me#endifintmain (){return $2 (); ; return 0;}
So, I copied, pasted (replacing all of the $2's with ruserok) and compiled this code using the generated GCC compiler
./arm-poky-linux-gnueabi-gcc -o test.o test.c
to see if the ruserok, ruserok_af and iuserok functions do/don't exist, and I received the following compilation error:
/tmp/ccU8YszI.o: In function `main':test.c:(.text+0x8): undefined reference to `ruserok'collect2: error: ld returned 1 exit status
which, is the same "undefined reference to `ruserok'" error as above. As a sanity check, since I had installed the Ubuntu/Linaro ARM GCC compiler through the Ubuntu Software center earlier, I compiled the same code with the arm-linux-gnueabi-gcc compiler, but the code compiled fine without any errors. Here the command I used for reference:
arm-linux-gnueabi-gcc -o test.o test.c