Problem Solving Process of The terminal process terminated with exit code 1
阿新 • • 發佈:2018-12-23
參考前輩的配置VScode C/C++環境的經驗:
參考之後我的配置
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 `[email protected]'
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 `[email protected]’
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…