FORTRAN example compiling error

I try to compile the fortran example “Fortran_Cuda”, only change the compiler to “gfortran”, and get error as:

nvcc -c -O3 Cuda_function.cu
gfortran -o complex_mul main.f90 Cuda_function.o -L/usr/local/cuda/lib -lcudart
Undefined symbols:
“___gxx_personality_v0”, referenced from:
___gxx_personality_v0$non_lazy_ptr in Cuda_function.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [complex_mul] Error 1

what’s wrong with it?

I’m new to both fortran and cuda, and I’m using a mac. THX

On the mac, add -lstdc++.6