我碰到一个奇怪的“未定义的引用”编译错误,我似乎无法找到一个解决方案。 我想配置/使用Yocto计划生成的ARM编译器来编译PAM 1.1.6我Gumstix Overo(ARM-狭小-Linux的gnueabi-GCC),但我一直在编译过程中收到以下错误:
.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
所以,我做了一些调查,结果发现,在配置的时候,下面的测试代码被编译并执行,以确定ruserok,ruserok_af和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 __cplusplus
extern "C"
#endif
char $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___$2
choke me
#endif
int
main ()
{
return $2 ();
;
return 0;
}
所以,我复制,粘贴(更换所有的$ 2'S与ruserok)和编译使用生成的GCC编译器的代码
./arm-poky-linux-gnueabi-gcc -o test.o test.c
看是否做/不存在ruserok,ruserok_af和iuserok功能,并且我收到以下编译错误:
/tmp/ccU8YszI.o: In function `main':
test.c:(.text+0x8): undefined reference to `ruserok'
collect2: error: ld returned 1 exit status
其中,是相同的“未定义参考`ruserok”错误如上。 作为一个全面的检查,因为我此前通过安装Ubuntu软件中心Ubuntu的/ Linaro的ARM GCC编译器,我编译臂Linux的gnueabi-gcc编译同样的代码,但是代码编译罚款没有任何错误。 在这里,我借鉴的命令:
arm-linux-gnueabi-gcc -o test.o test.c