![](/img/trans.png)
[英]how to Fix "Permission denied collect2.exe: error: ld returned 1 exit status" in Sublime Text 3 on Windows
[英]How to resolve:- "Permission denied collect2.exe: error: ld returned 1 exit status" in VS Code windows
我面臨錯誤:-“---編譯器 bin 文件夾的路徑---:無法打開 output 文件 queue_array.exe:權限被拒絕 collect2.exe:錯誤:ld 返回 1 退出狀態”。
--> 這是VS Code 上的問題我嘗試了其他 IDE,例如“Codes Block” ,相同的編譯器在那里工作正常。
--> 每當我殺死一個終端然后再次編譯程序時,我都會遇到這個問題。
--> 當我更改我工作的文件夾時,代碼編譯了一次,然后在終止終端並再次編譯代碼后,顯示了同樣的錯誤。
-->我懷疑當我終止終端時,它實際上並沒有結束進程,而是仍在后台某處運行。
--> 我已經嘗試過重新安裝編譯器和 Vs Code。 還嘗試編譯不同的程序但在終止終端一次后出現相同的錯誤
---------------------------------------------- ----------------------------------------------
---------------------------------------------- ----------------------------------------------
#include <bits/stdc++.h> 使用命名空間標准;
struct Queue {
int front, rear, capacity;
int* queue;
Queue(int c)
{
front = rear = 0;
capacity = c;
queue = new int;
}
~Queue() { delete[] queue; }
void queueEnqueue(int data)
{
if (capacity == rear) {
printf("\nQueue is full\n");
return;
}
else {
queue[rear] = data;
rear++;
}
return;
}
void queueDequeue()
{
if (front == rear) {
printf("\nQueue is empty\n");
return;
}
else {
for (int i = 0; i < rear - 1; i++) {
queue[i] = queue[i + 1];
}
rear--;
}
return;
}
void queueDisplay()
{
int i;
if (front == rear) {
printf("\nQueue is Empty\n");
return;
}
for (i = front; i < rear; i++) {
printf(" %d <-- ", queue[i]);
}
return;
}
void queueFront()
{
if (front == rear) {
printf("\nQueue is Empty\n");
return;
}
printf("\nFront Element is: %d", queue[front]);
return;
}
};
int 主要(無效){
Queue q(4);
q.queueDisplay();
q.queueEnqueue(20);
q.queueEnqueue(30);
q.queueEnqueue(40);
q.queueEnqueue(50);
q.queueDisplay();
q.queueEnqueue(60);
q.queueDisplay();
q.queueDequeue();
q.queueDequeue();
printf("\n\nafter two node deletion\n\n");
q.queueDisplay();
q.queueFront();
return 0;
}
您的進程仍在執行並加載到 memory,因此 Windows 鎖定它以避免任何可能導致奇怪事情的覆蓋 - 例如如果您嘗試在程序的生命周期內動態地從可執行文件加載資源。 在 Windows 上無法避免此行為。
如果你的程序從它的父程序中分離出來,那么殺死父程序(即終端)不會殺死它,這是完全正常的。 如果啟動該進程,然后連接到終端以獲取其輸出,情況是一樣的——終止終端就像終止子進程一樣,它也不會影響您的程序。 在 Linux 上,如果我沒記錯的話,用&
運行它會執行這樣的分離。 在 Windows 上, start
命令可以做同樣的事情,並且大多數時候,從命令行運行圖形程序也會將執行的進程與控制台分離 - 通常,您會在啟動程序后立即看到提示。
在全球范圍內,你不應該只是殺死一個程序:你應該有一個正確的方法來處理它的退出。 這取決於你做什么,它是圖形界面還是控制台可執行文件,它是否是線程化的,等等。 通常,對於控制台應用程序, Ctrl+C
足以殺死它,但您也可以監視stdin
和/或stdout
並在它們關閉時退出。 還要注意,如果您實現了信號處理程序,它們可能會阻止您的程序正常關閉。
需要更多的程序來充分回復並給出“the”解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.