2

I was trying to run a simple OpenCL test program for a course assignment. But I got an error when running make.

The error is:

ld: library not found for -lrt

I checked the Makefile, and found the related line was:

cl-demo: cl-demo.c cl-helper.c
gcc $(CL_CFLAGS) $(CL_LDFLAGS) -std=gnu99 -o$@ $^ -lrt -lOpenCL -v

While my fellow classmates using Ubuntu 16.04 managed to run this test program just fine, I am using macOS High Sierra. The TAs nor the professor cannot figure it out (unfortunately, they only have experience of OpenCL on Ubuntu).

It feels like that the missing library rt seems be a library from some common package, but I don't know which package it comes from. Is it exclusive to Ubuntu or Linux? Does anybody knows where it comes from? Thanks!

Jonas Schäfer
  • 20,140
  • 5
  • 55
  • 69
jackxujh
  • 983
  • 10
  • 31
  • 4
    Did you try just removing `-lrt`? It is part of the standard C library, other platforms may have those functions somewhere linked by defaut. – Marc Glisse Apr 04 '18 at 16:55
  • 2
    https://stackoverflow.com/questions/1505402/library-not-found-for-lrt-with-qtcreator-mac-os might help – Hatted Rooster Apr 04 '18 at 16:55
  • Note that even on Ubuntu 16.04, it'd work with `-lrt` if you're using glibc because it's [no longer a separate library](https://stackoverflow.com/a/32649327/1275169). Since you are MacOS, you can just remove it and compile - if it compiles then you don't need it at all! – P.P Apr 04 '18 at 16:59
  • Thanks for pointing out that! – jackxujh Apr 04 '18 at 17:11
  • I just found that I have a new issue regarding to the `-lOpenCL` option... Which also says not found... – jackxujh Apr 04 '18 at 17:11

0 Answers0