如何在Ubuntu中获得GLIBCXX_3.4.15?我无法运行一些我正在编译的程序.
当我做:
strings /usr/lib/libstdc++.so.6 | grep GLIBC
Run Code Online (Sandbox Code Playgroud)
我明白了:
GLIBCXX_3.4
GLIBCXX_3.4.1
GLIBCXX_3.4.2
GLIBCXX_3.4.3
GLIBCXX_3.4.4
GLIBCXX_3.4.5
GLIBCXX_3.4.6
GLIBCXX_3.4.7
GLIBCXX_3.4.8
GLIBCXX_3.4.9
GLIBCXX_3.4.10
GLIBCXX_3.4.11
GLIBCXX_3.4.12
GLIBCXX_3.4.13
GLIBCXX_3.4.14
GLIBC_2.2.5
GLIBC_2.3
GLIBC_2.4
GLIBC_2.3.4
GLIBC_2.3.2
GLIBCXX_FORCE_NEW
GLIBCXX_DEBUG_MESSAGE_LENGTH
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
我遇到了一个我不确定如何解决的问题.我相信这是GCC和/或libstdc ++中的一个问题.
我正在使用GCC 4.8.2-19ubuntu1,libstdc ++ 3.4.19运行Ubuntu 14.04 LTS(我相信?你如何找到你的linux机器上安装了什么版本的libstdc ++库?),并提升1.55.
这是代码:
// http://www.boost.org/doc/libs/1_54_0/libs/log/doc/html/log/tutorial.html
// with a slight modification to ensure we're testing with threads too
// g++ -g -O0 --std=c++11 staticlinktest.cpp -lboost_log_setup -lboost_log -lboost_system -lboost_filesystem -lboost_thread -lpthread
#define BOOST_ALL_DYN_LINK 1
#include <boost/log/trivial.hpp>
#include <thread>
#include <atomic>
#include <vector>
int main(int, char*[])
{
BOOST_LOG_TRIVIAL(trace) << "A trace severity message";
BOOST_LOG_TRIVIAL(debug) << "A debug severity message";
BOOST_LOG_TRIVIAL(info) << "An informational severity message";
BOOST_LOG_TRIVIAL(warning) << "A warning severity message";
BOOST_LOG_TRIVIAL(error) << "An …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Clang ++编译我在网上找到的程序.Makefile生成以下命令:
clang++ -c -arch x86_64 -msse3 -std=c++11 -stdlib=libstdc++
-Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type
-Wno-non-virtual-dtor -Wno-exit-time-destructors -Wformat -Wmissing-braces
-Wparentheses -Wno-switch -Wunused-function -Wunused-label -Wno-unused-parameter
-Wunused-variable -Wunused-value -Wno-empty-body -Wuninitialized -Wunknown-pragmas
-Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion
-Wint-conversion -Wno-shorten-64-to-32 -Wenum-conversion -Wno-newline-eof
-Wno-c++11-extensions -Wno-logical-op-parentheses -Wno-trigraphs
-Wno-invalid-offsetof -Wno-sign-conversion -Wdeprecated-declarations
-fmessage-length=0 -fno-exceptions -fstrict-aliasing -fvisibility=hidden
-fvisibility-inlines-hidden -funsafe-math-optimizations -ftrapping-math -fno-rtti
-fpascal-strings -fasm-blocks -O3 -Iinclude/ src/main.cpp
Run Code Online (Sandbox Code Playgroud)
但我明白了
src/main.cpp:23:10: fatal error: 'unordered_map' file not found
#include <unordered_map>
^
1 error generated.
Run Code Online (Sandbox Code Playgroud)
如果我编译一个包含<unordered_map>运行的简单程序clang++ test.cpp,它编译得很好.
我上线了
Apple LLVM version 5.1 …Run Code Online (Sandbox Code Playgroud) 我试图在版本4.9.0之前使用GCC分发的版本中测试libstdc++因为std::regex已实现但很大程度上已破坏的版本libstdc++.
注意:
我需要测试版本libstdc++,而不是GCC,因为Clang也支持使用libstdc++标准库.这排除了测试__GNUC_PATCHLEVEL__,__GNUC__和__GNUC_MINOR__宏.
该__GLIBCXX__宏是一个日期,而不是一个版本号并不会单调递增.例如,GCC 4.8.4附带#define __GLIBCXX__ 20150426,比GCC 4.9.0的发布日期更新.
有没有可靠的方法来测试它的版本libstdc++不依赖于使用GCC我的编译器?
我怎么知道每个gcc版本附带的libstdc ++?有没有一种简单的方法来获取此信息而无需安装gcc?
我正在尝试使用std::literals名称空间中的文字来编译一个简单的程序,但是当我尝试对其进行编译时,Clang会生成错误。
我正在尝试编译的代码:
#include <string>
#include <iostream>
using namespace std::literals;
int main()
{
std::cout << "Hello World!"s << std::endl;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
和编译命令:
clang++ -stdlib=libstdc++ -std=c++1y a.cpp
Run Code Online (Sandbox Code Playgroud)
导致此输出:
a.cpp:4:22: error: expected namespace name
using namespace std::literals;
~~~~~^
a.cpp:8:29: error: no matching literal operator for call to 'operator "" s' with arguments of
types 'const char *' and 'unsigned long', and no matching literal operator template
std::cout << "Hello World!"s << std::endl;
^
2 errors generated.
Run Code Online (Sandbox Code Playgroud)
由于各种原因,无法使用g ++或libc ++,并且我已经确认其他C ++ …
我正在尝试在Rust中构建Octave函数.Octave的API是用C++编写的,所以我使用了rust-bindgen生成了绑定.我正在解决尝试生成包含的绑定std::string时出现的问题.如果我可以将它指向C++的std::string不透明和有效指针,那将是很好的.我是否可以在需要传递C++时在C++端构建实用程序功能std::string?
当我第一次尝试这个时,我很天真.这显然是错误的.Rust std::ffi:CString用于C字符串,而不是C++字符串.我发现这篇最近的博客在比较两者时很有帮助.我的第一次尝试看起来像这样:
#![allow(non_snake_case)]
#![allow(unused_variables)]
extern crate octh;
// https://thefullsnack.com/en/string-ffi-rust.html
use std::ffi::CString;
#[no_mangle]
pub unsafe extern "C" fn Ghelloworld (shl: *const octh::root::octave::dynamic_library, relative: bool) -> *mut octh::root::octave_dld_function {
let name = CString::new("helloworld").unwrap();
let pname = name.as_ptr() as *const octh::root::std::string;
std::mem::forget(pname);
let doc = CString::new("Hello World Help String").unwrap();
let pdoc = doc.as_ptr() as *const octh::root::std::string;
std::mem::forget(pdoc);
octh::root::octave_dld_function_create(Some(Fhelloworld), shl, pname, pdoc)
}
pub unsafe extern "C" fn Fhelloworld (args: …Run Code Online (Sandbox Code Playgroud) 我的应用程序受到相当严重的数据丢失方式的旧版本libstdc ++中的错误的影响。如何使用或选择正确的库版本的补救措施是已知的,但对部署和构建的更改不可靠。在被自己咬了不止一次之后,我想停止痛苦,并引入运行时检查以获取足够新版本的libstdc ++。在部署无法使用正确版本的情况下,如何访问该版本以显示较大的警告消息。请注意,我需要的次要版本又名随GCC 8。-rpathLD_LIBRARY_PATHlibstdc++.so.6.0.25GLIBCXX_3.4.25
例如,采用以下最小示例:
#include <cstdio>
#include <stdexcept>
int main(int argc, char* argv[]){
#ifdef __GLIBCPP__
std::printf("GLIBCPP: %d\n",__GLIBCPP__);
#endif
#ifdef __GLIBCXX__
std::printf("GLIBCXX: %d\n",__GLIBCXX__);
#endif
throw std::runtime_error("Were are libstdc++.so.6 debug symbols?");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当在 my 中运行它时gdb,它不显示以下调试符号libstdc++.so.6:
$ g++ -o testmain test.cpp -ggdb --std=c++98 && gdb ./testmain
GNU gdb (Ubuntu 9.1-0ubuntu1) 9.1
Copyright (C) 2020 Free Software Foundation, Inc.
...
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./testmain...
(gdb) r
Starting …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的代码:
#include <string>
#include <iostream>
int main() {
std::string s("abc");
std::cout << s;
}
Run Code Online (Sandbox Code Playgroud)
然后,我编译了它:
g++ -Wall test_string.cpp -o test_string -std=c++17 -O3 -g3 -ggdb3
Run Code Online (Sandbox Code Playgroud)
然后将其反编译,最有趣的部分是:
00000000004009a0 <_ZNSs4_Rep10_M_disposeERKSaIcE.isra.10>:
4009a0: 48 81 ff a0 11 60 00 cmp rdi,0x6011a0
4009a7: 75 01 jne 4009aa <_ZNSs4_Rep10_M_disposeERKSaIcE.isra.10+0xa>
4009a9: c3 ret
4009aa: b8 00 00 00 00 mov eax,0x0
4009af: 48 85 c0 test rax,rax
4009b2: 74 11 je 4009c5 <_ZNSs4_Rep10_M_disposeERKSaIcE.isra.10+0x25>
4009b4: 83 c8 ff or eax,0xffffffff
4009b7: f0 0f c1 47 10 lock xadd …Run Code Online (Sandbox Code Playgroud)