This paper describes the formulation of optimization techniques based on control theory for aerodynamic shape design in viscous compressible flow, modeled by the Navier-Stokes equations. It extends previous work on optimization for inviscid flow. The theory is applied to a system defined by the partial differential equations of the flow, with the boundary shape acting as the control. The Fréchet derivative of the cost function is determined via the solution of an adjoint partial differential equation, and the boundary shape is then modified in a direction of descent. This process is repeated until an optimum solution is approached. Each design cycle requires the numerical solution of both the flow and the adjoint equations, leading to a computational cost roughly equal to the cost of two flow solutions. The cost is kept low by using multigrid techniques, in conjunction with preconditioning to accelerate the convergence of the solutions. The power of the method is illustrated by designs of wings and wing-body combinations for long range transport aircraft. Satisfactory designs are usually obtained with 20-40 design cycles.