Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building the library for check test C framework

I started to use check framework for testing C application. For better understanding I went across the example in check package. It is working fine, but I don't need the automake tools - I want to compile it by my own Makefile (since I want to understand the check properly and I need to use my final application as a package of an OS). Maybe I could use there the autogenerated Makefile, but for now, it would be next one new thing I have to learn and I have restricted time for preparing unit tests. (Then, of course, I want to study and understand the tools for generating Makfile, using configure, etc.)

There is a problem in building application with my Makefile, that I don't have linked the object for check functionality:

/tmp/ccm7cniy.o: In function `test_money_create':
check_money.c:(.text+0x1e): undefined reference to `tcase_fn_start'
check_money.c:(.text+0x79): undefined reference to `_fail_unless'
check_money.c:(.text+0xcc): undefined reference to `_fail_unless'

I found out, that in the example application is the gcc with obj. file check_money-check_money.o, which was created by gcc:

gcc -DHAVE_CONFIG_H -I. -I..     -g -O2 -MT check_money-check_money.o -MD -MP -MF .deps/check_money-check_money.Tpo -c -o check_money-check_money.o `test -f'check_money.c' || echo './'`check_money.c

And here is my problem: it uses the dependency check_money-check_money.Tpo. This file was generating by the command ./configure, which I don't use.

How can I create my own .o file for check to build successfully? It is necessary to create this file for every application? Could not be one, somewhere in shared libraries?

(I am sorry if my question is "stupid", I have small experience by building applications in linux yet)

like image 895
srnka Avatar asked Mar 15 '12 09:03

srnka


1 Answers

Adding comment as response:
Please check if you have installed check framework. If so, you could try using pkg-config say

gcc check_money.c `pkg-config --cflags --libs check`

Here pkg-config utility will read the .pc file (which happens to be check.pc in case of check framework, thus the last entry in the command says check) & add the necessary compiler flags (--cflags option) & libraries/linker options (--libs option)

Hope this helps!

like image 52
another.anon.coward Avatar answered Sep 29 '22 23:09

another.anon.coward