[Nelug] ld and unit testing in C
Oliver Burnett-Hall
olly at burnett-hall.co.uk
Mon Sep 24 23:02:43 UTC 2007
On 24/09/07 13:16, Martin Ward wrote:
> On Monday 24 Sep 2007 12:54, Oliver Burnett-Hall wrote:
>> Now, I was expecting to be able to produce an executable by doing this:
>> # gcc check_ranges.o ../../src/.libs/ranges.o -lcheck -o check_ranges
>>
>> But this tries to find every undefined reference in ranges.o as well,
>> giving me a ton of errors as I haven't included all of the
>> libraries/object files that it requires.
>
> Have you tried the option --unresolved-symbols=ignore-all
> or --unresolved-symbols=ignore-in-object-files ?
I'd missed that one in the ld man page, and it does let me run the
linker successfully. However it just means I now get errors at run time
instead of link time:
# ./check_ranges
~/src/gnumeric/gnumeric/test/unit
./check_ranges: symbol lookup error: ./check_ranges: undefined symbol:
gnm_app_prefs
[gnm_app_prefs is a symbol referenced from ranges.o that I'm really not
interested in]
I really don't understand this stuff at all; the books I've got on C
programming are all platform agnostic so don't tell you much about
compiling and linking, and the docs I've found for gcc are either
trivial or assume that you understand all this already. Can anyone
point me in the direction of something that might help me understand?
Cheers,
- olly
More information about the Nelug
mailing list