The Crystal Programming Language Forum

[Solved] How do I test for a successful C library link?

I’m trying my hand at creating a Crystal binding to DRM (“direct rendering manager”). For now I just want to see if I can link to it. I have one Crystal file that says:


I’ve run it through “crystal run” and the “crystal build” binary. I didn’t get any error messages, but I also don’t know if it worked.

Is there some way I can test this?

The only other way I can think of is to use “ldd” if you are on some kind of unix.

ldd should print the shared objects the binary uses.

for example:

 mavu   master … 4  ~  repo  fip-get  ldd fip-get (0x00007fff0fbfb000) => /lib/x86_64-linux-gnu/ (0x00007f7104e6b000) => /lib/x86_64-linux-gnu/ (0x00007f7104dd9000) => /lib/x86_64-linux-gnu/ (0x00007f7104aee000) => /lib/x86_64-linux-gnu/ (0x00007f7104a7a000) => /lib/x86_64-linux-gnu/ (0x00007f7104935000) => /lib/x86_64-linux-gnu/ (0x00007f7104914000) => /lib/x86_64-linux-gnu/ (0x00007f71046bc000) => /lib/x86_64-linux-gnu/ (0x00007f71046b1000) => /lib/x86_64-linux-gnu/ (0x00007f71046ac000) => /lib/x86_64-linux-gnu/ (0x00007f7104692000) => /lib/x86_64-linux-gnu/ (0x00007f71044d2000)
	/lib64/ (0x00007f71051be000)

If you don’t use a function from the library, the library is not linked.

I would test the library by actually using it.


Well. That would explain it then. >.<

Thank you!

Okay. So here’s the actual corrected code:


lib LibPixman
fun pixman_version_string


(I switched over to Pixman because I’m not quite ready for something as low-level as libdrm)

1 Like