C ++:编译错误 - “no.eh_frame_hdr表将被创建” [英] C++: compilation error - "no .eh_frame_hdr table will be created"

查看:1227
本文介绍了C ++:编译错误 - “no.eh_frame_hdr表将被创建”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该使用数据分析程序进行物理实验。我不能让它编译。<​​/ p>

代码是旧的,不是真正兼容当前的GCC版本从我可以找到。为了使事情有点更多的时间,我得到了一个人的代码,他修改了所有的makefile,使其在Mac上编译。我没有C ++ - 经验,但与手册页,谷歌和耐心我已经修复了很多错误的方式,但我困在这一个,即使一个星期的尝试和谷歌之后。



我相信相关的错误信息如下:



/ usr / bin / ld:error in /home/daniel/skola/exjobb/miniballscripts/lib/libCommandLineInterface.so(.eh_frame);不会创建.eh_frame_hdr表。



可能的原因是什么,补救措施是什么?



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 ++ - 版本是 g ++(Ubuntu 4.4.3-4ubuntu5)4.4.3 ,amd64 。





正如我所说,我没有C ++的经验,所以也许我的初始Makefile修改毁了一些东西。我缺乏经验也让我不知道需要什么其他信息来帮助我,但我很乐意回复。

解决方案

看来您在生成 libCommandLineInterface.so 文件时忘记了 -shared 命令行选项。这将解释这些多重定义错误。如果链接器认为它生成的文件是可执行文件(而不是动态库),那么它将链接到启动代码等。当您尝试使用此.so文件时,来自启动代码的符号将与添加到使用动态库的可执行文件的那些标记冲突。



libTransfer.so错误可能与省略的相同标记相关。共享库允许有悬挂引用(在使用库时解析),但可执行文件必须在链接时解析所有符号。这可能是对事情的过度简化,但我从来不需要了解更多关于动态链接的细节。 :)无论如何,添加 -shared 选项也可以解决未定义的引用错误。


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.

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.

解决方案

Looks like you have forgotten the -shared command line option when you generate the libCommandLineInterface.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.

这篇关于C ++:编译错误 - “no.eh_frame_hdr表将被创建”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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