Ask Your Question

unable to solve "nvcc fatal: A single input file is required for a non-link phase when an outputfile is specified" error

asked 2017-01-02 19:07:56 -0500

vinmean gravatar image

updated 2017-01-02 19:10:22 -0500

I am unable to find if there is any problem with the below build command generated by catkin_make. Similar questions on forums say that there must be some problem with the syntax of the command generated by cmake. Could some one help me find it ?

My system arch is aarch64 (Nvidia TX1) and OS is ubuntu 16.04. The same code builds perfectly on my ubuntu PC.

 -- Generating dependency file: /home/ubuntu/workspace/Jetson/ROS_Workspace/branches/tx1/iruVizhi_v1/build/ros_kinfu/kinfu/pcl_kinfu_large_scale/CMakeFiles/KinfuLargeScaleCUDA.dir/kinfu_large_scale/src/cuda/
Scanning dependencies of target KinfuLargeScaleCPP
/usr/local/cuda-8.0/bin/nvcc -M -D__CUDACC__ /home/ubuntu/workspace/Jetson/ROS_Workspace/branches/tx1/iruVizhi_v1/src/ros_kinfu/kinfu/pcl_kinfu_large_scale/kinfu_large_scale/src/cuda/ -o /home/ubuntu/workspace/Jetson/ROS_Workspace/branches/tx1/iruVizhi_v1/build/ros_kinfu/kinfu/pcl_kinfu_large_scale/CMakeFiles/KinfuLargeScaleCUDA.dir/kinfu_large_scale/src/cuda/ -ccbin /usr/bin/cc -m64 -DROS_BUILD_SHARED_LIBS=1 -DROS_PACKAGE_NAME=\"kinfu\" -DROSCONSOLE_BACKEND_LOG4CXX -DDISABLE_OPENNI2 -DDISABLE_PCAP -DDISABLE_PNG -DvtkFiltersFlowPaths_AUTOINIT=1 ( vtkFiltersParallelFlowPaths ) -DvtkIOExodus_AUTOINIT=1 ( vtkIOParallelExodus ) -DvtkIOGeometry_AUTOINIT=1 ( vtkIOMPIParallel ) -DvtkIOImage_AUTOINIT=1 ( vtkIOMPIImage ) -DvtkIOSQL_AUTOINIT=2 ( vtkIOMySQL,vtkIOPostgreSQL ) -DvtkRenderingContext2D_AUTOINIT=1 ( vtkRenderingContextOpenGL ) -DvtkRenderingCore_AUTOINIT=4 ( vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingFreeTypeOpenGL,vtkRenderingOpenGL ) -DvtkRenderingFreeType_AUTOINIT=2 ( vtkRenderingFreeTypeFontConfig,vtkRenderingMatplotlib ) -DvtkRenderingLIC_AUTOINIT=1 ( vtkRenderingParallelLIC ) -DvtkRenderingVolume_AUTOINIT=1 ( vtkRenderingVolumeOpenGL ) -DDISABLE_OPENNI2 -DKinfuLargeScaleCUDA_EXPORTS -Xcompiler ,\"-fPIC\",\"-g\" -D_FORCE_INLINES -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 --ftz=true --prec-div=false --prec-sqrt=false -DNVCC -I/usr/local/cuda-8.0/include -I/usr/include/vtk-6.2 -I/usr/include -I/usr/include/jsoncpp -I/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent -I/usr/lib/openmpi/include/openmpi/opal/mca/event/libevent2021/libevent/include -I/usr/lib/openmpi/include -I/usr/lib/openmpi/include/openmpi -I/usr/include/freetype2 -I/usr/include/aarch64-linux-gnu/freetype2 -I/usr/include/aarch64-linux-gnu -I/usr/include/hdf5/openmpi -I/usr/include/libxml2 -I/usr/include/python2.7 -I/usr/include/tcl -I/home/ubuntu/workspace/Jetson/ROS_Workspace/branches/tx1/iruVizhi_v1/src/ros_kinfu/kinfu/pcl_kinfu_large_scale/containers/include -I/home/ubuntu/workspace/Jetson/ROS_Workspace/branches/tx1/iruVizhi_v1/src/ros_kinfu/kinfu/pcl_kinfu_large_scale/utils/include -I/home/ubuntu/workspace/Jetson/ROS_Workspace/branches/tx1/iruVizhi_v1/src/ros_kinfu/kinfu/pcl_kinfu_large_scale/kinfu_large_scale/include -I/home/ubuntu/workspace/Jetson/ROS_Workspace/branches/tx1/iruVizhi_v1/src/ros_kinfu/kinfu/pcl_kinfu_large_scale/kinfu_large_scale/src -I/usr/include/pcl-1.7 -I/usr/include/eigen3 -I/usr/include/ni -I/usr/local/cuda-8.0/include
nvcc fatal   : A single input file is required for a non-link phase when an outputfile is specified
CMake Error at (message):
  Error generating

The difference I can make out when comparing the build output from my PC is that the tx1 compile options have some lines with round brackets. Is that a problem?

-DvtkFiltersFlowPaths_AUTOINIT=1 ( vtkFiltersParallelFlowPaths )

May be insignificant, but I also get the below warning on tx1 and not on my pc

  Argument not separated from preceding token by whitespace.
This warning is for project ...
edit retag flag offensive close merge delete


The parentheses and the whitespace around many of the options looks suspicious. You can try copying the whole line into a shell script and running it to verify that it produces the same error (you may need to add quotes around some things)

ahendrix gravatar image ahendrix  ( 2017-01-02 19:42:12 -0500 )edit

Once you have a shell script that reproduces the issue, you can try to modify it in various ways until it works. Once you know how to make this one line work, the challenge is simplified to figuring out how to make cmake do the same thing (which is still not that simple :P )

ahendrix gravatar image ahendrix  ( 2017-01-02 19:43:35 -0500 )edit

Thank you. I removed the parentheses from the command and then it executes without any error. So how do I ensure cmake generates a command without these brackets? I see that only the vtk command options seems to have this problem.

vinmean gravatar image vinmean  ( 2017-01-02 21:16:58 -0500 )edit

I don't know. Perhaps you can read the cmake files for finding Cuda and VTK and see where it gets those options, or do a recursive grep of your filesystem to see which file those options are coming from.

ahendrix gravatar image ahendrix  ( 2017-01-02 23:52:45 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2017-03-07 05:45:05 -0500

trsaunders gravatar image

try adding this to your CMakeLists.txt:

set_directory_properties( PROPERTIES COMPILE_DEFINITIONS "" )

edit flag offensive delete link more


This works perfectly!

Karol Majek gravatar image Karol Majek  ( 2017-10-17 01:07:47 -0500 )edit

To me too! Mark it as the answer :)

Bardo91 gravatar image Bardo91  ( 2018-01-12 05:50:09 -0500 )edit

What kind of sorcery is this?? It worked for me too, care to elaborate, please?

Martin Peris gravatar image Martin Peris  ( 2018-06-11 20:45:40 -0500 )edit

From what I can remember there's something in COMPILE_DEFINITONS that's not being escaped properly. Unfortunately I can't remember how I came to this conclusion

trsaunders gravatar image trsaunders  ( 2018-06-12 07:23:05 -0500 )edit

Works on my side!

Dragon Qu gravatar image Dragon Qu  ( 2019-05-09 22:04:39 -0500 )edit

answered 2018-12-27 12:01:09 -0500

stensootla gravatar image

The parenthesis that you observed in your compilation calls are definitions for function-like macros, and are valid preprocessor directives for the gcc compiler. However, they are not valid for certain CUDA compilers due the latter's inability to handle these redunant spaces between the characters that you observed.

What is likely happening is that your code uses the Point Cloud Library (PCL), with some necessary variables for it loaded into your CMakeLists.txt through the find_package(PCL) command, which runs PCLConfig.cmake. Since PCL depends on VTK (Visualization Toolkit), PCLConfig.cmake runs UseVTK.cmake. The latter file, due to poor design, adds flags into the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS directly (as opposed to adding them to something like VTK_CXX_FLAGS so that the user could use these flags optionally). This has the unintended consequence that the flags are passed to nvcc due to the way FindCUDA.cmake is set up: . Due to the fact that nvcc can't handle function-like macros with spaces around the parenthesis, an error is given.

As a solution, one can clear all the compiler flags (thus getting rid of the redundant function-like macros due to VTK) by using the set_directory_properties( PROPERTIES COMPILE_DEFINITIONS "" ) command in cmake before building cuda with the CUDA_COMPILE cmake macro.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2017-01-02 19:07:56 -0500

Seen: 4,363 times

Last updated: Jan 02 '17