A problem faced when I try to compile a mix code in linux

Hi all,

I have a code developed under win10 and it works well. There is a fortran-calling-c in it. The cuda c file is simple:

exts.cu:
#include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <thrust/sort.h>

extern “C”
{
void thr_SbyK( int *KEY, int N, int *ARRAY)
{
thrust::device_ptr dev_ptr1(KEY);
thrust::device_ptr dev_ptr2(ARRAY);
thrust::sort_by_key(dev_ptr1, dev_ptr1+N, dev_ptr2);
}
}

The relative code in makefile is:

CUDAFLAGS = -Mcuda=cc60
INCCO=“C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt”
INCCU=“C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include”

nvcc -I$(INCCO) -I$(INCCU) -arch sm_61 -c exts.cu

Today I try to compile it in linux system. I changed its relative code in makefile as:

CUDAFLAGS = -Mcuda=cc60
INCCU="/opt/cuda-9.0/lib64"
nvcc -I$(INCCU) -arch sm_61 -c -lstdc++ exts.cu

It turns out that this file exts.cu is compiled succesfully, but when I try to link them with:
pgfortran $(CUDAFLAGS) $(F90FLAGS) -o sphcf.$(EXE) sphmod.$(OBJ) kersph.$(OBJ) initsph.$(OBJ) divide.$(OBJ) exts.$(OBJ) singlestep.$(OBJ) output.$(OBJ) main.$(OBJ) $<

it shows an error as:

/usr/bin/ld: exts.o: undefined reference to symbol ‘_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEaSEPKc@@GLIBCXX_3.4.21
//usr/lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line

How can I solve this?

Thanks a lot!

Hi Lazycatyi,

This looks like a mismatch between the version of GNU that CUDA 9.0 supports and the version you have installed on your system?

CUDA 9.0 supported up to GNU 6.0. What version do you have installed on your system?

If it is newer than GNU 6.0, you’ll need to update your CUDA version to one that supports your GNU version, or downgrade GNU.

Hope this helps,
Mat