尝试编译webdis时出错

时间:2011-08-01 15:37:04

标签: c++ c gcc redis ld

我将使用webdis,但在链接阶段获取和错误。 Webdis是redis数据库的Web界面。您可以在此处找到它:http://webd.is

我的系统配置是:

* Ubuntu Oneiric Ocelot (11.10 Alpha)
* Gcc 4.6
* Linux kernel 3.0.0-7

当我确实生成下一个输出时:

krolik@krolik-PC:~/Projects/webdis$ make
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o webdis.o webdis.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o cmd.o cmd.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o worker.o worker.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o slog.o slog.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o server.o server.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o libb64/cencode.o libb64/cencode.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o acl.o acl.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o md5/md5.o md5/md5.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o http.o http.c
http.c: In function ‘http_response_write’:
http.c:138:9: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o client.o client.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o websocket.o websocket.c
websocket.c: In function ‘ws_handshake_reply’:
websocket.c:76:6: warning: variable ‘ret’ set but not used [-Wunused-but-set-variable]
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o pool.o pool.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o conf.o conf.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o formats/json.o formats/json.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o formats/raw.o formats/raw.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o formats/common.o formats/common.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o formats/custom-type.o formats/custom-type.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o formats/bson.o formats/bson.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o hiredis/hiredis.o hiredis/hiredis.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o hiredis/sds.o hiredis/sds.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o hiredis/net.o hiredis/net.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o hiredis/async.o hiredis/async.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o hiredis/dict.o hiredis/dict.c
hiredis/dict.c:53:21: warning: ‘dictGenHashFunction’ defined but not used [-Wunused-function]
hiredis/dict.c:73:14: warning: ‘dictCreate’ defined but not used [-Wunused-function]
hiredis/dict.c:160:12: warning: ‘dictReplace’ defined but not used [-Wunused-function]
hiredis/dict.c:182:12: warning: ‘dictDelete’ defined but not used [-Wunused-function]
hiredis/dict.c:238:13: warning: ‘dictRelease’ defined but not used [-Wunused-function]
hiredis/dict.c:258:22: warning: ‘dictGetIterator’ defined but not used [-Wunused-function]
hiredis/dict.c:268:19: warning: ‘dictNext’ defined but not used [-Wunused-function]
hiredis/dict.c:288:13: warning: ‘dictReleaseIterator’ defined but not used [-Wunused-function]
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/dump.o jansson/src/dump.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/error.o jansson/src/error.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/hashtable.o jansson/src/hashtable.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/load.o jansson/src/load.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/strbuffer.o jansson/src/strbuffer.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/utf.o jansson/src/utf.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/value.o jansson/src/value.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o jansson/src/variadic.o jansson/src/variadic.c
cc -c -O3 -Wall -Wextra -I. -Ijansson/src -Ihttp-parser -o http-parser/http_parser.o http-parser/http_parser.c
cc -levent -pthread -o webdis webdis.o cmd.o worker.o slog.o server.o libb64/cencode.o acl.o md5/md5.o http.o client.o websocket.o pool.o conf.o formats/json.o formats/raw.o formats/common.o formats/custom-type.o formats/bson.o hiredis/hiredis.o hiredis/sds.o hiredis/net.o hiredis/async.o hiredis/dict.o jansson/src/dump.o jansson/src/error.o jansson/src/hashtable.o jansson/src/load.o jansson/src/strbuffer.o jansson/src/utf.o jansson/src/value.o jansson/src/variadic.o http-parser/http_parser.o
worker.o: In function `worker_main':
worker.c:(.text+0xd): undefined reference to `event_base_new'
worker.c:(.text+0x29): undefined reference to `event_set'
worker.c:(.text+0x35): undefined reference to `event_base_set'
worker.c:(.text+0x3f): undefined reference to `event_add'
worker.c:(.text+0x6b): undefined reference to `event_base_dispatch'
worker.o: In function `worker_can_read':
worker.c:(.text+0xd2): undefined reference to `event_set'
worker.c:(.text+0xe5): undefined reference to `event_base_set'
worker.o: In function `worker_on_new_client':
worker.c:(.text+0x1f5): undefined reference to `event_set'
worker.c:(.text+0x208): undefined reference to `event_base_set'
worker.c:(.text+0x212): undefined reference to `event_add'
worker.o: In function `worker_monitor_input':
worker.c:(.text+0x2b8): undefined reference to `event_set'
worker.c:(.text+0x2cb): undefined reference to `event_base_set'
worker.o: In function `worker_can_read':
worker.c:(.text+0xf5): undefined reference to `event_add'
worker.o: In function `worker_monitor_input':
worker.c:(.text+0x2e3): undefined reference to `event_add'
server.o: In function `server_start':
server.c:(.text+0x217): undefined reference to `event_reinit'
server.c:(.text+0x338): undefined reference to `event_base_new'
server.c:(.text+0x35a): undefined reference to `event_set'
server.c:(.text+0x369): undefined reference to `event_base_set'
server.c:(.text+0x373): undefined reference to `event_add'
server.c:(.text+0x37f): undefined reference to `event_base_dispatch'
http.o: In function `http_can_write':
http.c:(.text+0x63): undefined reference to `event_set'
http.c:(.text+0x76): undefined reference to `event_base_set'
http.o: In function `http_schedule_write':
http.c:(.text+0x3f1): undefined reference to `event_set'
http.c:(.text+0x404): undefined reference to `event_base_set'
http.o: In function `http_response_write':
http.c:(.text+0x6b1): undefined reference to `event_set'
http.c:(.text+0x6c4): undefined reference to `event_base_set'
http.c:(.text+0x6ce): undefined reference to `event_add'
http.o: In function `http_response_write_chunk':
http.c:(.text+0xc36): undefined reference to `event_set'
http.c:(.text+0xc49): undefined reference to `event_base_set'
http.c:(.text+0xc53): undefined reference to `event_add'
http.o: In function `http_can_write':
http.c:(.text+0x84): undefined reference to `event_add'
http.o: In function `http_schedule_write':
http.c:(.text+0x40f): undefined reference to `event_add'
pool.o: In function `redisLibeventCleanup':
pool.c:(.text+0x89): undefined reference to `event_del'
pool.c:(.text+0x95): undefined reference to `event_del'
pool.o: In function `pool_on_disconnect':
pool.c:(.text+0x179): undefined reference to `event_set'
pool.c:(.text+0x189): undefined reference to `event_base_set'
pool.o: In function `redisLibeventAttach':
pool.c:(.text+0x266): undefined reference to `event_set'
pool.c:(.text+0x281): undefined reference to `event_set'
pool.c:(.text+0x28c): undefined reference to `event_base_set'
pool.c:(.text+0x297): undefined reference to `event_base_set'
pool.o: In function `pool_can_connect':
pool.c:(.text+0x3dd): undefined reference to `event_set'
pool.c:(.text+0x3ed): undefined reference to `event_base_set'
pool.o: In function `pool_connect':
pool.c:(.text+0x595): undefined reference to `event_set'
pool.c:(.text+0x5a5): undefined reference to `event_base_set'
pool.c:(.text+0x5b6): undefined reference to `event_add'
pool.o: In function `redisLibeventAddWrite':
pool.c:(.text+0x6a): undefined reference to `event_add'
pool.o: In function `redisLibeventAddRead':
pool.c:(.text+0x77): undefined reference to `event_add'
pool.o: In function `redisLibeventDelWrite':
pool.c:(.text+0xb8): undefined reference to `event_del'
pool.o: In function `redisLibeventDelRead':
pool.c:(.text+0xc5): undefined reference to `event_del'
pool.o: In function `pool_on_disconnect':
pool.c:(.text+0x19e): undefined reference to `event_add'
pool.o: In function `pool_can_connect':
pool.c:(.text+0x402): undefined reference to `event_add'
collect2: ld returned 1 exit status
make: *** [webdis] Помилка 1

我在/ usr / lib目录中安装了libevent.so和libevent-dev头文件,我还在Makefile的LDFLAGS变量中尝试了-levent2而不是-levent,但仍然没有取得任何进展。什么可以解决我的问题?

谢谢。

1 个答案:

答案 0 :(得分:4)

您需要在链接器命令行中将-levent命令行选项放在目标文件的名称之后。来自-l标志的GCC文档:

-llibrary
-l library
    Search the library named library when linking.  (The second
    alternative with the library as a separate argument is only for
    POSIX compliance and is not recommended.)

    It makes a difference where in the command you write this option;
    the linker searches and processes libraries and object files in the
    order they are specified.  Thus, foo.o -lz bar.o searches library z
    after file foo.o but before bar.o.  If bar.o refers to functions in
    z, those functions may not be loaded.