compiler-construction - 未定义对ruserok错误的引用

我遇到了一个奇怪的“ undefined reference ”编译错误,我似乎找不到解决方法。我正在尝试使用Yocto Project生成的ARM编译器(arm-poky-linux-gnueabi-gcc)为我的Gumstix Overo配置/编译PAM 1.1.6,但在编译过程中始终出现以下错误:

.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替换为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编译器,因此我使用arm-linux-gnueabi-gcc编译器编译了相同的代码,但是代码编译良好,没有任何错误。这是我引用的命令:
arm-linux-gnueabi-gcc -o test.o test.c

因此,我的问题是:为什么一个编译器会产生“对ruserok的 undefined reference ”错误,而另一个编译器却不会?或以不同的方式询问,两个编译器之间的区别是,一个编译器将产生“未定义对ruserok的引用”错误?

最佳答案

编译器(尤其是gcc)不仅仅是代码生成器。他们非常熟悉 libc 或标准C库,以及 libgcc 编译器帮助程序库。常规命令行隐式使用-lc(与 libc 链接)。 Ubuntu的arm-linux-gnueabi-gcc是一个带有eglibc的crosstool-ng构建。

我不知道Poky gcc是什么。您可能会提供指向从何处获得编译器的链接。从Poky configuration link看来,编译器是一个multi-lib发行版或诸如此类的东西,可能还需要执行其他步骤来配置交叉构建。

问题的答案,

Why would one compiler produce an "undefined reference to ruserok" error, while the other does not?



因为一个库中有ruserok,而另一个则没有(或未配置为查看)。

https://stackoverflow.com/questions/15890007/

相关文章:

compiler-errors - 来自gtest-all.cc的Google测试编译错误

vba - 具有多个条件的Select Case函数不循环

android - 如何解决java.lang.NoClassDefFoundError

android - Android Studio 0.2.1错误

compiler-errors - 错误: no newline at end of file [-

visual-c++ - 如何针对VES2008编译Greta?

xcode - Intel C++编译器,无法在OS X上打开stdarg.h

perl - "error: variable length array of non-POD el

python - python err : Local variable referenced be

android - 如何解决Java Eclipse中的 “The hierarchy of the