使用tcmalloc编译出现undefined reference to `sem_init'
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'的更多相关文章
- [转载]解决linux 下多线程错误 undefined reference to `sem_init'
转自:https://blog.csdn.net/yzycqu/article/details/7396498?utm_source=copy 解决linux 下多线程错误 undefined ref ...
- QT添加自定义信号后编译出现undefined reference
QT添加自定义信号后编译出现undefined reference 这是需要重新生成qmake: build --->run qmake
- Android编译错误——undefined reference to
[错误描述] 未定义引用 提示如下:bootable/recovery/minzip/Zip.c:1122: error: undefined reference to 'selabel_lookup ...
- Android NDK编译之undefined reference to 'JNI_CreateJavaVM'
利用Android NDK编译动态库,在C文件中调用了两个JNI函数:JNI_GetDefaultJavaVMInitArgs和JNI_CreateJavaVM.编译的时候始终报以下错误: XXX: ...
- FFmpeg编译: undefined reference to 'av_frame_alloc()'
今天使用CMake编译FFmpeg的时候,死活编不过,提示什么“undefined reference to 'av_frame_alloc()” 后来仔细查找,发现是头文件包含错误. 错误的代码: ...
- [ c++] cmake 编译时 undefined reference to `std::cout' 错误的解决方案
cmake .. 和 make 之后,出现如下错误 Linking CXX executable ../../../bin/ModuleTest CMakeFiles/ModuleTest.dir/ ...
- Linux下编译出现undefined reference to ‘pthread_create’问题解决
1.代码 /* * File: HeartPackageSendAgent.cpp * Author: Pangxiaojian * * * 主要实现:向服务器发送心跳包,每5s向服务器发送一个心跳包 ...
- Caffe 编译: undefined reference to imencode()
本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/52150781 整理之前编译工程中遇到的 ...
- Qt 编译出错“undefined reference to `vtable for”
1. 有时,如果将某个类改为继承自QObject类(以前不继承自该类),编译时会出错. 解决: clean Project, run qmake, rebulid都运行一遍,好了! 因为qmake生成 ...
随机推荐
- SpringBoot @ConfigurationProperties报错
idea报错如下: Not registered via @EnableConfigurationProperties or marked as Spring component less... (C ...
- check sub-string in the string
if "blah" not in somestring: continue
- Navicat Premium 连接Oracle 出现ora-12505 错误解决方案
找到listener.ora文件:我的Oracle是安装在F盘, 路径为:F:\oracle\product\10.2.0\db_1\network\admin\listener.ora 改动前的配 ...
- RESTful的一个样例
后台代码: @RequestMapping(value = { "queues" }) @ResponseBody public List<ResourcePool> ...
- (转)Maven的pom.xml文件结构之Build配置build
在Maven的pom.xml文件中,Build相关配置包含两个部分,一个是<build>,另一个是<reporting>,这里我们只介绍<build>. 1. 在M ...
- 利用OsCache实现后端轮循
轮循随处可见,最常用的是APP首页的一些促销活动,一两秒切换一张图片,让前端实现起来也不难.这里说下后端的轮循,实现原理是数组+缓存.将数组放入缓存,指定缓存失效时间,如果是在失效前从缓存中取数据,那 ...
- string源码分析 ——转载 http://blogs.360.cn/360cloud/2012/11/26/linux-gcc-stl-string-in-depth/
1. 问题提出 最近在我们的项目当中,出现了两次与使用string相关的问题. 1.1. 问题1:新代码引入的Bug 前一段时间有一个老项目来一个新需求,我们新增了一些代码逻辑来处理这个新需求.测试阶 ...
- print 和 println的区别
println 输出字符后,下一个输出的字符会换行展示 print 输出字符后,下一个输出字符不会会换展示
- Sentinel限流示例:编码和注解限流
一.Sentinel 是什么? 随着微服务的流行,服务和服务之间的稳定性变得越来越重要.Sentinel 以流量为切入点,从流量控制.熔断降级.系统负载保护等多个维度保护服务的稳定性. Sentine ...
- PTA 1005 Spell It Right (20)(20 分)水题
1005 Spell It Right (20)(20 分) Given a non-negative integer N, your task is to compute the sum of al ...