码迷,mamicode.com
首页 > 其他好文 > 详细

CUnit 安装笔记

时间:2014-11-10 20:04:20      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:http   io   ar   使用   sp   for   on   问题   cti   

今天安装 CUnit,发现几个坑,在此记一下。

首先下载 CUnit: http://cunit.sourceforge.net/

安装过程:

tar jxvf CUnit-2.1-3.tar.bz2
cd CUnit-2.1-3
./bootstrap
./configure
make
make install



这个时候,CUnit 已经安装好。但在使用的时候可能会有问题,在编译测试用例的时候,可能会出现:

cc -o tests/build-tests tests/httptest.c
/tmp/ccl6l4rB.o: In function `test1‘:
httptest.c:(.text+0x3b): undefined reference to `CU_assertImplementation‘
/tmp/ccl6l4rB.o: In function `test2‘:
httptest.c:(.text+0x66): undefined reference to `CU_assertImplementation‘
/tmp/ccl6l4rB.o: In function `main‘:
httptest.c:(.text+0x7d): undefined reference to `CU_initialize_registry‘
httptest.c:(.text+0x86): undefined reference to `CU_get_error‘
httptest.c:(.text+0x9f): undefined reference to `CU_add_suite‘
httptest.c:(.text+0xaf): undefined reference to `CU_cleanup_registry‘
httptest.c:(.text+0xb4): undefined reference to `CU_get_error‘
httptest.c:(.text+0xcc): undefined reference to `CU_add_test‘
httptest.c:(.text+0xe7): undefined reference to `CU_add_test‘
httptest.c:(.text+0xf1): undefined reference to `CU_cleanup_registry‘
httptest.c:(.text+0xf6): undefined reference to `CU_get_error‘
httptest.c:(.text+0x102): undefined reference to `CU_basic_set_mode‘
httptest.c:(.text+0x107): undefined reference to `CU_basic_run_tests‘
httptest.c:(.text+0x10c): undefined reference to `CU_cleanup_registry‘
httptest.c:(.text+0x111): undefined reference to `CU_get_error‘
collect2: ld returned 1 exit status
make: *** [build-tests] Error 1



在编译的时候加 -lcunit 就可以了,例如我的makefile: 

build-tests : tests/httptest.o
	cc -o tests/build-tests tests/httptest.c -lcunit
tests/httptest.o : tests/httptest.c

test : build-tests
	tests/build-tests



如果在运行测试用例的时候出现:

./build-tests: error while loading shared libraries: libcunit.so.1: cannot open shared ob



提示找不到 libcunit.so.1,给它一个软连接即可:

sudo ln -s /usr/local/lib/libcunit.so.1 libcunit.so.1



搞定!


CUnit 安装笔记

标签:http   io   ar   使用   sp   for   on   问题   cti   

原文地址:http://my.oschina.net/heiing/blog/342804

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!