I installed the CUnit 2.1-0. I ran the example from
the CUnit example page that test the fprintf and fread.
When I compile it using the following Makefile, I get
many errors. Please take a look below and let me know
what am missing. The online example is also attach to
this post.
Makefile:
rule = -pedantic -Wall -ansi -O2
OnlineExample: clean OnlineExample.o
gcc $(rule) -o OE OnlineExample.o
OnlineExample.o: OnlineExample.c
gcc -c OnlineExample.c
clean:
rm -f core. .o
I get these errors when I compile:
[phuchdao@HoangHao LATA]$ make OnlineExample
rm -f core. .o
gcc -c OnlineExample.c
gcc -pedantic -Wall -ansi -O2 -o OE OnlineExample.o
OnlineExample.o(.text+0xca): In function testFPRINTF':
: undefined reference to
CU_assertImplementation'
OnlineExample.o(.text+0x10a): In function testFPRINTF':
: undefined reference to
CU_assertImplementation'
OnlineExample.o(.text+0x14d): In function testFPRINTF':
: undefined reference to
CU_assertImplementation'
OnlineExample.o(.text+0x1b6): In function testFREAD':
: undefined reference to
CU_assertImplementation'
OnlineExample.o(.text+0x1f5): In function testFREAD':
: undefined reference to
CU_assertImplementation'
OnlineExample.o(.text+0x222): In function main':
: undefined reference to
CU_initialize_registry'
OnlineExample.o(.text+0x22b): In function main':
: undefined reference to
CU_get_error'
OnlineExample.o(.text+0x24a): In function main':
: undefined reference to
CU_add_suite'
OnlineExample.o(.text+0x25b): In function main':
: undefined reference to
CU_cleanup_registry'
OnlineExample.o(.text+0x260): In function main':
: undefined reference to
CU_get_error'
OnlineExample.o(.text+0x27a): In function main':
: undefined reference to
CU_add_test'
OnlineExample.o(.text+0x296): In function main':
: undefined reference to
CU_add_test'
OnlineExample.o(.text+0x2a2): In function main':
: undefined reference to
CU_cleanup_registry'
OnlineExample.o(.text+0x2a7): In function main':
: undefined reference to
CU_get_error'
OnlineExample.o(.text+0x2b6): In function main':
: undefined reference to
CU_basic_set_mode'
OnlineExample.o(.text+0x2be): In function main':
: undefined reference to
CU_basic_run_tests'
OnlineExample.o(.text+0x2c3): In function main':
: undefined reference to
CU_cleanup_registry'
OnlineExample.o(.text+0x2c8): In function main':
: undefined reference to
CU_get_error'
collect2: ld returned 1 exit status
make: *** [OnlineExample] Error 1
Please let me know what is going on.
Anonymous
Online Example
Logged In: NO
-lcunit should be added.
Logged In: YES
user_id=1530227
Thank you nobody for helping with my problem. After
spending time reading about the -L option in gcc, I
managed to get the library CUnit to link to the program.
I'm not sure if there's a reply button on this page or
not, but I haven't see one. That's why I'm replying you
through this comment box.
Logged In: NO
You are not linking against the library. you have to have a library named libcunit.lib
and include it during linking.