今天在一台主机上编译 memcached 的客户端库 libmemcached,./configure 配置结果如下
---
Configuration summary for libmemcached version 0.40
* Installation prefix: /usr/local
* System type: pc-linux-gnu
* Host CPU: i686
* C Compiler: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
* Assertions enabled: yes
* Debug enabled: no
* Warnings as failure: no
---
在运行编译后,出现如下错误
clients/ms_conn.o: In function `ms_get_udp_request_id':
/root/libmemcached-0.40/clients/ms_conn.c:194: undefined reference to `__sync_fetch_and_add_4'
clients/ms_conn.o: In function `ms_reconn_socks':
/root/libmemcached-0.40/clients/ms_conn.c:1051: undefined reference to `__sync_fetch_and_add_4'
clients/ms_conn.o: In function `ms_reconn':
/root/libmemcached-0.40/clients/ms_conn.c:919: undefined reference to `__sync_fetch_and_add_4'
/root/libmemcached-0.40/clients/ms_conn.c:956: undefined reference to `__sync_fetch_and_add_4'
clients/ms_thread.o: In function `ms_setup_thread':
/root/libmemcached-0.40/clients/ms_thread.c:225: undefined reference to `__sync_fetch_and_add_4'
clients/ms_thread.o:/root/libmemcached-0.40/clients/ms_thread.c:208: more undefined references to `__sync_fetch_and_add_4' follow
collect2: ld returned 1 exit status
估计是服务器 i386 和 i686 的关系,Google 后通过配置命令解决
./configure --disable-64bit CFLAGS="-O3 -march=i686"