标签: libstdc++

最新版本的gcc使用libstdc ++.so.5

什么是最新版本的gcc仍然使用libstdc ++.so.5(而不是libstdc ++.so.6)?

c++ gcc libstdc++

6
推荐指数
2
解决办法
3012
查看次数

加载共享库时出错:libstdc ++.so.6:错误的ELF类:ELFCLASS64

我想在我的CentOS系统中安装Qt.在构建库时,我收到此错误:

/root/capture/qt-everywhere-opensource-src-4.7.0/bin/qmake: error while loading shared libraries: libstdc++.so.6: wrong ELF class: ELFCLASS64
/root/capture/qt-everywhere-opensource-src-4.7.0/bin/qmake: error while loading shared libraries: libstdc++.so.6: wrong ELF class: ELFCLASS64
Run Code Online (Sandbox Code Playgroud)

c++ qt qmake std libstdc++

6
推荐指数
1
解决办法
4万
查看次数

c ++ new运算符通过libstdc ++占用大量内存(67MB)

我和new运营商有一些问题libstdc++.我用C++编写了一个程序,并且在内存管理方面遇到了一些问题.

用gdb调试后确定吃了什么东西我得到了以下内容 info proc mappings

Mapped address spaces:

      Start Addr           End Addr       Size     Offset objfile
        0x400000           0x404000     0x4000          0                             /home/sebastian/Developement/powerserverplus-svn/psp-job-distributor/Release/psp-job-distributor
        0x604000           0x605000     0x1000     0x4000                             /home/sebastian/Developement/powerserverplus-svn/psp-job-distributor/Release/psp-job-distributor
        0x605000           0x626000    0x21000          0                                   [heap]
  0x7ffff0000000     0x7ffff0021000    0x21000          0        
  0x7ffff0021000     0x7ffff4000000  0x3fdf000          0       
  0x7ffff6c7f000     0x7ffff6c80000     0x1000          0        
  0x7ffff6c80000     0x7ffff6c83000     0x3000          0        
  0x7ffff6c83000     0x7ffff6c84000     0x1000          0        
  0x7ffff6c84000     0x7ffff6c87000     0x3000          0        
  0x7ffff6c87000     0x7ffff6c88000     0x1000          0        
  0x7ffff6c88000     0x7ffff6c8b000     0x3000          0        
  0x7ffff6c8b000     0x7ffff6c8c000     0x1000          0        
  0x7ffff6c8c000     0x7ffff6c8f000     0x3000          0        
  0x7ffff6c8f000     0x7ffff6e0f000   0x180000          0                     /lib/x86_64-linux-gnu/libc-2.13.so
  0x7ffff6e0f000 …
Run Code Online (Sandbox Code Playgroud)

c++ malloc gdb new-operator libstdc++

6
推荐指数
1
解决办法
618
查看次数

虽然包含<typeinfo>,但Clang拒绝type_info为不完整

我很遗憾为什么Clang拒绝以下代码:

#include <typeinfo>
#include <exception>

const char* get_name( const std::exception_ptr eptr )
{
  return eptr.__cxa_exception_type()->name();
}

int main() {}
Run Code Online (Sandbox Code Playgroud)

GCC没问题,但Clang抱怨说它type_info是一个不完整的类型:

$ g++-4.7 -std=c++0x -O3 -Wall -Wextra t.cc -o t
$ clang++-3.2 -std=c++0x -O3 -Wall -Wextra t.cc -o t
t.cc:6:37: error: member access into incomplete type 'const class type_info'
  return eptr.__cxa_exception_type()->name();
                                    ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/exception_ptr.h:144:19: note: forward declaration of
      'std::__exception_ptr::type_info'
      const class type_info*
                  ^
1 error generated.
$ 
Run Code Online (Sandbox Code Playgroud)

问题:如何使用Clang修复它?或者我错过了什么,Clang拒绝代码是对的吗?

c++ clang libstdc++ c++11

6
推荐指数
1
解决办法
2543
查看次数

该程序找不到正确版本的glibc/libstdc ++,尽管它是静态链接的

我试图将我的程序与glibc静态链接,因为目标机器上的glibc版本几乎是不可预测的.我使用了链接器标志-static-libgcc和-static-libstdc ++,它运行正常.可执行文件很大,但我可以忍受它.不幸的是,当我在目标机器上运行我的可执行文件(在下面的例子中它被命名为'mytest')时,我收到以下错误:

./mytest: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.11' not found (required by libboost_log.so.1.53.0)
./mytest: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by libboost_log.so.1.53.0)
./mytest: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by libboost_log.so.1.53.0)
./mytest: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by libboost_date_time.so.1.53.0)
./mytest: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.9' not found (required by libboost_thread.so.1.53.0)
Run Code Online (Sandbox Code Playgroud)

如果我在mytest上做"串",它就会给我

$ strings mytest | grep GLIBC
GLIBC_2.9
GLIBC_2.7
GLIBC_2.8
GLIBC_2.3.2
GLIBC_2.2.5
GLIBCXX_3.4.15
GLIBCXX_3.4.11
GLIBCXX_3.4.14
GLIBCXX_3.4.9
GLIBCXX_3.4
Run Code Online (Sandbox Code Playgroud)

我认为,静态链接的工作原理是什么意思.为什么加载器仍然试图在共享glibc和libstdc ++中查找我的函数?我究竟做错了什么?

谢谢!

gcc glibc g++ ld libstdc++

6
推荐指数
1
解决办法
3055
查看次数

在clang中使用std :: async的模板函数

我在std::async 这里看一下这个例子,如下:

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <future>

template <typename RAIter>
int parallel_sum(RAIter beg, RAIter end)
{
    auto len = std::distance(beg, end);
    if(len < 1000)
        return std::accumulate(beg, end, 0);

    RAIter mid = beg + len/2;
    auto handle = std::async(std::launch::async,
                              parallel_sum<RAIter>, mid, end);
    int sum = parallel_sum(beg, mid);
    return sum + handle.get();
}

int main()
{
    std::vector<int> v(10000, 1);
    std::cout << "The sum is " << parallel_sum(v.begin(), v.end()) << '\n';
}
Run Code Online (Sandbox Code Playgroud)

我尝试用Clang 3.4的Web编译器编译它,它导致输出The sum …

c++ gcc clang libstdc++ c++11

6
推荐指数
1
解决办法
974
查看次数

让GCC在C++ 11模式下工作在FreeBSD上

如何在FreeBSD 10上获得基于GCC的C++ 11设置?似乎FreeBSD上最近的GCC版本附带的标准库已被破坏.我已经安装了端口gcc49,然后尝试编译:

#include <string>

int main()
{
  auto str = std::to_string(42);
  str = std::to_string(42ull);
  str = std::to_string(4.2);
  str.clear();
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

这给了我一个错误:

g++49 -v -std=c++11 foo.cc
Using built-in specs.
COLLECT_GCC=g++49
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc49/gcc/x86_64-portbld-freebsd10.0/4.9.2/lto-wrapper
Target: x86_64-portbld-freebsd10.0
Configured with: ./../gcc-4.9-20141022/configure --disable-nls --enable-gnu-indirect-function --libdir=/usr/local/lib/gcc49 --libexecdir=/usr/local/libexec/gcc49 --program-suffix=49 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gc
c49/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --with-ecj-jar=/usr/local/share/java/ecj-4.5.jar --enable-languages=c,c++,objc,fortran,java --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc49 --build=x86_64-portbld-freebsd10.0
Thread model: posix
gcc version 4.9.2 20141022 (prerelease) (FreeBSD Ports Collection) 
COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/local/libexec/gcc49/gcc/x86_64-portbld-freebsd10.0/4.9.2/cc1plus -quiet -v foo.cc -quiet …
Run Code Online (Sandbox Code Playgroud)

c++ gcc freebsd libstdc++ c++11

6
推荐指数
1
解决办法
2027
查看次数

何时调用__cxa_deleted_virtual

我尝试为avr c ++构建构建一个小测试用例集.

通常从c ++库提供一些"特殊功能".现在我想写一个测试程序,它产生这个必须链接的错误代码__cxa_deleted_virtual.

任何人都可以提供一个代码片段,导致链接到该功能?

我实际上不知道如何制作这个"错误"代码.

c++ libstdc++

6
推荐指数
1
解决办法
783
查看次数

如何在Visual Studio中更改C++标准库实现

我想将c ++标准库从microsoft更改为支持c ++ 17标准的另一个.我的意思是使用libstdc ++或libc ++来交换vs lib是可能的吗?我不知道如何做到这一点.

c++ libstdc++ visual-studio visual-c++ libc++

6
推荐指数
1
解决办法
858
查看次数

libstdc ++的make_shared布局是否在gcc 4.x和gcc 6.x之间发生了变化?

请考虑以下最小示例,包含三个文件:

foo.h:

#pragma once
#include <memory>

struct X {
    uint64_t i = 0xdeadbeefdeadbeefULL;
};

void foo();
Run Code Online (Sandbox Code Playgroud)

foo.cxx:

#include "foo.h"

void foo() {
    std::make_shared<X>();
}
Run Code Online (Sandbox Code Playgroud)

main.cxx:

#include <memory>
#include "foo.h"

template std::shared_ptr<X> std::make_shared();

int main() {
    foo();
}
Run Code Online (Sandbox Code Playgroud)

然后使用不同版本的gcc编译两个翻译单元:

$ g++-4.8.2 -g -std=c++11 -O0 -c foo.cxx -o foo.o
$ g++-6.2.0 -std=c++11 -D_GLIBCXX_USE_CXX11_ABI=0 -O0 -g main.cxx foo.o -fsanitize=address -fno-omit-frame-pointer
Run Code Online (Sandbox Code Playgroud)

请注意,我是专门用旧的ABI编译的.

运行生成的可执行文件(如果两个TU都使用相同版本的gcc编译,则不会):

==33535==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60300000eff8 at pc 0x000000401dcf bp 0x7fffffffd7f0 sp 0x7fffffffd7e8
WRITE of size 8 at …
Run Code Online (Sandbox Code Playgroud)

c++ gcc g++ abi libstdc++

6
推荐指数
1
解决办法
173
查看次数

标签 统计

libstdc++ ×10

c++ ×9

gcc ×5

c++11 ×3

clang ×2

g++ ×2

abi ×1

freebsd ×1

gdb ×1

glibc ×1

ld ×1

libc++ ×1

malloc ×1

new-operator ×1

qmake ×1

qt ×1

std ×1

visual-c++ ×1

visual-studio ×1