未定义对 ruserok 错误的引用 [英] undefined reference to ruserok error

查看:35
本文介绍了未定义对 ruserok 错误的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个奇怪的未定义引用"编译错误,我似乎找不到解决方法.我正在尝试使用 Yocto Project 生成的 ARM 编译器 (arm-poky-linux-gnueabi-gcc) 为我的 Gumstix Overo 配置/编译 PAM 1.1.6,但在编译过程中我不断收到以下错误:

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

所以,我做了一些调查,发现在配置过程中,编译并执行了以下测试代码,以确定 ruserok、ruserok_af 和 iruserok 的可用性.

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 __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 编译器编译了这段代码

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

查看 ruserok、ruserok_af 和 iuserok 函数是否存在,我收到以下编译错误:

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

与上面的未定义对 `ruserok' 的引用相同"错误.作为一个健全的检查,由于我之前通过 Ubuntu 软件中心安装了 Ubuntu/Linaro ARM GCC 编译器,所以我使用 arm-linux-gnueabi-gcc 编译器编译了相同的代码,但编译的代码没有任何错误.这里是我用来参考的命令:

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

所以,我的问题是:为什么一个编译器会产生未定义的 ruserok 引用"错误,而另一个不会?或者换一种问法,两个编译器有什么区别,一个编译器会产生未定义的ruserok引用"错误?

推荐答案

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

Compilers (and in particular gcc) are more than just code generators. They are intimately familiar with the libc, or standard C library and also the libgcc compiler helper library. General command lines implicitly use -lc (link with libc). The arm-linux-gnueabi-gcc from Ubuntu is a crosstool-ng build with an eglibc.

我不知道 Poky gcc 是关于.您可能会提供指向您从何处获得编译器的链接.来自 Poky 配置链接,似乎编译器是一个多库发行版或其他东西,您可能需要执行其他步骤来配置 cross-build.

I have no idea what the Poky gcc is about. You might provide a link to where you got the compiler from. From the Poky configuration link, it seems that the compiler is a mult-lib distribution or something and there are probably additional steps that you need to perform to configure the cross-build.

问题的答案,

为什么一个编译器会产生未定义的 ruserok 引用"错误,而另一个不会?

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

因为一个库中有 ruserok 而另一个没有(或未配置为查看它).

Because one has ruserok in the library and the other doesn't (or isn't configured to see it).

这篇关于未定义对 ruserok 错误的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆