GCC:允许未定义的符号 [英] gcc: Allow Undefined Symbols

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

问题描述

我不希望海湾合作委员会链接以显示未定义的符号链接错误。我用gcc 4.2 MAC OSX 10.6

I don't want the gcc linker to show the undefined symbols as linkage errors. I'm using gcc 4.2 on MAC OSX 10.6

当然,我在网上找了一个解决方案,但所有的尝试失败了!

Of course I've looked online for a solution, but all the tries failed!

如何修改这个命令来摆脱未定义符号错误的?

How can I modify this command to get rid of the undefined symbols error?

gcc -o Proj $(wildcard *.o);

感谢。

编辑:我工作的一个研究项目,我需要code是联和放大器;我不在乎它是否将有运行时异常

I'm working on a research project where I need the code to be linkable & I don't care if it'll have runtime exceptions

推荐答案

咦?这是没有意义的。它的的错误,并且它不能被忽略。当链接失败时做的工作不能生成可执行文件。你会希望它只是创造一个实现,并希望它只是工作了?

Huh? That makes no sense. It is an error and it cannot be ignored. You cannot build an executable when the linker fails to do its job. Would you expect it to simply invent an implementation and hope that it just works out?

相反,你需要学习如何正确地配置您的项目建设。如果你依赖于外部库,那么你需要的路径添加到它在你的链接搜索路径。

Instead, you need to learn how to properly configure your project to build. If you depend on an external library then you need to add the path to it in your linker search paths.

编辑:每您的评论...

Per your comment...

有选择共进晚餐preSS联动错误,如在这里sourceware.org/binutils/docs/ld/Options.html~~MD~~aux我工作的一个研究项目,我需要code是可链接&安培;我不在乎它是否将有运行时异常

there are options to suppress the linkage errors like in here sourceware.org/binutils/docs/ld/Options.html I'm working on a research project where I need the code to be linkable & I don't care if it'll have runtime exceptions

好了,你还不能和它仍然是没有意义的。更多的,请仔细阅读该节:

Well, you still can't and it still makes no sense. Read that section more carefully:

允许未定义的符号引用的原因的共享库在链接时指定是:

The reasons for allowing undefined symbol references in shared libraries specified at link time are that:

一个共享库可能不一样,一个是可以在加载时间,因此符号实际上可能是在加载时解析。
  有一些操作系统,比如BeOS的和HPPA,凡在共享库未定义的符号都是正常的。

A shared library specified at link time may not be the same as the one that is available at load time, so the symbol might actually be resolvable at load time. There are some operating systems, eg BeOS and HPPA, where undefined symbols in shared libraries are normal.

所以,有一些情况,其中允许未定义的符号共享库是合理的,因为你可能没有连接到相同的版本,你将在实践中链接到一个动态库。

So, there are some circumstances wherein allowing undefined symbols in a shared library are reasonable because you may not be linking to the same version of a dynamic library that you will be linking to in practice.

不过,你想建立一个可执行文件,而不是共享库,所以它的是没有意义做你所要求的东西。您只需一个可执行文件是borked,将无法正常工作。为什么任何理智的编译器允许这样的条件?

However, you want to build an executable, not a shared library, so it makes no sense to do what you are asking for. You simply have an executable that is borked and will not work. Why would any sane compiler allow for such a condition?

这篇关于GCC:允许未定义的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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