[Nelug] ld and unit testing in C

Martin Ward martin at gkc.org.uk
Mon Sep 24 12:17:19 UTC 2007


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 ?

This is what the man page to ld says:

       --unresolved-symbols=method
           Determine  how to handle unresolved symbols.  There are four possi-
           ble values for method:

           ignore-all
               Do not report any unresolved symbols.

           report-all
               Report all unresolved symbols.  This is the default.

           ignore-in-object-files
               Report  unresolved  symbols  that  are  contained   in   shared
               libraries,  but  ignore  them  if they come from regular object
               files.

           ignore-in-shared-libs
               Report unresolved symbols that come from regular object  files,
               but  ignore  them if they come from shared libraries.  This can
               be useful when creating a dynamic binary and it is  known  that
               all  the  shared  libraries  that  it should be referencing are
               included on the linker's command line.

           The behaviour for shared libraries on their own can  also  be  con-
           trolled by the --[no-]allow-shlib-undefined option.

           Normally  the  linker  will  generate  an  error  message  for each
           reported unresolved symbol but the option --warn-unresolved-symbols
           can change this to a warning.



-- 
			Martin

martin at gkc.org.uk http://www.cse.dmu.ac.uk/~mward/ Erdos number: 4
G.K.Chesterton web site: http://www.cse.dmu.ac.uk/~mward/gkc/




More information about the Nelug mailing list