Problem Solving Process of The terminal process terminated with exit code 1

参考前辈的配置VScode C/C++环境的经验:

成成赐我力量
bat67

参考之后我的配置

c_cpp_properties.json

    "configurations": [
        {
            "name": "Mac",
            "includePath": ["/usr/include"],
            "browse" : {
                "limitSymbolsToIncludedHeaders" : true,
                "databaseFilename" : ""
            }
        },
        {
            "name": "Linux",
            "includePath": ["/usr/include"],
            "browse" : {
                "limitSymbolsToIncludedHeaders" : true,
                "databaseFilename" : ""
            }
        },
        {
            "name": "Win32",
            "includePath": ["D:/MinGW/include"],
            "browse" : {
                "limitSymbolsToIncludedHeaders" : true,
                "databaseFilename" : ""
            }
        }
    ],
    "version": 4

launch.json

{
            "name": "(gdb) Launch", 
            "type": "cppdbg", 
            "request": "launch",
            "targetArchitecture": "x86",
            "program": "${workspaceRoot}/${fileBacenameNoExtention}.exe", 
            "miDebuggerPath": "D:\\MinGW\\bin\\gdb.exe", // 注意这里要与本机MinGw的路径对应
            "args": [], 
            "stopAtEntry": false, 
            "cwd": "${workspaceRoot}",
            "externalConsole": true, 
            "MIMode": "gdb",
            "preLaunchTask": "gcc",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",  
                    "text": "-enable-pretty-printing",  
                    "ignoreFailures": true
                }
            ]
        }

task.json

{
        "label": "gcc",
        "command": "gcc",
        "args": ["-g","${file}","-o","${fileBacenameNoExTention}.exe"], 
        "problemMatcher": {
          "owner": "c",
          "fileLocation": ["relative", "${workspaceRoot}"],
          "pattern": {
              "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
              "file": 1,
              "line": 2,
              "column": 3,
              "severity": 4,
              "message": 5
          }
        }
      }

出现的问题

d:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1

也看到Stack Overflow上有类似问题

分析问题

因为看不懂报错信息,只能暴力检索。
Keyword:

The terminal process terminated with exit code: 1
or
undefined reference to `WinMain@16’

Result: 有个前辈说他环境变量配置不正确
and
Something probably useful from it

Project -> properties -> build targets -> Type set it to native or gui…
If it doesn’t work (I’m not a windows user anymore) search the forum for sollutions…

I made it working. It was because there was not created main script, so the main function was missing.

解决办法

我检查了一下自己配置的环境变量,的确有问题。

在这里插入图片描述
That 's all and I must be careful next time…

猜你喜欢

转载自blog.csdn.net/qq_31912571/article/details/85222056