  We study the Bishop-Phelps-Bollob\'as property (BPBp for short) for compact
operators. We present some abstract techniques which allows to carry the BPBp
for compact operators from sequence spaces to function spaces. As main
applications, we prove the following results. Let $X$, $Y$ be Banach spaces. If
$(c_0,Y)$ has the BPBp for compact operators, then so do $(C_0(L),Y)$ for every
locally compact Hausdorff topological space $L$ and $(X,Y)$ whenever $X^*$ is
isometrically isomorphic to $\ell_1$. If $X^*$ has the Radon-Nikod\'ym property
and $(\ell_1(X),Y)$ has the BPBp for compact operators, then so does
$(L_1(\mu,X),Y)$ for every positive measure $\mu$; as a consequence,
$(L_1(\mu,X),Y)$ has the the BPBp for compact operators when $X$ and $Y$ are
finite-dimensional or $Y$ is a Hilbert space and $X=c_0$ or $X=L_p(\nu)$ for
any positive measure $\nu$ and $1< p< \infty$. For $1\leqslant p <\infty$, if
$(X,\ell_p(Y))$ has the BPBp for compact operators, then so does
$(X,L_p(\mu,Y))$ for every positive measure $\mu$ such that $L_1(\mu)$ is
infinite-dimensional. If $(X,Y)$ has the BPBp for compact operators, then so do
$(X,L_\infty(\mu,Y))$ for every $\sigma$-finite positive measure $\mu$ and
$(X,C(K,Y))$ for every compact Hausdorff topological space $K$.
