海湾合作委员会 #include <>和 #include "",我可以在不更改其中之一的情况下进行编译吗?

发布于 2024-11-09 02:52:13 字数 632 浏览 0 评论 0 原文

我被要求重新编译一个相当旧的 EMG 处理冷库,以便它可以在现代 Mac 上运行,而不是在当前运行的古老 SunOS 工作站上运行。对于那些对 makefile 不太熟悉的人来说,这是一条痛苦的道路,但在阅读了整个互联网之后,这让我难住了。

makefiles(由 imake 生成)使用每个源文件的以下参数调用 gcc,但因“未定义符号”错误而失败:

gcc -I[First Include Path] -I[Second Include Path] -I. -c [File Name].c
gcc -o [Output File Name] [Include a bunch of libraries] -lm

我认为问题的根源是所有 #include 语句都使用 <>对于系统库,.h 位于包含目录中,.h 位于与正在编译的 .c 文件相同的目录中。我知道这是错的,但事实就是这样。如果我将它们更改为“”,仅将 .h 与正在编译的 .c 位于同一目录中,那么一切都会正常。

当然,我不想对数百个文件单独执行此操作。那么,我可以做一些更改,以便 gcc 在当前目录中查找 #include <> 吗?从我阅读的搜索路径来看,默认情况下它不会?

或者我注定要继续我目前的某种黑客工作批量查找和替换计划?

I have been asked to recompile a rather old library of EMG processing cold so it works on modern Macs rather than the ancient SunOS workstation it is currently running on. It's been a painful road for someone not very experienced with makefiles, but after reading all over the internet this has me stumped.

The makefiles (generated by imake) are calling gcc with the following arguments for each source file, but are failing with 'Undefined symbols' errors:

gcc -I[First Include Path] -I[Second Include Path] -I. -c [File Name].c
gcc -o [Output File Name] [Include a bunch of libraries] -lm

What I assume is the root of the problem is ALL of the #include statements use <> for the system libraries, .h in the include directories, and the .h in the same directory as the .c file being compiled. I know its wrong, but thats the way it is. If I change them to "" for only the .h in the same directory as the .c being compiled then everything works out fine.

Of course I would rather not do this individually for hundreds of files. So, is there some change I can make so gcc will look in the current directory for #include <>? as from reading up on the search path I gather it does not by default?

Or am I doomed to continue with my current plan of some sort of hack job bulk find and replace?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灰色世界里的红玫瑰 2024-11-16 02:52:13

根据我的经验,#include "" 也适用于系统标头。因此,如果您不关心区分本地标头和系统标头,可以尝试将所有 #include <> 替换为 #include ""

In my experience #include "" will also work for system headers. So you can try replace all #include <> to #include "", if you don't care differentiating local and system headers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文