I also had to figure it out a bit. First you have to compile your C file into an object. In gcc, you run gcc -c hello.c -o hello.o .
Then in the crystal file you will need to link object C. Here is an example:
#hello.cr @[Link(ldflags: "#{__DIR__}/hello.o")] lib Say fun hello(name : LibC::Char*) : Void end Say.hello("your name")
Now you just need to compile your crystal application and it will work. crystal build hello.cr
source share