PCL-1.7.1 with CUDA-6.0 compile problems

I have been trying to compile PCL with CUDA capabilities for my Ubuntu 14.04LTS for quite some time now. I have managed to work around a few problems but I am now stuck at this error:

As soon as the compiling hits the gpu folder, cmake throws a lot of errors at first, I would get this one:

[ 45%] Built target pcl_ground_based_rgbd_people_detector
[ 45%] Built target pcl_gpu_containers
[ 45%] Building NVCC intermediate link file gpu/utils/CMakeFiles/pcl_gpu_utils.dir/./pcl_gpu_utils_intermediate_link.o
nvcc fatal   : nvcc supports '--relocatable-device-code=true (-rdc=true)', '--device-c (-dc)', and '--device-link (-dlink)' only when targeting sm_20 or higher
make[2]: *** [gpu/utils/CMakeFiles/pcl_gpu_utils.dir/./pcl_gpu_utils_intermediate_link.o] Error 255
make[1]: *** [gpu/utils/CMakeFiles/pcl_gpu_utils.dir/all] Error 2
make: *** [all] Error 2

To fix this problem (I don’t know if it solved the root of the issue) I added this to my makefile to tell nvcc to use a specific architecture for my gpu:


Now, that error does not show up but immediately after the intermediate link file is generated another error is thrown. I don’t understand what is going on with this error and it is a complete roadblock for what I am trying to do.

Here is the error:

[ 45%] Built target pcl_gpu_containers
[ 45%] Building NVCC intermediate link file gpu/utils/CMakeFiles/pcl_gpu_utils.dir/./pcl_gpu_utils_intermediate_link.o
Linking CXX shared library ../../lib/libpcl_gpu_utils.so
/usr/bin/ld: CMakeFiles/pcl_gpu_utils.dir/./pcl_gpu_utils_intermediate_link.o: relocation R_X86_64_32S against '__nv_module_id' can not be used when making a shared object; recompile with -fPIC
CMakeFiles/pcl_gpu_utils.dir/./pcl_gpu_utils_intermediate_link.o: error adding symbols: Bad value
collect2: ld returned 1 exit status
make[2]: *** [lib/libpcl_gpu_utils.so.1.7.2] Error 1
make[1]: *** [gpu/utils/CMakeFiles/pcl_gpu_utils.dir/all] Error 2
make: *** [all] Error 2

Any help please?

Thank you in advance.

I don’t know what PCL is, but the error message in your second build seems to be quite clear. In order to build a DSO, you need to compile the source code with -fPIC (this is a gcc compiler flag).

PIC stands for “position-independent code” and as far back as I can recall (ca. 2003) compilation with -fPIC has been either a requirement or at least a highly recommended practice for DSOs on x86 platforms. The following document by Ulrich Drepper (updated by the author every once in a while) covers in detail everything developers on Linux have to know about building DSOs: http://www.akkadia.org/drepper/dsohowto.pdf


You might want to ask your question on a relevant PCL mailing list, there is probably more expertise there on how to build it. Best I can tell, you can sign up for one of the mailing list following the links on this page: http://pointclouds.org/contact.html

Thanks for your reply,

I did look around for where the -fPIC flag was set and I found it in the flags.make file in the directory where this error happens.

Here is the section of the build.make file of interest:

gpu/utils/CMakeFiles/pcl_gpu_utils.dir/./pcl_gpu_utils_intermediate_link.o: gpu/utils/CMakeFiles/pcl_gpu_utils.dir/src/./pcl_gpu_utils_generated_repacks.cu.o
	$(CMAKE_COMMAND) -E cmake_progress_report /home/aaron/Downloads/pcl/build/CMakeFiles $(CMAKE_PROGRESS_2)
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold "Building NVCC intermediate link file gpu/utils/CMakeFiles/pcl_gpu_utils.dir/./pcl_gpu_utils_intermediate_link.o"
	cd /home/aaron/Downloads/pcl/build/gpu/utils && /usr/local/cuda/bin/nvcc -DPCLAPI_EXPORTS -m64 -ccbin "/usr/bin/cc" -dlink  -arch=compute_30 /home/aaron/Downloads/pcl/build/gpu/utils/CMakeFiles/pcl_gpu_utils.dir/src/./pcl_gpu_utils_generated_repacks.cu.o -o /home/aaron/Downloads/pcl/build/gpu/utils/CMakeFiles/pcl_gpu_utils.dir/./pcl_gpu_utils_intermediate_link.o

gpu/utils/CMakeFiles/pcl_gpu_utils.dir/src/repacks.cpp.o: gpu/utils/CMakeFiles/pcl_gpu_utils.dir/flags.make
gpu/utils/CMakeFiles/pcl_gpu_utils.dir/src/repacks.cpp.o: ../gpu/utils/src/repacks.cpp
	$(CMAKE_COMMAND) -E cmake_progress_report /home/aaron/Downloads/pcl/build/CMakeFiles $(CMAKE_PROGRESS_3)
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building CXX object gpu/utils/CMakeFiles/pcl_gpu_utils.dir/src/repacks.cpp.o"
	cd /home/aaron/Downloads/pcl/build/gpu/utils && /usr/bin/c++   $(CXX_DEFINES) $(CXX_FLAGS) -o CMakeFiles/pcl_gpu_utils.dir/src/repacks.cpp.o -c /home/aaron/Downloads/pcl/gpu/utils/src/repacks.cpp

And here is the flags.make file:

# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

# compile CXX with /usr/bin/c++
CXX_FLAGS = -Wall -Wextra -Wno-unknown-pragmas -fno-strict-aliasing -Wno-format-extra-args -Wno-sign-compare  -Wno-conversion  -march=native -msse4.2 -mfpmath=sse -Wabi -pthread -fopenmp -Wno-conversion -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-but-set-variable -O3 -DNDEBUG -fPIC -isystem /usr/include/eigen3 -isystem /usr/include/ni -isystem /usr/include/openni2 -I/home/aaron/Downloads/pcl/recognition/include/pcl/recognition/3rdparty -isystem /usr/include/qt4 -isystem /usr/include/qt4/QtGui -isystem /usr/include/qt4/QtCore -I/home/aaron/Downloads/pcl/build/include -I/home/aaron/Downloads/pcl/common/include -I/home/aaron/Downloads/pcl/gpu/containers/include -I/home/aaron/Downloads/pcl/gpu/utils/include -I/usr/local/cuda/include    -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG


As you can see in the CXX_FLAGS, -fPIC is included. I’m not sure exactly what CXX_FLAGS exactly means.

Is there something else I need to recompile other than PCL? like cuda?

And yes thank you I have just signed up for the pcl mailing list.