使用credis API编译用C编写的测试代码时,如何纠正以下错误:
gcc -g -Wall -lcredis test_redis.c -o redisOUT
/tmp/ccetckOb.o: In function `main':
/home/faris/Downloads/credis-0.2.3/test_redis.c:12: undefined reference to `credis_connect'
/home/faris/Downloads/credis-0.2.3/test_redis.c:15: undefined reference to `credis_ping'
/home/faris/Downloads/credis-0.2.3/test_redis.c:18: undefined reference to `credis_set'
/home/faris/Downloads/credis-0.2.3/test_redis.c:21: undefined reference to `credis_get'
/home/faris/Downloads/credis-0.2.3/test_redis.c:25: undefined reference to `credis_close'
collect2: error: ld returned 1 exit status
示例:http://code.google.com/p/credis/wiki/Examples
我长时间不知所措。
感谢您的解决方案。
Sam Iverish
答案 0 :(得分:3)
将库放在引用它的源文件之后:
gcc -g -Wall test_redis.c -lcredis -o redisOUT