The library search mechanism in dynamic mode searches a given directory for a shared object, and then searches an archive library. Finer control of the type of search required is possible through the -B option.
By specifying the -B dynamic and -B static options on the command line as many times as required, you can toggle the library search between shared objects or archives respectively. For example, to link an application with the archive libfoo.a and the shared object libbar.so, issue the following command:
$ cc -o prog main.o file1.c -Bstatic -lfoo -Bdynamic -lbar
The -B static and -B dynamic keywords are not exactly symmetrical. When you specify -B static, the link-editor does not accept shared objects as input until the next occurrence of -B dynamic. However, when you specify -B dynamic, the link-editor first looks for shared objects and then archive library's in any given directory.
The precise description of the previous example is that the link-editor first searches for libfoo.a, and then for libbar.so, and if that search fails, for libbar.a. Finally, it searches for libc.so, and if that search fails, libc.a.