本文介绍了未定义参考`杀“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了用于C.一个ARM7嵌入式系统现在我想为了使用一些C ++特性来编译和用C链接它++应用程序。要做到这一点,我使用 mipsel体系精灵-G ++ 而不是的mipsel体系精灵-GCC 。我可以编译我的code与 mipsel体系精灵-G ++ 成功,但在联步骤我得到的错误:

I developed an application for an ARM7 embedded system in C. Now I want to compile and link it with C++ in order to use some C++ features. To do this, I am using mipsel-elf-g++ instead of mipsel-elf-gcc. I can compile my code with mipsel-elf-g++ successfully, but in linking step I get the errors:

/opt/mipsel/lib/gcc/mipsel-elf/3.4.6 /../../../../ mipsel体系精灵/ lib目录/文件libc.a(lib_a-abort.o):在功能```中止':
  /cygdrive/d/Files/cross/mips/newlib-1.15.0/newlib/libc/s​​tdlib/abort.c:63:未定义引用
_exit'`

/opt/mipsel/lib/gcc/mipsel-elf/3.4.6 /../../../../ mipsel体系精灵/ lib目录/文件libc.a(lib_a-signalr.o):在功能```_kill_r:
  /cygdrive/d/Files/cross/mips/newlib-1.15.0/newlib/libc/reent/signalr.c:61:未定义引用
kill'`

/opt/mipsel/lib/gcc/mipsel-elf/3.4.6/../../../../mipsel-elf/lib/libc.a(lib_a-signalr.o): In function```_kill_r': /cygdrive/d/Files/cross/mips/newlib-1.15.0/newlib/libc/reent/signalr.c:61: undefined reference tokill'`

collect2:LD返回1退出状态

collect2: ld returned 1 exit status

我搜索了这个问题,并认为我应该实现自己的 _exit 的功能,所以我加了这codeS到我的项目:

I searched about this issue and found that I should implement my own _exit and kill functions, so I added this codes to my project:

void _exit(int code)
{
    while(1);

}

int _DEFUN (kill, (pid, sig), int pid _AND int sig)
{
    if(pid == __MYPID)
        _exit(sig);

    return 0;
}

通过添加这两种功能,未定义的参考`_exit的错误是固定的,但未定义的参考``杀的错误依然存在。

By adding these two functions, the undefined reference to `_exit' error is fixed, but the undefined reference to ``kill' error still exists.

我应该怎么做才能解决这个问题?

What should I do to fix this issue?

推荐答案

尝试包裹的externC{...}功能。而且,为了清楚起见,我建议不要使用 _DEFUN 宏。

Try wrapping the kill function in extern "C" { … }. And, for clarity, I suggest not using the _DEFUN macro.

这篇关于未定义参考`杀“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-16 21:11