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

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

问题描述

我遇到了一个奇怪的未定义引用"编译错误,我似乎找不到解决方法.我正在尝试使用 Yocto 项目生成的 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

所以,我做了一些调查,发现在configure过程中,会编译并执行以下测试代码来确定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;
}

所以,我复制、粘贴(用 ruserok 替换所有 $2)并使用生成的 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 的未定义引用"错误,而另一个则不会?或者换个角度问,一个编译器会产生undefined reference to 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 配置链接,似乎编译器是一个多库发行版或其他东西,您可能需要执行其他步骤来配置交叉构建.

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天全站免登陆