We investigate relationships between the determ inistic infinite time horizon optimal control problem with discounting, in which the state trajectories remain in a given compact set Y, and a certain infinite dimensional linear programming (IDLP) problem. We introduce the problem dual with respect to this IDLP problem and obtain some duality results. We construct necessary and sufficient optimality conditions for the optimal control problem under consideration, and we give a characterization of the viability kernel of Y. We also indicate how one can use finite dimensional approximations of the IDLP problem and its dual for construction of near optimal feedback controls. The construction is illustrated with a numerical example.