如何配置libstdc ++与GCC 4.8? [英] How to configure libstdc++ with GCC 4.8?

查看:125
本文介绍了如何配置libstdc ++与GCC 4.8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

A while back,我决定升级到GCC 4.8,以便早日开始一些c ++ 11的功能。我有一点sidetracked,虽然,并没有真正把任何新的功能使用,直到一个项目前几天(新的编译器似乎已经工作正常,但它可能是因为我不利用任何新的功能。)

A while back, I decided to upgrade to GCC 4.8 in order to get an early start on some c++11 features. I got a bit sidetracked, though, and didn't really put any of the new features to use until a project a few days ago (the new compiler seemed to have been working fine, but it may just be because I wasn't utilizing any new functionality.)

在这个新项目中,当我使用= std = c ++ 11标志编译时,我没有问题。但是,在运行时,我得到的错误:

In this new project, when I compiled with the =std=c++11 flag, I had no problems. However, at runtime, I get the error:


./ main:/ usr / lib / i386-linux -gnu / libstdc ++。so.6:version GLIBCXX_3.4.18'未找到(./main需要)`

./main: /usr/lib/i386-linux-gnu/libstdc++.so.6: versionGLIBCXX_3.4.18' not found (required by ./main)`



假设有一个问题链接到一个更现代的libstdc ++库与GCC 4.8相关联,但我不能为我的生活找出如何解决这个或适当的库应该在哪里。我记得象征性地将g ++和gcc二进制文件链接到gcc-4.8,这似乎是有效的,因为 g ++ -v 返回:


使用内置规格。
COLLECT_GCC = g ++
COLLECT_LTO_WRAPPER = / app / gcc / 4.8.0 / libexec / gcc / i686-pc-linux-gnu / 4.8.0 / lto-wrapper
目标:i686-pc -linux-gnu
配置为:./gcc-4.8.0/configure --prefix = / app / gcc / 4.8.0
线程模型:posix
gcc版本4.8.0 GCC)

另一个在线线程让我看看 ldd 输出, 向我显示链接的libstdc ++库的目录结构与二进制文件的目录结构不同。但是,我不能在后面找到合适的 libstdc ++ 库,所以我不知道在哪里看。 ldd main 的输出为:

Another thread online led me to look at the ldd output for the program, which did show me that the directory structure for the libstdc++ libraries being linked to was different than the directory structure for the binaries. I couldn't, however, find the appropriate libstdc++ libraries in the latter, so I'm not sure where to look. The output for ldd main is:


./ main:/usr/lib/i386-linux-gnu/libstdc++.so.6:版本 GLIBCXX_3.4.18'未找到(./main需要)
linux-gate.so。 1 =>(0xb7791000)
libstdc ++。so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6(0xb768e000)
libm.so.6 => / lib / i386-linux-gnu / libm.so.6(0xb7662000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1(0xb7644000)
libc.so。 6 => /lib/i386-linux-gnu/libc.so.6(0xb749b000)
/lib/ld-linux.so.2(0xb7792000)`

./main: /usr/lib/i386-linux-gnu/libstdc++.so.6: versionGLIBCXX_3.4.18' not found (required by ./main) linux-gate.so.1 => (0xb7791000) libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb768e000) libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb7662000) libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb7644000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb749b000) /lib/ld-linux.so.2 (0xb7792000)`

我不知道这是怎么回事,我会继续Googling和寻找答案,但任何帮助,你们可以提供将非常感谢。如果有什么不清楚的问题,或者我忘了一些信息,只是让我知道,我会尝试添加在。非常感谢。

I'm not sure exactly where this is going wrong, and I'll continue Googling and looking around for answers, but any help you guys could offer would be greatly appreciated. If anything is unclear about the issue or I forgot some information, just let me know and I'll try to add that in. Thanks so much!

推荐答案

您需要告诉您的动态链接器(当您运行程序时执行它)在哪里可以找到库。将 LD_LIBRARY_PATH 设置为库路径(可能位于 /app/gcc/4.8.0/lib )。

You need to tell your dynamic linker (it's executed when you run your program) where to find the library. Set LD_LIBRARY_PATH to the path of the library (probably somewhere under /app/gcc/4.8.0/lib or something).

使用查找/app/gcc/4.8.0 -namelibstdc ++。so.6。将目录添加到LD_LIBRARY_PATH。例如使用我提到的路径:

Use find /app/gcc/4.8.0 -name "libstdc++.so.6". Add the directory to your LD_LIBRARY_PATH. e.g with the path I mentioned:

export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/app/gcc/4.8.0/lib

然后尝试运行你的程序。

Then try to run your program.

如果它工作,你可能想配置动态链接器在目录中查找而不使用LD_LIBRARY_PATH。有关如何配置路径的详细信息,请参阅 man ld.so

If it works, you'll probably want to configure your dynamic linker to look in the directory without using LD_LIBRARY_PATH. See man ld.so for details about how to configure the path.

这篇关于如何配置libstdc ++与GCC 4.8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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