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

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

问题描述

我碰到一个奇怪的未定义的引用编译错误,我似乎无法找到的分辨率。我试图配置/使用Yocto项目产生的ARM编译器来编译PAM 1.1.6的Gumstix我Overo(ARM-狭小-Linux的gnueabi-GCC),但我一直在编译过程中收到以下错误:

 的.libs / pam_rhosts.o:在函数'的pam_sm_authenticate:
模块/ pam_rhosts / pam_rhosts.c:117:未定义的参考`ruserok
collect2:错误:LD返回1退出状态

所以,我做了一些调查,结果发现,在配置的时候,下面的测试code编译并执行,以确定ruserok,ruserok_af和iruserok的可用性。

  / *结束confdefs.h。 * /
/ *定义$ 2无害变体中,若所述; limits.h中>声明港币$ 16。
   例如,HP-UX 11i的<&limits.h中GT;声明gettimeofday的。 * /
#定义$ 2 innocuous_ $ 2/ *系统头定义__stub宏,并希望一些原型,
    它可以用char $ 2()发生冲突;下面。
    preFER<&limits.h中GT;到< ASSERT.H>如果__STDC__定义,因为
    <&limits.h中GT;甚至存在于独立的编译器。 * /#IFDEF __STDC__
#包括LT&;&limits.h中GT;
#其他
#包括LT&;&ASSERT.H GT;
#万一和#undef $ 2/ *覆盖任何GCC内部原型,以避免错误。
   使用CHAR因为INT可能匹配GCC的返回类型
   内置然后它的参数原型仍然适用。 * /
#IFDEF __cplusplus
为externC
#万一
烧焦$ 2();
/ * GNU C库定义了本作,它实现的功能
    总是失败,ENOSYS。有些功能实际上命名
    事情开始__和正常名是别名。 * /
#如果__stub_ $ 2 ||定义定义__stub ___ $ 2

#万一INT
main()的
{
返回$ 2​​();
  ;
  返回0;
}

所以,我复制,粘贴(更换全部$ 2'S与ruserok)和使用生成的GCC编译器编译这个code

  ./臂狭小-Linux的gnueabi-GCC -o test.o test.c的

看是否ruserok,不/不存在ruserok_af和iuserok功能,我收到了以下编译错误:

  /tmp/ccU8YszI.o:在函数'主':
test.c以:(文字+ 0x8中):未定义的参考`ruserok
collect2:错误:LD返回1退出状态

其中,是相同的未定义参考`ruserok错误如上。作为一个全面的检查,因为我已经安装过早期的Ubuntu软件中心Ubuntu的/ Linaro的ARM GCC编译器,我编在同一code。与臂Linux的gnueabi-gcc编译器,但code编译罚款没有任何错误。在这里,我命令用于参考:

  ARM-Linux的gnueabi-GCC -o test.o test.c的

所以,我的问题是:为什么有人编译器产生一个未定义的引用ruserok的错误,而其他不?或问不同,是一个编译器会产生一个未定义参考ruserok两种编译器之间的差异错误?


解决方案

编译器(尤其是 GCC )不仅仅是code发电机多。他们是非常熟悉的的libc 或标准 C 库,也是 libgcc中编译器辅助库。一般命令行隐含的使用 -lc (带链接的的libc )。在 ARM-Linux的gnueabi-GCC 从Ubuntu是一个的crosstool-ng的建立与 eglibc

我不知道是什么的老板问起GCC 左右。你可能会提供一个链接,你来自哪里得到了编译器。从href=\"http://marcin.juszkiewicz.com.pl/2008/07/17/using-poky-sdk-to-build-software/\" rel=\"nofollow\">老板问起配置链接,似乎编译器是一个MULT-LIB分配或东西,有您需要执行配置的交叉编译可能额外的步骤

该问题的答案,


  

为什么有人编译器产生一个未定义的引用ruserok的错误,而其他不?


由于人都有 ruserok 在图书馆和其他没有(或没有配置,看看它)。

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 __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;
}

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

So, my question is: Why would one compiler produce an "undefined reference to ruserok" error, while the other does not? Or asked differently, what is the difference between the two compilers that one compiler would produce an "undefined reference to ruserok" error?

解决方案

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.

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.

The answer to the question,

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

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

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

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