tcmalloc是Google开源的一个内存管理库, 作为glibc malloc的替代品,效率大概是gclibc malloc的几倍。想在工程中用上tcmalloc非常的简单,我们采用了静态编译的方式,通过增加链接选项-ltcmalloc静态链接libtcmalloc.a即可。但是在链接过程中出现了意外情况,报出了如下错误:

../3party/static_libs/libtcmalloc.a(libtcmalloc_la-linuxthreads.o): In function `TCMalloc_ListAllProcessThreads':
linuxthreads.cc:(.text+0x333): undefined reference to `sem_init'
linuxthreads.cc:(.text+0x41c): undefined reference to `sem_post'
linuxthreads.cc:(.text+0x477): undefined reference to `sem_destroy'
../3party/static_libs/libtcmalloc.a(libtcmalloc_la-linuxthreads.o): In function `ListerThread':
linuxthreads.cc:(.text+0x67b): undefined reference to `sem_wait'
collect2: error: ld returned exit status

sem_init是库函数,头文件是#include<semaphore.h>。搜索了很多资料,都说是缺少了链接选项-lpthread,但是我们的Makefile是有-lpthread选项的,又尝试了在编译选项里面加-pthread,但还是没有效果,各种办法都尝试了之后,最后试着把-lpthread选项放到了-tcmalloc选项后面,居然就通过了,也算是比较乌龙吧。

使用tcmalloc编译出现undefined reference to `sem_init'的更多相关文章

  1. [转载]解决linux 下多线程错误 undefined reference to `sem_init'

    转自:https://blog.csdn.net/yzycqu/article/details/7396498?utm_source=copy 解决linux 下多线程错误 undefined ref ...

  2. QT添加自定义信号后编译出现undefined reference

    QT添加自定义信号后编译出现undefined reference 这是需要重新生成qmake: build --->run qmake

  3. Android编译错误——undefined reference to

    [错误描述] 未定义引用 提示如下:bootable/recovery/minzip/Zip.c:1122: error: undefined reference to 'selabel_lookup ...

  4. Android NDK编译之undefined reference to 'JNI_CreateJavaVM'

    利用Android NDK编译动态库,在C文件中调用了两个JNI函数:JNI_GetDefaultJavaVMInitArgs和JNI_CreateJavaVM.编译的时候始终报以下错误: XXX: ...

  5. FFmpeg编译: undefined reference to 'av_frame_alloc()'

    今天使用CMake编译FFmpeg的时候,死活编不过,提示什么“undefined reference to 'av_frame_alloc()” 后来仔细查找,发现是头文件包含错误. 错误的代码: ...

  6. [ c++] cmake 编译时 undefined reference to `std::cout' 错误的解决方案

    cmake ..  和 make 之后,出现如下错误 Linking CXX executable ../../../bin/ModuleTest CMakeFiles/ModuleTest.dir/ ...

  7. Linux下编译出现undefined reference to ‘pthread_create’问题解决

    1.代码 /* * File: HeartPackageSendAgent.cpp * Author: Pangxiaojian * * * 主要实现:向服务器发送心跳包,每5s向服务器发送一个心跳包 ...

  8. Caffe 编译: undefined reference to imencode()

    本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/52150781 整理之前编译工程中遇到的 ...

  9. Qt 编译出错“undefined reference to `vtable for”

    1. 有时,如果将某个类改为继承自QObject类(以前不继承自该类),编译时会出错. 解决: clean Project, run qmake, rebulid都运行一遍,好了! 因为qmake生成 ...

随机推荐

  1. 玩转Eclipse — 自动代码规范检查工具Checkstyle

    大项目都需要小组中的多人共同完成,但是每个人都有自己的编码习惯,甚至很多都是不正确的.那么如何使小组所有开发人员都遵循某些编码规范,以保证项目代码风格的一致性呢?如果硬性地要求每个开发人员在提交代码之 ...

  2. C#封装的一个JSON操作类

    using System; using System.Collections.Generic; using System.Collections; using System.Text; using S ...

  3. LG2590 [ZJOI2008]树的统计

    题意 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w. 我们将以下面的形式来要求你对这棵树完成一些操作: I. CHANGE u t : 把结点u的权值改为t II. QMAX u v: ...

  4. @Autowired & @Resource 区别 & 解读@Bean

    一样     Autowired & @Resource 都可以用来Bean的注入,可以写在属性(字段)上.也可以写在setter方法上 不一样 1.来源不一样 @Autowired 由Spr ...

  5. 我的 Git 学习过程

    我的 Git 学习过程 有 SVN 使用基础. 开始使用 FastAdmin 后正式使用 Git. 找了一篇廖雪峰的 <Git 教程> 找到一个在线学习 Git 的教程 https://l ...

  6. bzoj 1185 [HNOI2007]最小矩形覆盖——旋转卡壳

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1185 矩形一定贴着凸包的一条边.不过只是感觉这样. 枚举一条边,对面的点就是正常的旋转卡壳. ...

  7. 请求MWS报错401:Access Denied

    跑MWS接口,报错: Caught Exception: Access denied Response Status Code: Error Code: AccessDenied Error Type ...

  8. openresty+lua做接口调用权限限制

    说明:openresty可以理解为一个服务器它将nginx的核心包含了过来,并结合lua脚本语言实现一些对性能要求高的功能,该篇文章介绍了使用openresty 1.purview.lua --调用j ...

  9. Eclipse中添加web dynamic project【菜鸟学JAVA】

    很多eclipse版本是不能直接新建web dynamic project的,需要从网上找插件或更新.我的Eclipse的版本是(Version: 3.7.0) 比较方便的是在Help → Insta ...

  10. [转]Winform 经验集

    多线程篇: CheckForIllegalCrossThreadCalls = false; 更多示例可见: http://www.cnblogs.com/z5337/p/4030287.html i ...