未定义的引用sync_fetch_and_add_4 [英] undefined reference to sync_fetch_and_add_4

查看:1236
本文介绍了未定义的引用sync_fetch_and_add_4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试在64位计算机上使用 __ sync_fetch_and_add 与-m32,我得到了下面的错误,而它编译罚款与正常的64位。我使用gcc编译器4.1.2。有什么可这里的问题和如何解决?

  replication.cpp :(文字+ 0xb3b):未定义的参考`__sync_fetch_and_add_4
。replication.cpp :(文字+ 0xb82):未定义的参考`__sync_fetch_and_add_4
。replication.cpp :(文字+ 0xcc2):未定义的参考`__sync_fetch_and_add_4
/tmp/cc7u9FLV.o:在功能`potential_barrier_leader(无符号整数,pthread_barrier_t *):
。replication.cpp :(文字+ 0xd3f):未定义的参考`__sync_fetch_and_add_4
。replication.cpp :(文字+ 0xd54):未定义的参考`__sync_fetch_and_add_4
/tmp/cc7u9FLV.o:replication.cpp:(.text+0xdb0):为`__sync_fetch_and_add_4更未定义的引用遵循
collect2:劳工处返回1退出状态
使:*** [全部]错误1


解决方案

使用的 -march = i486的标志的伎俩我。

Whenever I try to use __sync_fetch_and_add with -m32 on a 64 bit machine, I get the following error, while it compiles fine with normal 64 bit. I am using gcc compiler 4.1.2. What can be the problem here and what is the solution?

replication.cpp:(.text+0xb3b): undefined reference to `__sync_fetch_and_add_4'
replication.cpp:(.text+0xb82): undefined reference to `__sync_fetch_and_add_4'
replication.cpp:(.text+0xcc2): undefined reference to `__sync_fetch_and_add_4'
/tmp/cc7u9FLV.o: In function `potential_barrier_leader(unsigned int, pthread_barrier_t*)':
replication.cpp:(.text+0xd3f): undefined reference to `__sync_fetch_and_add_4'
replication.cpp:(.text+0xd54): undefined reference to `__sync_fetch_and_add_4'
/tmp/cc7u9FLV.o:replication.cpp:(.text+0xdb0): more undefined references to `__sync_fetch_and_add_4' follow
collect2: ld returned 1 exit status
make: *** [all] Error 1

解决方案

Using -march=i486 flag did the trick for me.

这篇关于未定义的引用sync_fetch_and_add_4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆