Skip to content

Fail to make (Undefined symbols for architecture x86_64) #1933

Closed

Description

@airpingu

cd src && make all
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof .o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-
)
(rm -f .make-)
echo STD=-std=c99 -pedantic >> .make-settings
echo WARN=-Wall >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=libc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -Wall -O2 -g -ggdb -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src >> .make-settings
echo PREV_FINAL_LDFLAGS= -g -ggdb >> .make-settings
(cd ../deps && make hiredis linenoise lua)
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-
)
(echo "" > .make-ldflags)
(echo "" > .make-cflags)
MAKE hiredis
cd hiredis && make static
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb hiredis.c
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb sds.c
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb async.c
ar rcs libhiredis.a net.o hiredis.o sds.o async.o
MAKE linenoise
cd linenoise && make
cc -Wall -Os -g -c linenoise.c
MAKE lua
cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI " MYLDFLAGS=""
cc -O2 -Wall -DLUA_ANSI -c -o lapi.o lapi.c
cc -O2 -Wall -DLUA_ANSI -c -o lcode.o lcode.c
cc -O2 -Wall -DLUA_ANSI -c -o ldebug.o ldebug.c
cc -O2 -Wall -DLUA_ANSI -c -o ldo.o ldo.c
cc -O2 -Wall -DLUA_ANSI -c -o ldump.o ldump.c
cc -O2 -Wall -DLUA_ANSI -c -o lfunc.o lfunc.c
cc -O2 -Wall -DLUA_ANSI -c -o lgc.o lgc.c
cc -O2 -Wall -DLUA_ANSI -c -o llex.o llex.c
cc -O2 -Wall -DLUA_ANSI -c -o lmem.o lmem.c
cc -O2 -Wall -DLUA_ANSI -c -o lobject.o lobject.c
cc -O2 -Wall -DLUA_ANSI -c -o lopcodes.o lopcodes.c
cc -O2 -Wall -DLUA_ANSI -c -o lparser.o lparser.c
cc -O2 -Wall -DLUA_ANSI -c -o lstate.o lstate.c
cc -O2 -Wall -DLUA_ANSI -c -o lstring.o lstring.c
cc -O2 -Wall -DLUA_ANSI -c -o ltable.o ltable.c
cc -O2 -Wall -DLUA_ANSI -c -o ltm.o ltm.c
cc -O2 -Wall -DLUA_ANSI -c -o lundump.o lundump.c
cc -O2 -Wall -DLUA_ANSI -c -o lvm.o lvm.c
cc -O2 -Wall -DLUA_ANSI -c -o lzio.o lzio.c
cc -O2 -Wall -DLUA_ANSI -c -o strbuf.o strbuf.c
cc -O2 -Wall -DLUA_ANSI -c -o lauxlib.o lauxlib.c
cc -O2 -Wall -DLUA_ANSI -c -o lbaselib.o lbaselib.c
cc -O2 -Wall -DLUA_ANSI -c -o ldblib.o ldblib.c
cc -O2 -Wall -DLUA_ANSI -c -o liolib.o liolib.c
cc -O2 -Wall -DLUA_ANSI -c -o lmathlib.o lmathlib.c
cc -O2 -Wall -DLUA_ANSI -c -o loslib.o loslib.c
loslib.c:60:3: warning: 'tmpnam' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that
you use mkstemp(3) instead. [-Wdeprecated-declarations]
lua_tmpnam(buff, err);
^
./luaconf.h:657:33: note: expanded from macro 'lua_tmpnam'

define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }

                                   ^

/usr/include/stdio.h:274:7: note: 'tmpnam' declared here
char *tmpnam(char *);
^
1 warning generated.
cc -O2 -Wall -DLUA_ANSI -c -o ltablib.o ltablib.c
cc -O2 -Wall -DLUA_ANSI -c -o lstrlib.o lstrlib.c
cc -O2 -Wall -DLUA_ANSI -c -o loadlib.o loadlib.c
cc -O2 -Wall -DLUA_ANSI -c -o linit.o linit.c
cc -O2 -Wall -DLUA_ANSI -c -o lua_cjson.o lua_cjson.c
cc -O2 -Wall -DLUA_ANSI -c -o lua_struct.o lua_struct.c
cc -O2 -Wall -DLUA_ANSI -c -o lua_cmsgpack.o lua_cmsgpack.c
ar rcu liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o strbuf.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o lua_cjson.o lua_struct.o lua_cmsgpack.o # DLL needs all object files
ranlib liblua.a
cc -O2 -Wall -DLUA_ANSI -c -o lua.o lua.c
cc -o lua lua.o liblua.a -lm
cc -O2 -Wall -DLUA_ANSI -c -o luac.o luac.c
cc -O2 -Wall -DLUA_ANSI -c -o print.o print.c
cc -o luac luac.o print.o liblua.a -lm
CC adlist.o
CC ae.o
CC anet.o
CC dict.o
CC redis.o
CC sds.o
CC zmalloc.o
zmalloc.c:129:5: warning: implicit declaration of function '__atomic_add_fetch' is invalid in C99 [-Wimplicit-function-declaration]
update_zmalloc_stat_alloc(zmalloc_size(ptr));
^
zmalloc.c:95:9: note: expanded from macro 'update_zmalloc_stat_alloc'
update_zmalloc_stat_add(_n);
^
zmalloc.c:71:38: note: expanded from macro 'update_zmalloc_stat_add'

define update_zmalloc_stat_add(__n) __atomic_add_fetch(&used_memory, (__n), __ATOMIC_RELAXED)

                                 ^

zmalloc.c:165:5: warning: implicit declaration of function '__atomic_sub_fetch' is invalid in C99 [-Wimplicit-function-declaration]
update_zmalloc_stat_free(oldsize);
^
zmalloc.c:105:9: note: expanded from macro 'update_zmalloc_stat_free'
update_zmalloc_stat_sub(_n);
^
zmalloc.c:72:38: note: expanded from macro 'update_zmalloc_stat_sub'

define update_zmalloc_stat_sub(__n) __atomic_sub_fetch(&used_memory, (__n), __ATOMIC_RELAXED)

                                 ^

2 warnings generated.
CC lzf_c.o
CC lzf_d.o
CC pqsort.o
CC zipmap.o
CC sha1.o
CC ziplist.o
CC release.o
CC networking.o
CC util.o
CC object.o
CC db.o
CC replication.o
CC rdb.o
CC t_string.o
CC t_list.o
CC t_set.o
CC t_zset.o
CC t_hash.o
CC config.o
CC aof.o
CC pubsub.o
CC multi.o
CC debug.o
CC sort.o
CC intset.o
CC syncio.o
CC cluster.o
CC crc16.o
CC endianconv.o
CC slowlog.o
CC scripting.o
CC bio.o
CC rio.o
CC rand.o
CC memtest.o
CC crc64.o
CC bitops.o
CC sentinel.o
CC notify.o
CC setproctitle.o
CC blocked.o
CC hyperloglog.o
CC latency.o
CC sparkline.o
LINK redis-server
Undefined symbols for architecture x86_64:
"___atomic_add_fetch", referenced from:
_zmalloc in zmalloc.o
_zcalloc in zmalloc.o
_zrealloc in zmalloc.o
_zmalloc_used_memory in zmalloc.o
_zmalloc_get_fragmentation_ratio in zmalloc.o
"___atomic_sub_fetch", referenced from:
_zrealloc in zmalloc.o
_zfree in zmalloc.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [redis-server] Error 1
make: *** [all] Error 2

Activity

  1. airpingu commented on Aug 13, 2014

    @airpingu
    Author

    I'd appreciate if anyone can give some hints to tackle this. Thank you!

  2. badboy commented on Aug 13, 2014

    @badboy
    Contributor

    What system? what compiler?

  3. airpingu commented on Aug 13, 2014

    @airpingu
    Author

    Mac OS X 10.9.4 with g++/gcc-4.9

  4. mattsta commented on Aug 13, 2014

    @mattsta
    Contributor

    Mac OS X 10.9.4 with g++/gcc-4.9

    That combination does work, so your source tree is broken somehow.

    Try a clean checkout in a new directory or try make distclean; make V=1

  5. airpingu commented on Aug 13, 2014

    @airpingu
    Author

    I just tried make distclean; make V=1. This issue is still the same:

    (skip...)
    cc -g -ggdb -o redis-server adlist.o ae.o anet.o dict.o redis.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a
    Undefined symbols for architecture x86_64:
    "___atomic_add_fetch", referenced from:
    _zmalloc in zmalloc.o
    _zcalloc in zmalloc.o
    _zrealloc in zmalloc.o
    _zmalloc_used_memory in zmalloc.o
    _zmalloc_get_fragmentation_ratio in zmalloc.o
    "___atomic_sub_fetch", referenced from:
    _zrealloc in zmalloc.o
    _zfree in zmalloc.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [redis-server] Error 1
    make: *** [all] Error 2

  6. mattsta commented on Aug 13, 2014

    @mattsta
    Contributor

    One thing of note: cc -g -ggdb ... <-- that's clang, not gcc-4.9

    Where did you get Redis from (website archive, git clone, other)?

    What's the contents of version.h in src/?

    What if you do compile with gcc-4.9 (make distclean; CC=gcc-4.9 make)?

  7. airpingu commented on Aug 13, 2014

    @airpingu
    Author

    Oh yeap. That's clang not gcc! Stupid me!

    I got Redis from http://redis.io/download (3.0.0 Beta-8).

    The version.h in Redis shows REDIS_VERSION "2.9.57" (weird here... isn't it 3.0.0?).

    I just tried make distclean; CC=gcc-4.9 make and ran make package under Jedis and it start working! Thanks to your awesome suggestion! :)

    However, in the end it still shows me two tests error:

    Results :

    Tests in error:
    ControlCommandsTest.waitReplicas:123 » JedisData ERR unknown command 'WAIT'
    JedisSentinelPoolTest.ensureSafeTwiceFailover:43->forceFailover:150 » JedisConnection

    Tests run: 365, Failures: 0, Errors: 2, Skipped: 0

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 04:50 min
    [INFO] Finished at: 2014-08-14T00:07:10+08:00
    [INFO] Final Memory: 16M/246M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test (default-test) on project jedis: There are test failures.
    [ERROR]
    [ERROR] Please refer to /Users/genelian/yahoo/twdata/legolas/jedis/target/surefire-reports for the individual test results.
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
    make: *** [package] Error 1

    Any thoughts?

  8. mattsta commented on Aug 13, 2014

    @mattsta
    Contributor

    Glad it's finally working! Though, clang should have no problem compiling Redis. There's still something kinda strange with your setup.

    As far as jedis goes, that's outside of what we can help with. Though, if it doesn't recognize the "wait" command, it may be connecting to a very old Redis server (not the one you compiled)?

  9. airpingu commented on Aug 13, 2014

    @airpingu
    Author

    Oops... I think the new issue should a Jedis one. I shouldn't post that here. I'll repost that at https://github.com/xetorthio/jedis/issues/ later. I was hoping to see if anyone here is facing the same issue.

    Anyway, thanks @mattsta. Really appreciate your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions