Use the LINKLIBS macro to specify the libraries that you need to link against.
Note If you are building a DLL (TARGETTYPE=DYNLINK), and one directory is building a function, and a second directory is building a binary that will export that function, you need to use the LINKLIBS macro to specify the library built from the first directory within the sources file of the second directory. In all other cases, you should use TARGETLIBS.
When you are building a DLL, you could be using objects that you have built in combination with libraries from which you would like to export certain features. Any directory that requires the libraries built in another directory should use the LINKLIBS macro to specify them.
For example, suppose that in directory one you are compiling first.lib. In directory two, you are compiling second.lib. And in directory three, you are building a DLL that must export functions that are defined in the first two libraries. Then, in the sources of directory three, you should include something like the following:
LINKLIBS=$(TARGETPATH)\first.lib \
$(TARGETPATH)\second.lib
This operation must be carefully done. The LINKLIBS macro requires that the library must be located in pass one of the build, because the Build utility builds the import libraries during pass one. You must structure your build in such a manner that the libraries are guaranteed to exist during pass one. You should never specify an import library in your LINKLIBS macro, primarily because you could end up exporting something that you imported from somebody else instead of what you actually had (perhaps with syntax errors or other problems). Problems resulting from such a mishap can be undetectable for some time.
As a result, it is almost always better to use TARGETLIBS. Use LINKLIBS only for cases that meet the following conditions: