To load a private key directly from disk, use the PEM_read_PrivateKey function:
FILE *f;
EVP_PKEY *pkey;
f = fopen("key.pem", "rb");
PEM_read_PrivateKey(
f, /* use the FILE* that was opened */
&pkey, /* pointer to EVP_PKEY structure */
NULL, /* passwor...