class_docstr: Concrete class that implements an interface to Microsoft Visual C++,
  as defined by the CCompiler abstract class.
class_docstr_tok: ["Concrete","class","that","implements","an","interface","to","Microsoft","Visual","C++",",","as","defined","by","the","CCompiler","abstract","class","."]
code: def link(
      self,
      target_desc,
      objects,
      output_filename,
      output_dir=None,
      libraries=None,
      library_dirs=None,
      runtime_library_dirs=None,
      export_symbols=None,
      debug=0,
      extra_preargs=None,
      extra_postargs=None,
      build_temp=None,
      target_lang=None,
  ):
      if not self.initialized:
          self.initialize()
      (objects, output_dir) = self._fix_object_args(objects, output_dir)
      fixed_args = self._fix_lib_args(
          libraries, library_dirs, runtime_library_dirs
      )
      (libraries, library_dirs, runtime_library_dirs) = fixed_args
  
      if runtime_library_dirs:
          self.warn(
              "I don't know what to do with 'runtime_library_dirs': "
              + str(runtime_library_dirs)
          )
  
      lib_opts = gen_lib_options(
          self, library_dirs, runtime_library_dirs, libraries
      )
      if output_dir is not None:
          output_filename = os.path.join(output_dir, output_filename)
  
      if self._need_link(objects, output_filename):
          if target_desc == CCompiler.EXECUTABLE:
              if debug:
                  ldflags = self.ldflags_shared_debug[1:]
              else:
                  ldflags = self.ldflags_shared[1:]
          else:
              if debug:
                  ldflags = self.ldflags_shared_debug
              else:
                  ldflags = self.ldflags_shared
  
          export_opts = []
          for sym in export_symbols or []:
              export_opts.append("/EXPORT:" + sym)
  
          ld_args = (
              ldflags
              + lib_opts
              + export_opts
              + objects
              + ["/OUT:" + output_filename]
          )
  
          # The MSVC linker generates .lib and .exp files, which cannot be
          # suppressed by any linker switches. The .lib files may even be
          # needed! Make sure they are generated in the temporary build
          # directory. Since they have different names for debug and release
          # builds, they can go into the same directory.
          build_temp = os.path.dirname(objects[0])
          if export_symbols is not None:
              (dll_name, dll_ext) = os.path.splitext(
                  os.path.basename(output_filename)
              )
              implib_file = os.path.join(
                  build_temp, self.library_filename(dll_name)
              )
              ld_args.append("/IMPLIB:" + implib_file)
  
          self.manifest_setup_ldargs(
              output_filename, build_temp, ld_args
          )
  
          if extra_preargs:
              ld_args[:0] = extra_preargs
          if extra_postargs:
              ld_args.extend(extra_postargs)
  
          self.mkpath(os.path.dirname(output_filename))
          try:
              self.spawn([self.linker] + ld_args)
          except DistutilsExecError as msg:
              raise LinkError(msg)
  
          # embed the manifest
          # XXX - this is somewhat fragile - if mt.exe fails, distutils
          # will still consider the DLL up-to-date, but it will not have a
          # manifest.  Maybe we should link to a temp file?  OTOH, that
          # implies a build environment error that shouldn't go undetected.
          mfinfo = self.manifest_get_embed_info(target_desc, ld_args)
          if mfinfo is not None:
              mffilename, mfid = mfinfo
              out_arg = "-outputresource:%s;%s" % (
                  output_filename,
                  mfid,
              )
              try:
                  self.spawn(
                      [
                          "mt.exe",
                          "-nologo",
                          "-manifest",
                          mffilename,
                          out_arg,
                      ]
                  )
              except DistutilsExecError as msg:
                  raise LinkError(msg)
      else:
          log.debug("skipping %s (up-to-date)", output_filename)
  
imports: import os
  import subprocess
  import sys
  import re
  from distutils.errors import DistutilsExecError, DistutilsPlatformError, CompileError, LibError, LinkError
  from distutils.ccompiler import CCompiler, gen_lib_options
  from distutils import log
  from distutils.util import get_platform
  import winreg
label_desc: Use image node_id 6 for calling the MSVCCompiler obj's underlying member method code with example usage: obj.link(target_desc, objects, output_filename, output_dir, libraries, library_dirs, runtime_library_dirs, export_symbols, debug, extra_preargs, extra_postargs, build_temp, target_lang) without return types