链接器错误无法在库中找到符号名称 [英] linker error cannot find symbol name in library

查看:159
本文介绍了链接器错误无法在库中找到符号名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  g ++(GCC)4.7.2 
3.7.6-201.fc18.x86_64#1 SMP Mon Feb 4 15:54:08 UTC 2013 x86_64 x86_64 x86_64 GNU / Linux
Fedora release 18(Spherical Cow)

你好,

我正在编译并尝试链接程序时出现问题。



链接器错误为:

  / usr / bin / ld:point.o:未定义的符号引用'_Znwj @@ GLIBCXX_3.4'
/ usr / bin / ld:备注:'_Znwj @@ GLIBCXX_3.4'在DSO /lib/libstdc++.so.6中定义,因此请尝试将其添加到链接器命令行
/lib/libstdc++.so.6:无法读取符号:操作无效
collect2:error:ld返回1退出状态

这个目标文件是 point.o 试图调用libstdc ++中不存在的函数。



当我尝试检查符号名称确实存在使用readelf我无法找到它。

  readelf --all libstdc ++。so.6.0.17 | grep _Znwj @@ GLIBCXX_3.4 

这是因为point.o正在寻找一个符号更旧的libstdc ++可能已经在更高版本中被删除了?



非常感谢您的任何建议,

解决方案

在我的情况下,我使用gcc而不是g ++。它曾经在'12工作,但后来在'14'的另一台机器上建立窒息。 gnu编译器确实已经改变。我的答案是添加

  -lstdc ++ 

。 HTH。


g++ (GCC) 4.7.2 
3.7.6-201.fc18.x86_64 #1 SMP Mon Feb 4 15:54:08 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Fedora release 18 (Spherical Cow)

Hello,

I am compiling and having a problem trying to link a program.

The linker error is:

/usr/bin/ld: point.o: undefined reference to symbol '_Znwj@@GLIBCXX_3.4'
/usr/bin/ld: note: '_Znwj@@GLIBCXX_3.4' is defined in DSO /lib/libstdc++.so.6 so try adding it to the linker command line
/lib/libstdc++.so.6: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

This object file is point.o is trying to call a function that doesn't exist in libstdc++.

When I try and check if the symbol name does exist using readelf I can't find it.

readelf --all libstdc++.so.6.0.17 | grep _Znwj@@GLIBCXX_3.4

Is this because the point.o is looking for a symbol in a older libstdc++ that could have been removed in a later version?

Many thanks for any suggestions,

解决方案

In my case I was using gcc not g++. It used to work in '12, but a later build on a different machine in '14 choked. The gnu compiler has indeed changed. The answer in my case was to add

  -lstdc++

onto the end of the linking line, as the error messages suggest. HTH.

这篇关于链接器错误无法在库中找到符号名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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