在vscode编译时出现cpp: fatal error: too many input files
task.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "catkin_make:debug",
"type": "shell",
"command": "catkin_make",
"args": [],
"group": "build",
"presentation": {
"reveal": "always"
},
"problemMatcher": "$msCompile"
},
{
"type": "cppbuild",
"label": "C/C++: cpp 生成活动文件",
"command": "/usr/bin/cpp",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
/* 项目所需的头文件路径 */
//"-I","${workspaceFolder}/",
"-I","/opt/ros/noetic/include/**",
"-I","/home/lxl/catkin_ws/src/program_control/include/**",
"-I","/usr/include/**",
"-I","/usr/local/include/",
"-I","/usr/local/include/opencv4/",
"-I","/usr/local/include/opencv4/opencv2",
/* 项目所需的库文件路径 */
"-L", "/usr/local/lib",
/* OpenCV的lib库 */
"/usr/local/lib/libopencv_*",
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
}
]
}
可能的原因:
(1)gcc的配置位置发生变化,或者找不到gcc
(2)gcc版本较低
查看gcc是否已经安装,如未安装,则安装gcc。如已安装,把gcc升级到一个较高版本。
gcc tends to report the error message "cpp: too many input files" when it cannot find tools in the places it expects them to be. One cause is if you configured with a --prefix or a --exec-prefix argument with a trailing slash. You must ensure there are no trailing slashes to the arguments to --prefix and --exec-prefix. Another cause is if you have moved your gcc installation from the location you originally specified when it was configured. This location is determined primarily by the --exec-prefix argument to gcc's configure script.
More recent gcc snapshots do not have this limitation, which is specific to gcc 2.95.2 or earlier. To resolve it, you can: use a more recent gcc snapshot; reconfigure gcc with the intended installation location set correctly; or set up symlinks from the old location to the new one.
我把task.json改成了下边 重新编译就成功了...
也不知道怎么弄的 刚开始学 自己也不太熟悉
可能是task:configure task的问题
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "shell",
"command": "/usr/bin/g++",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-I","${workspaceFolder}/",
"-I","/usr/local/include/",
"-I","/usr/local/include/opencv4/",
"-I","/usr/local/include/opencv4/opencv2",
"-I","/opt/ros/noetic/include/**",
"-I","/home/lxl/catkin_ws/src/hello_world_c/include/**",
"-I","/usr/include/**",
/* 项目所需的库文件路径 */
"-L", "/usr/local/lib",
/* OpenCV的lib库 */
"/usr/local/lib/libopencv_*",
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "编译器: /usr/bin/g++"
}
]
}
-I
后面必须是完整相对路径或绝对路径,不能含有*
或**