About lib linker(ulibc and glibc)

I have two question about lib linker

1#,how gcc know link /lib/libc.so.6 not /lib/uclibc.so.n

2#,if I just have one gcc on my os, I have the glibc and ulibc.
how to use glibc build one application,and how to use ulibc to build another application

please show me a example .

Thanks

gcc is just the compiler, not the linker. It will, however, run the linker for you (if you don't specify -c on the command line). There are many linker options. Here's the reference: Link Options - Using the GNU Compiler Collection (GCC)

One way to do it is to specify --nostdlib and then specify all the libraries you do want your program linked to.

If you want more control over gcc's default behavior, I suggest you read the following section:
Spec Files - Using the GNU Compiler Collection (GCC)

Basically, gcc is just a wrapper program which uses rules in a spec file to determine which programs to run and how, including the linker. By changing the spec file, you can control gcc's default behavior when running the linker.