In the php, how can I have a category of a custom post type display?

It’s for my search page on my site. I would link it but it’s not up and running yet so hopefully, I can explain.

I have custom post types that are then broken out into categories. I want, when searching the site, the results to list what category that type of content is (the content is classified as custom post type “library”).

How do I write this?