compiling/linking gcc/nvcc objects with pgfortran

Dear All,
I have the following problem:
gfortran -c -fcray-pointer -O3 main.for
nvcc -c cppcode.cu
gfortran *.o -lstdc++ -L/usr/local/cuda-6.5/lib64/ -lcudart

My question is how to do it with pgfortran.

Thanks,
Barak

Hi Barak,

It should be the same for pgfortran. Though you could use the -Mcuda flag to link instead of explicitly adding the CUDA libraries.

  • Mat

Hi Mat,
This is the gnu sequence:
gfortran -c -fcray-pointer -O3 main.for
nvcc -c cppcode.cu
gfortran *.o -lstdc++ -L/usr/local/cuda-6.5/lib64/ -lcudart

and what I do with pgfortran:
pgfortran -c -Mcray=pointer -O3 main.for -Mfree
nvcc -c cppcode.cu
pgfortran -Mcuda -o …/load_lib.exe ext_lib.o -lstdc++
and I get:
/usr/bin/ld: ext_lib.o: undefined reference to symbol ‘_Unwind_Resume@@GCC_3.0
//lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line
pgacclnk: child process exit status 1: /usr/bin/ld

Thanks,
Barak

Hi Barak,

I tried to recreate your issue here but my example just worked, so I’m not positive why you’re getting this.

One thought is that there’s a mismatch between the CUDA versions being used. Since it appears your nvcc is 6.5, try using “-Mcuda=cuda6.5”.

Another thing to try is add “-pgc++libs” to the link line. This will bring in the PGI C++ runtime libraries as well as some of the system C++ libraries.

  • Mat

Hi Mat,
Here is now a working combination:
I added in the C++ code the two lines:
#define TRUE 0xff
#define FALSE 0

and the linking is:
pgfortran cppcode.o main.o -pgc++libs -Mcuda=cuda6.0

Thanks a lot!
Barak