Polymer chains in colloid-polymer mixtures can be coarse-grained by replacing them with single soft particles interacting via effective polymer-polymer and polymer-colloid pair potentials. Here we describe in detail how Ornstein-Zernike inversion techniques, originally developed for atomic and molecular fluids, can be generalized to complex fluids and used to derive effective potentials from computer simulations on a microscopic level. In particular, we consider polymer solutions for which we derive effective potentials between the centers of mass, and also between mid-points or end-points from simulations of self-avoiding walk polymers. In addition, we derive effective potentials for polymers near a hard wall or a hard sphere. We emphasize the importance of including both structural and thermodynamic information (through sum-rules) from the underlying simulations. In addition we develop a simple numerical scheme to optimize the parameterization of the density dependent polymer-polymer, polymer-wall and polymer-sphere potentials for dilute and semi-dilute polymer densities, thus opening up the possibility of performing large-scale simulations of colloid-polymer mixtures. The methods developed here should be applicable to a much wider range effective potentials in complex fluids.