0

I am working with CUnit and learning test driven development.

Please can someone help me out with the compilation part.

my command in terminal is:

gcc -main.c -o main

this is obviously not correct as i get the following output :

FOR EVERY FUNCTION

main.c:(.text+0x1ee): undefined reference to CU_initialize_registry' main.c:(.text+0x1f7): undefined reference toCU_get_error' main.c:(.text+0x210): undefined reference to CU_add_suite' main.c:(.text+0x22a): undefined reference toCU_add_test' main.c:(.text+0x240): undefined reference to CU_add_test' main.c:(.text+0x256): undefined reference toCU_add_test' main.c:(.text+0x260): undefined reference to CU_set_output_filename' main.c:(.text+0x265): undefined reference toCU_automated_run_tests' main.c:(.text+0x26a): undefined reference to CU_cleanup_registry' main.c:(.text+0x26f): undefined reference toCU_get_error' collect2: ld returned 1 exit status

I need to know how to link the libcunit.a with the gcc .

I have tried gcc -o main main.c -L/usr/local/lib -Wl,-Bstatic -lcunit -Wl,-Bdynamic

It does comile and when i run ./main it sort of uses 100% cpu (continously) and there are no results !!!!
I have to exit the process using ctrl + c .

satej k
  • 89
  • 2
  • 13
  • 2
    If it runs endlessly, you will need to show your code. The problem is some logical error in your code. – 0xF1 Sep 22 '14 at 10:38
  • so is the compiling command correct ?? – satej k Sep 22 '14 at 11:13
  • If it is compiled and linked successfully the command must be correct, unless you link to wrong version of library which again is a logical error. – 0xF1 Sep 22 '14 at 11:16
  • ok... thanks !! i dont have permission to post the code . other wise you could have helped me much more...:) – satej k Sep 22 '14 at 11:19
  • 1
    hey...i found why the code ran endlessly...the function was doing a large computation ! so i reduced the value to a manageble level and it worked !! – satej k Sep 22 '14 at 14:47

0 Answers0