qtmlr
1
Hi,
i wrote a library (*.cu) from which i’d like to build a dynamic library. I use autotools for that.
In the Makefile.am i added rules:
.cu.o:
$(NVCC) -o $@ -c $< $(NVCCFLAGS)
.cu.lo:
$(LIBTOOL) --tag=CC --mode=compile $(NVCC) -o $@ -c $< $(NVCCFLAGS)
When building a dynamic library there is the problem that $(LIBTOOL) calls CC with the parameter -fPIC, which “nvcc” does not understand.
Can anybody give me a hint on how to proceed from here?
Is there a way to tell libtool to NOT use -fPIC ?
Thanks for any hints,
Torsten.
qtmlr
2
Hi everybody,
i can’t imagine that nobody else had the same problem, is there really no solution available?
Best regards,
Torsten.
mfatica
3
Try this:
- Use nvcc to just compile the object
- keep using gcc to link
I have a project using automake where i use these rules:
NVCC=nvcc
SUFFIXES= .cu
%.o: %.cu %.h
$(NVCC) $(INCLUDES) -Xcompiler “-fPIC -DPIC” -c -o $@ $<
Since I had to pass different flags to my cuda files. I have explicit rules for each one of my cuda files.
ARCH=sm_20
fileA.o: fileA.cu
nvcc --ptxas-options=-v -Xcompiler “-fPIC -DPIC” -arch $(ARCH) -O3 -c fileA.cu
fileB.o: fileB.cu
nvcc --ptxas-options=-v --use_fast_math -arch $(ARCH) -O3 -Xcompiler “-fPIC -DPIC” -c fileB.cu
And remember to add the needed cudart library
libtest_la_LIBADD =
$(OTHER_LIBS) fileA.o fileB.o -L/usr/local/cuda/lib64 -lcudart -lstdc++