CUnit 安装笔记

今天安装 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



搞定!


转载于:https://my.oschina.net/heiing/blog/342804

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值