LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-18-2010, 11:43 AM   #1
dino3333
LQ Newbie
 
Registered: Jan 2010
Posts: 2

Rep: Reputation: 0
memcached and undefined reference to `__sync_fetch_and_add_4' error


Hi Everyone,
I tried to install memcached onto a freebsd 8.0 machine. I saw that for some reason libmemcached was not updated to the latest version so I tried to update that port manually. When I try to install it I get this error

Code:
===> Building for libmemcached-0.37_1
gmake all-recursive
gmake[1]: Entering directory `/usr/ports/databases/libmemcached/work/libmemcached-0.37'
Making all in docs
gmake[2]: Entering directory `/usr/ports/databases/libmemcached/work/libmemcached-0.37/docs'
ln -s ../docs/memcached_result_st.pod ../docs/memcached_result_cas.pop
ln -s ../docs/memcached_result_st.pod ../docs/memcached_result_create.pop
ln -s ../docs/memcached_result_st.pod ../docs/memcached_result_flags.pop
ln -s ../docs/memcached_result_st.pod ../docs/memcached_result_free.pop
ln -s ../docs/memcached_result_st.pod ../docs/memcached_result_key_length.pop
ln -s ../docs/memcached_result_st.pod ../docs/memcached_result_key_value.pop
ln -s ../docs/memcached_result_st.pod ../docs/memcached_result_length.pop
ln -s ../docs/memcached_result_st.pod ../docs/memcached_result_st.pop
ln -s ../docs/memcached_result_st.pod ../docs/memcached_result_value.pop
gmake all-am
gmake[3]: Entering directory `/usr/ports/databases/libmemcached/work/libmemcached-0.37/docs'
gmake[3]: Nothing to be done for `all-am'.
gmake[3]: Leaving directory `/usr/ports/databases/libmemcached/work/libmemcached-0.37/docs'
gmake[2]: Leaving directory `/usr/ports/databases/libmemcached/work/libmemcached-0.37/docs'
gmake[2]: Entering directory `/usr/ports/databases/libmemcached/work/libmemcached-0.37'
CCLD clients/memslap
clients/ms_conn.o(.text+0x9b3): In function `ms_build_udp_headers':
clients/ms_conn.c:184: undefined reference to `__sync_fetch_and_add_4'
clients/ms_conn.o(.text+0x1ba7): In function `ms_reconn_socks':
clients/ms_conn.c:1055: undefined reference to `__sync_fetch_and_add_4'
clients/ms_conn.o(.text+0x2240): In function `ms_drive_machine':
clients/ms_conn.c:924: undefined reference to `__sync_fetch_and_add_4'
clients/ms_conn.o(.text+0x3365):clients/ms_conn.c:960: undefined reference to `__sync_fetch_and_add_4'
clients/ms_thread.o(.text+0x496): In function `ms_worker_libevent':
clients/ms_thread.c:215: undefined reference to `__sync_fetch_and_add_4'
clients/ms_thread.o(.text+0x4fa):clients/ms_thread.c:198: more undefined references to `__sync_fetch_and_add_4' follow
gmake[2]: *** [clients/memslap] Error 1
gmake[2]: Leaving directory `/usr/ports/databases/libmemcached/work/libmemcached-0.37'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/usr/ports/databases/libmemcached/work/libmemcached-0.37'
gmake: *** [all] Error 2
*** Error code 1

Stop in /usr/ports/databases/libmemcached.
What does this mean?!?!

Thanks for the help!
 
Old 12-28-2014, 02:06 PM   #2
debguy
Member
 
Registered: Oct 2014
Location: U.S.A.
Distribution: mixed, mostly debian slackare today
Posts: 207

Rep: Reputation: 19
error: __sync_fetch_and_add_4 is not defined

error: __sync_fetch_and_add_4 is not defined means sync_fetch_and_add isnt

hahah! there are 5+ "standard atomic libs" (+kernel support) that's hardly atomic if you ask me. but ignore it, is all a timely distraction.

so your building, ie glibc and get that error (i did)

glibc-2.11.x expects gcc-4.4.x to define it internally, and you have gcc sans built-in atomic, likely you didnt specify arch that gcc accepts (due to lacky directions). were glibc likes 786, gcc wants 386 and figures 786 maybe. use "native" should do it. opt(march) and opt(mtune) ARE NON OPTIONAL gcc builds wrong w/o them (likely)

you won't find a header or libfoo that defines it

for linux-gnu you might use (a simple for moi build)

cd gcc-4.4.foo
./configure --with-glibc-version=2.11 --enable-threads=posix \
--disable-cloog --disable-ppl --disable-libssp --enable-__cxa_atexit \
--disable-rpath --disable-nls --disable-bootstrp --disable-multilib \
--with-system-libunwind

IMPORTANT: if you build gcc w/o known arch it wont have sync_fetch_and_add
(p.s. glibc sync_fetch_and_add_4 is just macro for sync_fetch_and_add which, aga
in, glibc expects is defined)

also if you replace gcc-3.foo with gcc-4.4.foo and are compiling you may need:

[ -n "$newgnu" ] && CFLAGS="$CFLAGS -march=native -mtune=native "
[ -n "$newgnu" ] && \
CFLAGS="$CFLAGS -std=gnu89 " && CPPFLAGS="$CPPFLAGS -std=gnu89 "

i newly need this (newgnu) to build binutils-ver/: -Wstrict-aliasing=0

cd glibc-2.foo/
./configure --with-headers=/usr/src/linux/usr/include \
--enable-kernel=2.2.foo \
--disable-profile --disable-sanity-checks --with-tls
--disable-rpath --disable-nls

* thanks guy in holland for posting --std that might be an issue for gcc upgraders !

* no thanks to comittees continually changing and also creating "standards" that make depends problems in gcc use .h or .c appropriately to get your features for you project like everyone else !!

*** all this sync_fetc_ bull added up to: a single asm instruction to "lock" (386 nmemonics) added in your code. horay you could have darn typed in the assembler quicker had you knew what the holdup was and where ! isn't progress nice ...

have fun
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Undefined reference error jacques83 Programming 20 04-11-2013 07:23 AM
libmemcached-0.37 and undefined reference to `__sync_fetch_and_add_4 error dino3333 Linux - Software 0 01-15-2010 11:40 AM
glibc make error: undefined reference to `__sync_fetch_and_add_4' rendezvous123 Linux - Software 4 11-09-2008 07:18 PM
Undefined Reference error JMJ_coder Programming 6 03-20-2008 01:27 AM
undefined reference error Quest101 Programming 3 01-01-2005 12:27 PM


All times are GMT -5. The time now is 12:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration