BN_generate_prime is a deprecated function, says here. Also, it is defined in crypto/bn_depr.c. You shouldn't use it to generate primes. Instead, you should use BN_generate_prime_ex. Here's the sample usage of BN_generate_prime_ex:
BIGNUM *r;
static const char rnd_seed[] = "string to make the random number generator think it has entropy";
r = BN_new();
RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_generate_prime_ex may fail */
BN_generate_prime_ex(r, 512, 0, NULL, NULL, NULL);
BN_free(r);
Then you'll have a 512-bit pseudo-random prime number. As the above example, you can seed the PRNG by RAND_seed.
For the second question, try BN_num_bits.