CUDA math library cannot be found error

While trying to compile my code, I got the following error:

clang -fopenmp -omptargets=nvptx64sm_35-nvidia-linux -g -O3 -std=c99 Source.c -o source -L /home/rjordans/openmp4/lib -lm

clang-3.8: error: CUDA math library (libdevice) is required and cannot be found.

How can I solve this error?

It looks like you are trying to use the compiler in github - The current upstreamed version of clang does not have support in the driver for offloading yet. If you have questions about the github version is better if you post them there.

About your error, you are probably missing LIBRARY_PATH pointing to where libdevice is, usually something like /usr/local/cuda/nvvm/lib. Try ‘export LIBRARY_PATH=/usr/local/cuda/nvvm/lib’ prior to running the compiler.


Let me correct myself, you should use something like /usr/local/cuda/nvvm/libdevice (not /usr/local/cuda/nvvm/lib as I stated in my previous email).