# CUDA Mex files on a Mac with Snow Leopard

**URL:** <https://forums.developer.nvidia.com/t/cuda-mex-files-on-a-mac-with-snow-leopard/16355>\
**Category:** CUDA Programming and Performance\
**Created:** [April 29, 2010, 1:13pm UTC](https://forums.developer.nvidia.com/t/cuda-mex-files-on-a-mac-with-snow-leopard/16355 "2010-04-29T13:13:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Agent.Floyd](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Agent.Floyd](https://forums.developer.nvidia.com/u/Agent.Floyd)\
**Post date:** [April 29, 2010, 1:13pm UTC](https://forums.developer.nvidia.com/t/cuda-mex-files-on-a-mac-with-snow-leopard/16355/1 "2010-04-29T13:13:44Z")

</div>

Hi,

I have a problem compiling CUDA Mex files on a Mac with Snow Leopard. -

When calling the function I get the following error:

“(…) Library not loaded: @rpath/libcudart.dylib (…)”

I found this post here, where the problem seems to be similar. Unfortunately, his solution did not solve my problem.

I am using the same command lines:

```auto
system(sprintf('/usr/local/cuda/bin/nvcc --machine 32 -I"%s/extern/include" --cuda "my_cuda_mex.cu" --output-file "my_cuda_mex.cpp"', matlabroot));

mex -I/usr/local/cuda/include -L/usr/local/cuda/lib -lcudart -lcufft my_cuda_mex.cpp

```

and I also added the " -Xlinker -rpath /usr/local/cuda/lib " at the end of LDFLAGS in the maci section of the _mexopts.sh_ file.

What else can I do?

I am using a MacBook Pro with a CUDA 3.0 installation and MATLAB R2009a (32bit).

Thank you in anticipation!

rgds
