C++:编译错误 - “不会创建 .eh_frame_hdr 表”
我应该使用数据分析程序进行物理实验。但我无法编译它。
该代码很旧,与我能找到的当前 GCC 版本并不真正兼容。为了让事情变得更耗时,我从一个人那里得到了代码,他修改了所有 makefile 以使其在 Mac 上编译。我没有 C++ 经验,但凭借手册页、Google 和耐心,我已经修复了很多错误,但即使经过一周的尝试和谷歌搜索,我仍然坚持这个错误。
我相信相关的错误信息如下:
/usr/bin/ld: error in /home/daniel/skola/exjobb/miniballscripts
/lib/libCommandLineInterface.so(.eh_frame); no .eh_frame_hdr table will be created.`
可能是什么原因,以及什么可以补救?
libCommandLineInterface.so
是我之前编译的,没有任何明显的错误消息:
$ make
g++ -g2 -O2 -I./ -c CommandLineInterface.cc -o CommandLineInterface.o
g++ -g -Wl -o /home/daniel/skola/exjobb/miniballscripts/lib/libCommandLineInterface.so
CommandLineInterface.o -lm -L/home/daniel/skola/exjobb/miniballscripts/lib -lgcc -lc
Done
我的 g++-version 是 g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
, amd64。
- http://tinypaste.com/9eee9 - 生成输出
- http://tinypaste.com/ddbde - GNUmakefile
正如我所说,我没有 C++ 经验,所以也许我天真的 Makefile 修改破坏了一些东西。我缺乏经验也让我真的不知道还需要什么其他信息来帮助我,但我很乐意回复。
I'm supposed to use a data analysis program for a physics experiment. I can't get it to compile though.
The code is old, not really compatible with current GCC-versions from what I can find. To make things a bit more time-comsuming, I got the code from a guy who had modified all the makefiles to make it compile on Mac. I have no C++-experience, but with man-pages, Google and patience I have fixed a lot of errors on the way, but I'm stuck on this one, even after a week of tries and googling.
I believe the relevant error message is the following:
/usr/bin/ld: error in /home/daniel/skola/exjobb/miniballscripts
/lib/libCommandLineInterface.so(.eh_frame); no .eh_frame_hdr table will be created.`
What can be the cause, and what can be the remedy?
libCommandLineInterface.so
was compiled by me before, without any apparent error messages:
$ make
g++ -g2 -O2 -I./ -c CommandLineInterface.cc -o CommandLineInterface.o
g++ -g -Wl -o /home/daniel/skola/exjobb/miniballscripts/lib/libCommandLineInterface.so
CommandLineInterface.o -lm -L/home/daniel/skola/exjobb/miniballscripts/lib -lgcc -lc
Done
My g++-version is g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3
, amd64.
- http://tinypaste.com/9eee9 - make output
- http://tinypaste.com/ddbde - GNUmakefile
As I said, I have no experience with C++, so maybe my naive Makefile modifications have destroyed something. My lack of experience also makes me not really knowing what other information is needed to help me, but I'll be glad to reply.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来您在生成
libCommandLineInterface.so
文件时忘记了-shared
命令行选项。这可以解释那些多重定义错误。如果链接器认为它生成的文件是可执行文件(而不是动态库),那么它将链接到启动代码等。当您尝试使用此 .so 文件时,这些符号来自启动代码将与添加到使用动态库的可执行文件中的内容发生冲突。libTransfer.so 错误可能与省略相同标志有关。共享库允许有悬空引用(在使用库时解析),但可执行文件必须在链接时解析所有符号。这可能过于简单化了事情的本质,但我从来不需要深入了解 Linux 中动态链接的更多细节。 :) 无论如何,添加
-shared
选项也可以解决未定义的引用错误。Looks like you have forgotten the
-shared
command line option when you generate thelibCommandLineInterface.so
file. That would explain those multiple definition errors. If the linker thinks that the file it is generating is an executable (instead of a dynamic library), then it would link in the startup code, etc. When you try to use this .so file, those symbols coming in from the startup code will clash with those that are being added to the executable that uses the dynamic library.It is possible that the libTransfer.so errors are related to the same flag being omitted. A shared library is allowed to have dangling references (that get resolved when the library is used), but an executable has to have all the symbols resolved at link time. This is probably an oversimplification of how things are, but I never needed to get into more details on dynamic linking in linux. :) Anyhow, adding
-shared
option may solve the undefined reference errors as well.值得关注的链接错误始于:
多重定义的符号在 Unix 上是“标准”的 - 而且我自己也不需要在 Mac 上费心处理它们,尽管我不在那里进行 GUI 编程。
您需要以一种非常偏见的态度来看待
libCommandLineInterface.cc
,并决定它是否提供了您需要的任何内容。您也许可以将其完全删除。如果它包含您确实需要的一些内容,您将需要烧灼定义_start
、_end
和main
等的材料。您还必须担心缺少的 vtable:
The linking errors of concern start with:
The symbols that are multiply defined are 'standard' on Unix - and I've never needed to bother with them myself on Mac either, though I don't do GUI programming there.
You need to look at
libCommandLineInterface.cc
with a very prejudiced attitude and decide whether it provides anything that you need. You might be able to remove it altogether. If it contains some stuff you do need, you will need to cauterize the material that defines_start
, and_end
andmain
and so on.You are also going to have to worry about the missing vtables:
解决了。该线程解决了 eh_frame_hdr 问题。通过在第一个
make
之后删除libTransfer.so
,然后直接再次运行make
来解决未定义的引用。不要问我是怎么做到的,但这使它编译了。It's solved. The eh_frame_hdr-problem was solved by this thread. The undefined references was solved by deleting
libTransfer.so
after the firstmake
, and then directly afterwards runningmake
again. Don't ask me how, but that made it compile.