Find system package dependency on a gem


Is there anyway to find the C library dependency when installing a gem
containing a native extension?

For now my only solution is to do a ldd on the so file.

By example I know which C lib is needed by nokogiri by doing that:
ldd ./gems/nokogiri-1.5.9/ext/nokogiri/ => (0x00007fff659ff000) => /usr/lib/
(0x00007f86362c1000) => /usr/lib/x86_64-linux-gnu/

Then I can search in by ubuntu repo with apt-cache/apt-file.

I’d need that in order to package my app, the goal being to have a .deb
file with all my app code + all the gems (with or without native
extension) + dependencies in the .deb package for the C libraries
(libxml/libssl/whateevr is needed).
The build of the package will be done on the CI environment (it will run
the bundle install then put the above in the package).
So an apt-get install myapp will deploy my code (with vendor/bundle from
my bundle install) and install the C dependency (libsqlite3-dev by

Thanks for your help!