GLIBCXX_3.4.21未在文件libstdc ++。so.6中用链接时间参考定义 [英] GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference

查看:3672
本文介绍了GLIBCXX_3.4.21未在文件libstdc ++。so.6中用链接时间参考定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

抱歉,我了解与此类似的问题已被相对经常地提出,尽管没有任何解决方案似乎适用于我。当试图运行具有合理复杂性的任何c ++代码时,出现上述错误。完整的错误信息是:

  / main:重定位错误:./main:symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev,版本GLIBCXX_3.4.21未定义文件libstdc ++。so.6带有链接时间引用

运行另一个项目,我得到一个非常类似的错误:

  ./main:重定位错误:./main:符号_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev,版本GLIBCXX_3.4.21未在文件libstdc ++。so中定义。 6 with link time reference 

我实际上没有任何编译问题,因为这些项目都编译精细。这只是当我尝试运行可执行文件时发生的。
我以为这是我的海湾合作委员会安装错误,所以今天我重新安装了它,虽然这根本没有帮助。我不知道该怎么做才能解决这个问题,任何人都可以提供帮助吗?

这是我用来编译项目的Makefile,我感觉这是错误的地方:

  CC = g ++ 
CFLAGS = -Wall -g -std = c + +11 -lX11 -lpthread
OBJS = main.o Board_Tile.o Sliding_Solver.o

main:$(OBJS)
$(CC)-o $ @ $(OBJS )
%.o:%.cc
$(CC)$(CFLAGS)-c $ ^

我的gcc版本是5.3.0,我正在运行Ubuntu 14.0.4。

解决方案

GCC 5.1或5.2(现在不记得了,google它)改了C ++ ABI。你的标准ubuntu(包括libstdc ++)是用旧的ABI编译的。

您的gcc编译器尝试使用新的ABI。有时它很有效,大部分时间 - 没有。

所以,有三种方法可以编译你的代码:

< 1)降级gcc 2)添加-D_GLIBCXX_USE_CXX11_ABI = 0(cmake示例)标志(如果你这样做,你应该把这个标志添加到每个makefile或项目中你建立直到
你升级ubuntu或降级gcc)
$ b $ 3升级Ubuntu(测试它,顺便说一句,16.04随着新的ABI和新的gcc默认,我不得不ack-grep并从我所有的宠物项目中删除上述标志)

了解GCC 5的_GLIBCXX_USE_CXX11_ABI或新的ABI



PS有趣的是,答案在于: _ZNSt7__cxx11 CXX11 ,尽管我们没有真正阅读错误信息。


Apologies, I understand questions very similar to this have been asked relatively often, although none of the solutions seem to work for me.When attempting to run any c++ code of a reasonable complexity, I get the above error. The full error message is:

/main: relocation error: ./main: symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference

running another project, I get a very similar error:

./main: relocation error: ./main: symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference

I don't actually have any problem with compilation, as these projects both compile fine. This just happens when I try to run the executable. I thought it was an error with my gcc install, so today I reinstalled it, although that did not help at all. I don't really know what to do to fix this, can anyone offer assistance?

This is the Makefile I'm using to compile one of the projects, I feel this is where the error could be:

CC= g++
CFLAGS= -Wall -g -std=c++11 -lX11 -lpthread
OBJS = main.o Board_Tile.o Sliding_Solver.o

main: $(OBJS)
   $(CC) -o $@ $(OBJS)
%.o : %.cc
   $(CC) $(CFLAGS) -c $^

My gcc version is 5.3.0, I'm running Ubuntu 14.0.4.

解决方案

GCC 5.1 or 5.2 (can't remember now, google it) changed C++ ABI. Your standard ubuntu (including libstdc++) is compiled with old ABI.

Your gcc compiler tries to use new ABI. Sometimes it works, most of the time - no.

So, there are 3 ways to compile your code:

1) downgrade gcc

2) add -D_GLIBCXX_USE_CXX11_ABI=0 (cmake example) flag (if you go this way, you should add this flag to every makefile or project you build till you upgrade ubuntu or downgrade gcc)

3) upgrade Ubuntu (tested it, by the way 16.04 goes with new ABI and new gcc by default, I had to ack-grep and remove flag mentioned above from all my pet projects)

also: Understanding GCC 5's _GLIBCXX_USE_CXX11_ABI or the new ABI

P.S. funny thing, the answer is in the question: _ZNSt7__cxx11 : CXX11, though we don't really read error messages.

这篇关于GLIBCXX_3.4.21未在文件libstdc ++。so.6中用链接时间参考定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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