Creating a library for checking C

I started using the test framework to test application C. For a better understanding, I looked at the example in the validation package. It works fine, but I don't need automake tools - I want to compile it using my own Makefile (since I want to understand the check correctly, and I need to use my final application as an OS package). Perhaps I could use an autogenerated Makefile there, but for now this will be the next new thing that I need to learn, and I have limited time for preparing unit tests. (Then, of course, I want to learn and understand the tools for generating Makfile using configure, etc.)

The problem with creating an application with my Makefile is that I did not bind the object for verification:

/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 the application is 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 generated by the ./configure command, which I do not use.

How can I create my own .o file for verification for a successful build? Need to create this file for each application? Could it be somewhere in shared libraries?

(I apologize if my question is "stupid", I have little experience creating applications on Linux yet)

+4
source share
1 answer

Adding a comment as an answer:
Check if the check platform is installed. If so, you can try using pkg-config say

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

Here the pkg-config utility will read the .pc file (which happens to be check.pc in the case of the check framework, so the last entry in the command says check ) and adds the necessary compiler flags ( --cflags ) and linker libraries / parameters ( --libs )

Hope this helps!

+7
source

Source: https://habr.com/ru/post/1401548/


All Articles