小编yoc*_*oco的帖子

使用静态链接重新定义malloc/free具有多个定义错误

最近,我的公司想要将编译器从gcc-3.4更新到gcc-4.5.但是,我们客户的机器可能没有最新版本libstdc++.so,因此我们希望静态链接我们的二进制文件.

我们的计划需要根据malloc()/free()非常高的性能要求定制.

我修改了makefile,添加了一段-static时间链接,并收到以下错误消息:

/usr/lib64/libc.a(malloc.o)(.text+0x18c0): In function `free':
: multiple definition of `free'
../../ic/src/memmgr/libmemmgr_mt_thread.a(memmgr_mt_thread.o)(.text+0x3430): first defined here
/usr/bin/ld: Warning: size of symbol `free' changed from 271 in ../../ic/src/memmgr/libmemmgr_mt_thread.a(memmgr_mt_thread.o) to 255 in /usr/lib64/libc.a(malloc.o)
/usr/lib64/libc.a(malloc.o)(.text+0x3970): In function `malloc':
: multiple definition of `malloc'
../../ic/src/memmgr/libmemmgr_mt_thread.a(memmgr_mt_thread.o)(.text+0x29c0): first defined here
/usr/bin/ld: Warning: size of symbol `malloc' changed from 281 in ../../ic/src/memmgr/libmemmgr_mt_thread.a(memmgr_mt_thread.o) to 461 in /usr/lib64/libc.a(malloc.o)
/usr/lib64/libc.a(malloc.o)(.text+0x4050): In function `realloc':
: multiple definition of `realloc'
../../ic/src/memmgr/libmemmgr_mt_thread.a(memmgr_mt_thread.o)(.text+0x3e80): first defined here
/usr/bin/ld: Warning: …
Run Code Online (Sandbox Code Playgroud)

c c++ malloc gcc static-linking

7
推荐指数
1
解决办法
5811
查看次数

如何unordered_set <tuple <int,int >>?

我在构造一个时遇到了奇怪的问题unordeed_set<tuple<int,int>>.我曾尝试过VC++ 8,gcc3.2,gcc4.3,都有相同的结果.我不知道代码有什么问题,以下是我的代码:

#include <boost/unordered_set.hpp>
#include <boost/tuple/tuple.hpp>
// For unordered container, the declaration of operator==
#include <boost/tuple/tuple_comparison.hpp>

using namespace std ;
using namespace boost ;

// define of the hash_value funciton for tuple<int, int>
size_t hash_value(tuple<int, int> const& t) {
    return get<0>(t) * 10 + get<1>(t) ;
}

int main () {
    unordered_set<tuple<int, int>> s ;
    tuple<int, int> t ;
    s.insert(t) ;
}
Run Code Online (Sandbox Code Playgroud)

这是编译错误消息:

1>c:\libs\boost_1_37_0\boost\functional\hash\extensions.hpp(72) : error C2665: 'boost::hash_value' : none of the 16 overloads could convert all the …
Run Code Online (Sandbox Code Playgroud)

c++ boost

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

Google perftool无法读取文件"libprofiler.so.0"

我正在尝试使用谷歌性能工具进行CPU时间分析.但是,我遇到了一些问题,我无法读取共享库文件"libprofiler.so.0"

我已经阅读了google性能工具的自述文件,手册中有3个步骤:

  1. 编译我的程序-lprofiler.我没有遇到任何问题.

  2. 运行我的程序的二进制文件以生成配置文件结果文件.
    我在这一步失败了.当我尝试运行我的二进制文件时,会出现一条错误消息:
    "error while loading shared libraries: libprofiler.so.0: cannot open shared object file: No such file or directory.".
    我用谷歌搜索,在这个页面中,有人说它"libprofiler.so.0""/usr/local/lib",所以我将共享库文件复制到我的二进制文件目录,并尝试运行我的二进制文件.它仍然报告相同的错误消息.

我刚刚使用Linux大约一年,请原谅我,如果我的问题非常愚蠢.并且,提前谢谢你.

我的机器信息:

  • 操作系统:Ubuntu 8.10
  • 编译器:gcc 4.3.2
  • shell:bash
  • 谷歌性能工具版本:1.4(我今天刚下载)

linux shared-libraries dynamic-linking google-perftools

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

Hg:如何将变更集标记为"稳定"

作为hg本身存储库,一些变更集标记为'stable'.我想知道如何将'stable'标记添加到更改集.我用谷歌搜索,但它没有帮助.我试过'hg help tag'但仍然无法弄清楚该怎么做.我想念一些非常基本的东西吗?

提前致谢.

mercurial

5
推荐指数
1
解决办法
278
查看次数

clang_complete错误:未知参数:' - std = c ++ 0x'

clang ++版本:2.9 vim版本:7.3

我写了我的 .clang_comple

--std=c++0x
Run Code Online (Sandbox Code Playgroud)

跟随源代码test.cc:

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

并且clang_complete显示

test.cc|| unknown argument: '--std=c++0x'
Run Code Online (Sandbox Code Playgroud)

在quickfix列表中.

我尝试添加选项

set g:clang_user_options="--std=c++0x"
Run Code Online (Sandbox Code Playgroud)

问题仍然存在.

试图追踪一些clang_complete的代码,但仍然无法解决这个问题.所有其他选项都可以正确处理,但不能--std=c++0x错过任何内容吗?或者做错了什么?

c++ clang c++11 libc++ clang-complete

3
推荐指数
1
解决办法
5398
查看次数

Boost序列化多态寄存器(导出)不能跨文件工作

boost::serialization在我的项目中使用.该项目很大,并在几个地方序列化我的对象.根据这里文档,我应该用两个单独的步骤导出我的类.

  1. BOOST_EXPORT_KEY().h文件中,女巫包含声明.
  2. BOOST_EXPOET_IMPLEMENT().cpp文件中,witch包含导出的实例化(定义).

hier.h 在类层次结构中,层次结构中有3个类.

/*
B <---+--- D1
      |
      +--- D2
*/

#include <boost/serialization/base_object.hpp>                                                                                                                                                                 

class B {                                                                                                                                                                                                      
public:                                                                                                                                                                                                        
    virtual ~B() {}                                                                                                                                                                                            
    template < typename Ar >                                                                                                                                                                                   
    void serialize(Ar& ar, const int) {                                                                                                                                                                        
    }                                                                                                                                                                                                          
} ;                                                                                                                                                                                                            

class D1 : public B {                                                                                                                                                                                          
public:                                                                                                                                                                                                        
    virtual ~D1() {}                                                                                                                                                                                           
    template < typename Ar > void serialize(Ar& ar, const int) {                                                                                                                                               
        boost::serialization::base_object<B>(*this);                                                                                                                                                           
    }                                                                                                                                                                                                          
} ;                                                                                                                                                                                                            

class D2 : public B {                                                                                                                                                                                          
public: …
Run Code Online (Sandbox Code Playgroud)

boost boost-serialization

3
推荐指数
1
解决办法
4008
查看次数