Importing and exporting of symbols can be accomplished in two ways, similarly to how it can be done in dynamic executables:
For example, if you want to export a function, red_fish(), and import another function, blue_fish(), you could specify this in a source file as follows:
__declspec(dllexport) long red_fish();__declspec(dllimport) int blue_fish();
So at link time, you might say:
cl6x ... -z --dynamic=lib --export=red_fish --import=blue_fishblue.dll -o red.dll
This informs the linker that the definition of red_fish() will be in the red.dll dynamic library and that we can find and use the definition of blue_fish() in blue.dll.
In general, to build a dynamic library, you must specify --dynamic=lib on the linker command line or in a linker command file. In addition, if any symbols are imported from other dynamic objects, then those dynamic objects must be specified on the linker command line when the dynamic library is built. This is sometimes referred to as static binding.