Error id returned 1 exit status что это

ошибка Id returned 1 exit status что может значить? C++ Решение и ответ на вопрос 784138

да! я уже как раз это поняла ))
только теперь не знаю куда ее вставить..

вот программа
может будет непонятно потому что она чуток на другом языке)) но факт в том что первой должна выполняться команда там где menu.. как теперь туда вставить main?

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
struct student {
    char am[7]; /*AM tou foithth */
    float final_grade; /*telikos bathmos*/
    float exam_grade; /*bathmos ths eksetashs*/
    float essay_grade; /*bathmos ths ergasias*/
} pupil[100];
 
struct exam_question {
    char erwtisi[100]; /*erwtiseis*/
    char apantisi1[50]; /*pithanh apanthsh 1*/
    char apantisi2 [50]; /*pithanh apanthsh 2*/
    char apantisi3 [50]; /*pithanh apanthsh 3*/
    int swsti_apantisi; /*arithmos swsths apanthshs*/
} erwtiseis[3];
 
int current = 0; /*o arithmos twn foithtwn pou eisagontai sto susthma*/
 
void pinakas_erwthsewn(void) { /*erwtiseis*/
    strcpy(erwtiseis[0].apantisi1, "Xerox");
    strcpy(erwtiseis[0].apantisi2, "Apple");
    strcpy(erwtiseis[0].apantisi3, "IBM");
    strcpy(erwtiseis[0].erwtisi, "Apo poia etairia anaptithhke h glwssa FORTRAN?"); /*erwtisi 1*/
    erwtiseis[0].swsti_apantisi = 3;
 
    strcpy(erwtiseis[1].apantisi1, "Pascal");
    strcpy(erwtiseis[1].apantisi2, "Cobol");
    strcpy(erwtiseis[1].apantisi3, "SQL");
    strcpy(erwtiseis[1].erwtisi, "Poia apo tis parakatw glwsses einai h glwssa polu upsilou epipedou?"); /*erwtisi 2*/
    erwtiseis[1].swsti_apantisi = 3;
 
    strcpy(erwtiseis[2].apantisi1, "ROM");
    strcpy(erwtiseis[2].apantisi2, "CD");
    strcpy(erwtiseis[2].apantisi3, "DRAM");
    strcpy(erwtiseis[2].erwtisi, "Poia apo tis parakatw mnhmes einai astathhs?"); /*erwtisi 3*/
    erwtiseis[2].swsti_apantisi = 3;
 
    strcpy(erwtiseis[3].apantisi1, "2^(n+1)");
    strcpy(erwtiseis[3].apantisi2, "2^n");
    strcpy(erwtiseis[3].apantisi3, "2^(n-1)");
    strcpy(erwtiseis[3].erwtisi, "Posous pithanous sunduasmous timwv eisodou mporei na exei mia sunarthsh Boole me n metablites?"); /*erwtisi 4*/
    erwtiseis[3].swsti_apantisi = 2;
 
}
 
int checkAM(char *amToCheck) /*na elegxoume an AM hdh uparxei sto susthma h oxi*/ {
    int check1 = 0; /*ean o AM den uparxei*/
    for (int i = 0; i < current; i++) {
        if (strcmp(amToCheck, pupil[i].am) == 0) {
            check1 = -1; /*ean o AM hdh uparxei*/
            break;
        }
 
    }
    return check1;
}
 
void Eksetash(void) {
    int erwt1 = rand() % 4; /*gia na emfanizontai tuxaia oi erwtiseis*/
    int erwt2, erwt3, erwt4;
    do {
        erwt2 = rand() % 4;
    } while (erwt1 == erwt2);
    
    do {
        erwt3 = rand() % 4;
    } while (erwt1 == erwt3 || erwt2 == erwt3);
    
    do {
        erwt4 = rand() % 4;
    } while (erwt1 == erwt4 || erwt2 == erwt4 || erwt3 == erwt4);
 
 
    printf("Grapste ton AM sasn");
    char AM [7];
    scanf("%s", &AM);
    int found = checkAM(AM);
    if (found == -1) {
        printf("Exete hdh extastei. Exit");
    } else {
        strcpy(pupil[current].am,AM);
 
        do {
            printf("Grapste ton bathmo ergasias sasn");
            scanf("%f", &pupil[current].essay_grade);
        } while (pupil[current].essay_grade < 0 || pupil[current].essay_grade > 10);
 
        current++;
 
    }
  
        int apantisi = 0;
        int count = 0;
        printf("%sn", erwtiseis[erwt1].erwtisi);
        printf("1.%sn", erwtiseis[erwt1].apantisi1);
        printf("2.%sn", erwtiseis[erwt1].apantisi2);
        printf("3.%sn", erwtiseis[erwt1].apantisi3);
 
        scanf("%d", &apantisi);
        if (apantisi == erwtiseis [erwt1].swsti_apantisi) {
            count++;
 
        }
        printf("%sn", erwtiseis[erwt2].erwtisi);
        printf("1.%sn", erwtiseis[erwt2].apantisi1);
        printf("2.%sn", erwtiseis[erwt2].apantisi2);
        printf("3.%sn", erwtiseis[erwt2].apantisi3);
        scanf("%d", &apantisi);
        if (apantisi == erwtiseis[erwt2]. swsti_apantisi) {
            count++;
 
        }
        printf("%sn", erwtiseis[erwt3]. erwtisi);
        printf("1.%sn", erwtiseis[erwt3].apantisi1);
        printf("2.%sn", erwtiseis[erwt3].apantisi2);
        printf("3.%sn", erwtiseis[erwt3].apantisi3);
        scanf("%d", &apantisi);
        if (apantisi == erwtiseis[erwt3]. swsti_apantisi) {
            count++;
 
        }
 
        printf("%sn", erwtiseis[erwt4]. erwtisi);
        printf("1.%sn", erwtiseis[erwt4].apantisi1);
        printf("2.%sn", erwtiseis[erwt4].apantisi2);
        printf("3.%sn", erwtiseis[erwt4].apantisi3);
        scanf("%d", &apantisi);
        if (apantisi == erwtiseis[erwt4]. swsti_apantisi) {
            count++;
 
        }
        pupil[found].exam_grade = count * 2, 5; /*metrhsh bathmou eksetashs*/
        pupil[found].final_grade = 0.75 * pupil[found].exam_grade + 0.25 * pupil[found].essay_grade; /*metrhsh telikou bathmou*/
     
}
 
void Anazhthsh_kai_ektupwsh_bathmou() {
    printf("Grapste AM tou foithth: n ");
    char AM [7];
    scanf("%s", &AM);
    for (int i = 0; i < current; i++) {
 
        if (strcmp(AM, pupil[i].am) == 0) {
            printf("AM:%snn", pupil[i].am);
            printf("Essay grade:%fn", pupil[i].essay_grade);
            printf("Exam grade:%fn", pupil[i].exam_grade);
            printf("Final Grade:%fnn", pupil[i].final_grade);
            break;
        }
    }
}
 
void Ektupwsh_telikhs_listas_bathmologias(void) {
    for (int counter = 0; counter < current; counter++) {
        printf("AM:%snn", pupil[counter].am);
        printf("Essay grade:%fn", pupil[counter].essay_grade);
        printf("Exam grade:%fn", pupil[counter].exam_grade);
        printf("Final Grade:%fnn", pupil[counter].final_grade);
    }
    printf("nn");
}
 
void Statistika_stoixeia(void) {
    int arithmos_epituxontwn = 0;
    for (int counter = 0; counter < current; counter++) {
        if (pupil[counter].final_grade >= 5) {
            arithmos_epituxontwn++;
        }
    }
    float pososto_epituxontwn = (arithmos_epituxontwn / current)*100;
    printf("O arithmos twn epituxontwn einai %dn", arithmos_epituxontwn);
    printf("To pososto twn epituxontwn einai %fnn %", pososto_epituxontwn);
}
 
int menu(void) {
    printf("nnt1:Eksetash");
    printf("ntt2:Anazhthsh kai ektupwsh bathmou");
    printf("ntt3:Ektupwsh telikhs listas bathmologias");
    printf("ntt4:Statistika stoixeia");
    printf("ntt5:Eksodosn");
    int c = 0;
    scanf("%d", &c);
    do {
        
        c = menu();
        if (c > 0 || c < 5) {
            switch (c) {
                case 1:
                    Eksetash();
                    break;
 
                case 2:
                    Anazhthsh_kai_ektupwsh_bathmou();
                    break;
 
                case 3:
                    Ektupwsh_telikhs_listas_bathmologias();
                    break;
 
                case 4:
                    Statistika_stoixeia();
                    break;
            }
        } 
        }while(c!=5);
        
 
      return c;
    
}

Добавлено через 2 минуты
вот я поставила main вместо menu, но теперь программа работает неправильно, потому что не возвращает пользователя в меню после выбора пункта

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
struct student
 {
    char am[7]; /*AM tou foithth */
    float final_grade; /*telikos bathmos*/
    float exam_grade; /*bathmos ths eksetashs*/
    float essay_grade; /*bathmos ths ergasias*/
 } 
    pupil[100];
 
struct exam_question 
 {
    char erwtisi[100]; /*erwtiseis*/
    char apantisi1[50]; /*pithanh apanthsh 1*/
    char apantisi2 [50]; /*pithanh apanthsh 2*/
    char apantisi3 [50]; /*pithanh apanthsh 3*/
    int swsti_apantisi; /*arithmos swsths apanthshs*/
 } 
    erwtiseis[4];
 
int current = 0; /*o arithmos twn foithtwn pou eisagontai sto susthma*/
 
void pinakas_erwthsewn(void) 
 { /*erwtiseis*/
    strcpy(erwtiseis[0].apantisi1, "Xerox");
    strcpy(erwtiseis[0].apantisi2, "Apple");
    strcpy(erwtiseis[0].apantisi3, "IBM");
    strcpy(erwtiseis[0].erwtisi, "Apo poia etairia anaptithhke h glwssa FORTRAN?"); /*erwtisi 1*/
    erwtiseis[0].swsti_apantisi = 3;
 
    strcpy(erwtiseis[1].apantisi1, "Pascal");
    strcpy(erwtiseis[1].apantisi2, "Cobol");
    strcpy(erwtiseis[1].apantisi3, "SQL");
    strcpy(erwtiseis[1].erwtisi, "Poia apo tis parakatw glwsses einai h glwssa polu upsilou epipedou?"); /*erwtisi 2*/
    erwtiseis[1].swsti_apantisi = 3;
 
    strcpy(erwtiseis[2].apantisi1, "ROM");
    strcpy(erwtiseis[2].apantisi2, "CD");
    strcpy(erwtiseis[2].apantisi3, "DRAM");
    strcpy(erwtiseis[2].erwtisi, "Poia apo tis parakatw mnhmes einai astathhs?"); /*erwtisi 3*/
    erwtiseis[2].swsti_apantisi = 3;
 
    strcpy(erwtiseis[3].apantisi1, "2^(n+1)");
    strcpy(erwtiseis[3].apantisi2, "2^n");
    strcpy(erwtiseis[3].apantisi3, "2^(n-1)");
    strcpy(erwtiseis[3].erwtisi, "Posous pithanous sunduasmous timwv eisodou mporei na exei mia sunarthsh Boole me n metablites?"); /*erwtisi 4*/
    erwtiseis[3].swsti_apantisi = 2;
 
 }
 
int checkAM(char *amToCheck) /*na elegxoume an AM hdh uparxei sto susthma h oxi*/ 
 {
    int check1 = 0; /*ean o AM den uparxei*/
    for (int i = 0; i < current; i++) 
    {
        if (strcmp(amToCheck, pupil[i].am) == 0) 
        {
            check1 = -1; /*ean o AM hdh uparxei*/
            break;
        }
    }
    
    return check1;
 }
 
void Eksetash(void) 
 {
    int erwt1 = rand() % 4; /*gia na emfanizontai tuxaia oi erwtiseis*/
    int erwt2, erwt3, erwt4;
    do 
    {
        erwt2 = rand() % 4;
    }
    
    while (erwt1 == erwt2);
    do 
    {
        erwt3 = rand() % 4;
    } 
    
    while (erwt1 == erwt3 || erwt2 == erwt3);
    do 
    {
        erwt4 = rand() % 4;
    }
    
    while (erwt1 == erwt4 || erwt2 == erwt4 || erwt3 == erwt4);
 
    printf("Grapste ton AM sasn");
    char AM [7];
    scanf("%s", &AM);
    int found = checkAM(AM);
    if (found == -1) 
    {
        printf("Exete hdh extastei. Exit");
    } 
    else 
    {
        strcpy(pupil[current].am,AM);
 
        do 
        {
            printf("Grapste ton bathmo ergasias sasn");
            scanf("%f", &pupil[current].essay_grade);
        }
        while (pupil[current].essay_grade < 0 || pupil[current].essay_grade > 10);
 
        current++;
 
     }
  
        int apantisi = 0;
        int count = 0;
        printf("%sn", erwtiseis[erwt1].erwtisi);
        printf("1.%sn", erwtiseis[erwt1].apantisi1);
        printf("2.%sn", erwtiseis[erwt1].apantisi2);
        printf("3.%sn", erwtiseis[erwt1].apantisi3);
 
        scanf("%d", &apantisi);
        
        if (apantisi == erwtiseis [erwt1].swsti_apantisi) 
        {
            count++;
        }
        
        printf("%sn", erwtiseis[erwt2].erwtisi);
        printf("1.%sn", erwtiseis[erwt2].apantisi1);
        printf("2.%sn", erwtiseis[erwt2].apantisi2);
        printf("3.%sn", erwtiseis[erwt2].apantisi3);
        
        scanf("%d", &apantisi);
        
        if (apantisi == erwtiseis[erwt2]. swsti_apantisi) 
        {
            count++;
        }
        
        printf("%sn", erwtiseis[erwt3]. erwtisi);
        printf("1.%sn", erwtiseis[erwt3].apantisi1);
        printf("2.%sn", erwtiseis[erwt3].apantisi2);
        printf("3.%sn", erwtiseis[erwt3].apantisi3);
        
        scanf("%d", &apantisi);
        
        if (apantisi == erwtiseis[erwt3]. swsti_apantisi) 
        {
            count++;
        }
 
        printf("%sn", erwtiseis[erwt4]. erwtisi);
        printf("1.%sn", erwtiseis[erwt4].apantisi1);
        printf("2.%sn", erwtiseis[erwt4].apantisi2);
        printf("3.%sn", erwtiseis[erwt4].apantisi3);
        
        scanf("%d", &apantisi);
        
        if (apantisi == erwtiseis[erwt4]. swsti_apantisi) 
        {
            count++;
        }
        
        pupil[found].exam_grade = count * 2, 5; /*metrhsh bathmou eksetashs*/
        pupil[found].final_grade = 0.75 * pupil[found].exam_grade + 0.25 * pupil[found].essay_grade; /*metrhsh telikou bathmou*/
     
 }
 
void Anazhthsh_kai_ektupwsh_bathmou() 
 {
    printf("Grapste AM tou foithth: n ");
    char AM [7];
    scanf("%s", &AM);
    for (int i = 0; i < current; i++) 
      {
         if (strcmp(AM, pupil[i].am) == 0) 
           {
             printf("AM:%snn", pupil[i].am);
             printf("Essay grade:%fn", pupil[i].essay_grade);
             printf("Exam grade:%fn", pupil[i].exam_grade);
             printf("Final Grade:%fnn", pupil[i].final_grade);
             break;
           }
      }
 }
 
void Ektupwsh_telikhs_listas_bathmologias(void) 
 {
    for (int counter = 0; counter < current; counter++) 
      {
         printf("AM:%snn", pupil[counter].am);
         printf("Essay grade:%fn", pupil[counter].essay_grade);
         printf("Exam grade:%fn", pupil[counter].exam_grade);
         printf("Final Grade:%fnn", pupil[counter].final_grade);
      }
    printf("nn");
 }
 
void Statistika_stoixeia(void) 
 {
    int arithmos_epituxontwn = 0;
    for (int counter = 0; counter < current; counter++) 
      {
         if (pupil[counter].final_grade >= 5) 
           {
             arithmos_epituxontwn++;
           }
      }
      
    float pososto_epituxontwn = (arithmos_epituxontwn / current)*100;
    printf("O arithmos twn epituxontwn einai %dn", arithmos_epituxontwn);
    printf("To pososto twn epituxontwn einai %fnn %", pososto_epituxontwn);
 }
int main (void)
 
 {
    printf("nnt1:Eksetash");
    printf("ntt2:Anazhthsh kai ektupwsh bathmou");
    printf("ntt3:Ektupwsh telikhs listas bathmologias");
    printf("ntt4:Statistika stoixeia");
    printf("ntt5:Eksodosn");
    int c = 0;
    scanf("%d", &c);
    do 
     {
      
        if (c > 0 || c < 5) 
          {
            switch (c) 
              {
                case 1:
                    Eksetash();
                    break;
 
                case 2:
                    Anazhthsh_kai_ektupwsh_bathmou();
                    break;
 
                case 3:
                    Ektupwsh_telikhs_listas_bathmologias();
                    break;
 
                case 4:
                    Statistika_stoixeia();
                    break;
               }
          } 
     }
     
     while(c>5);
     return c;
    
 }



0



Содержание

  1. C++ Error ID Returned 1 Exit Status
  2. Common Causes of [Error]: Id returned 1 exit status in C++
  3. Solution of [Error]: Id returned 1 exit status in C++
  4. Qt ошибка: collect2: error: ld returned 1 exit status
  5. Dev-C++ Discussion
  6. Open Source C & C++ IDE for Windows
  7. Forums
  8. Invalid Argument: ld returned 1 exit status
  9. include
  10. include
  11. include
  12. include
  13. include
  14. include
  15. include
  16. include

C++ Error ID Returned 1 Exit Status

The C++ [Error]: Id returned 1 exit status is not a common error. It usually means that the program crashed, and it will be challenging to determine why without looking at the stack trace.

The C++ compiler will display this message when an error occurs in your code. This can be due to a syntax error or some other problem with your code.

The compiler will also display where the problem occurred, so you can correct it and try again.

Common Causes of [Error]: Id returned 1 exit status in C++

The possible causes of this error are:

  1. A syntax error in the C++ program.
  2. A mismatch between the compiler and the library.
  3. An incorrect link to a library.
  4. An incorrect or missing header file.

Solution of [Error]: Id returned 1 exit status in C++

The most common reason for this error is a mismatch in the compiler version. A compiler converts your code into machine language.

There are two major compiler versions: GCC and Microsoft Visual Studio.

Below are four ways to fix this problem.

  1. Download the latest version of the compiler from its website and install it on your computer.
  2. Update your system with the latest updates from Windows Update, including installing any recommended updates for Visual Studio or GCC.
  3. Use a different compiler, Clangor MinGW, to compile your code instead of GCC or Microsoft Visual Studio.
  4. Examine how the main() function is written. The function main() must be written in lowercase and with proper spelling.

Let’s discuss an example of this error.

We wrote the first alphabet of the main function in capital letters in this example. That’s why we are getting this error.

We will write the main function in lowercase letters instead of capital letters to solve this error.

Click here to check the working of the code as mentioned above.

Muhammad Adil is a seasoned programmer and writer who has experience in various fields. He has been programming for over 5 years and have always loved the thrill of solving complex problems. He has skilled in PHP, Python, C++, Java, JavaScript, Ruby on Rails, AngularJS, ReactJS, HTML5 and CSS3. He enjoys putting his experience and knowledge into words.

Источник

Qt ошибка: collect2: error: ld returned 1 exit status

Kubuntu LTS 18.04 новая, Qt 5.11

Всем привет! Поставил новую Kubuntu и Qt, сделал новый проект, только с MainWindow. Сначала ругался линковщик, вылечил установив

и еще время от времени вылезает такая ошибка

Ошибка где-то выше должна быть. Полный выхлоп дай.

Покажи что выдает.

Зачем от рута запускал креатор? Делай теперь

Сделал. Ничего не выдает В некоторых проектах были проблемы с девайсами, система не давала работать с ними без прав. Запускал и без рута, ошибка остается

Дай полный вывод с ошибкой.

Извиняюсь, надо было сразу дать инфу из консоли сборки

Народ, я нашел ответ, кому интересно почитать или различается система, здесь: http://doc.qt.io/qt-5/linux.html , а кому некогда, для Debian/Ubuntu (apt-get):

Cпасибо за помощь

Причина в том, что Qt 5 раздулся, разжирел, у него сильно усложнился деплой и теперь он требует OpenGL там, где он нахер не нужен.

Если ты попробуешь заюзать Qt 4, то оно просто соберётся. Так как зависимости от OpenGL там нет.

Все верно, недавно ставил Qt на Lubuntu.

Из соображения — лишь бы было,

поставил, вроде, версию 5.4. Оно там не требовалось.

Источник

Dev-C++ Discussion

Open Source C & C++ IDE for Windows

Forums

Invalid Argument: ld returned 1 exit status

I just started C++ programming today and already I have a problem I can’t get past. I keep getting this

Invalid Argument
ld returned 1 exit status

error when I try to compile. My code is nothing more complicated than:

// test math program

include

include

include

using namespace std;

int main(int nnumberofargs, char* pszargs[])
<
// enter temp in celsius
int celsius;
cout > celsius;

Can someone help please?

umm okay I’ve tried several simple basic programs like hello world type junk and I always get the same

Invalid Argument
ld returned 1 exit status

error whenever I try to compile. Therefore, I can conclude that I probably forgot to set up a program setting correctly. Can anyone please give me some help?

Well, we can help a little more if you post full compile log. Its on the tab labeled «Compile Log», and the right mouse button brings up the copy menu.

Please post the full log starting from the beginning, do not excerpt the errors. It would also be useful to know what version number of Dev you are using.

The invalid argument it is talking about is nothing to do with the code. It is an argument being passed to the linker during the build. All the arguments being passed appear of the build command line which is logged in the ‘Compile Log’. We can do nothing further until you post that text (in full).

Version number: 4.9.9.2

Log:
Compiler: Default compiler
Executing g++.exe.
g++.exe «ceruleanstudents2009bse356celsius to fahrenheit conv.cpp» -o «ceruleanstudents2009bse356celsius to fahrenheit conv.exe» -I»C:cDev-Cpplibgccmingw323.4.2include» -I»C:cDev-Cppincludec++3.4.2backward» -I»C:cDev-Cppincludec++3.4.2mingw32″ -I»C:cDev-Cppincludec++3.4.2″ -I»C:cDev-Cppinclude» -L»C:cDev-Cpplib»
C:cDev-CppBin..libgccmingw323.4.2. mingw32binld.exe: cannot open output file ceruleanstudents2009bse356celsius to fahrenheit conv.exe: Invalid argument
collect2: ld returned 1 exit status

Oh. it looks as if I can’t write the .exe because my stupid school doesn’t allow applications in personal user files.

If this is wrong, please let me know lol

Okay I moved the .cpp file to a writeable folder and it works fine. Coming off of Visual Basic programming, it’s hard.

Thanks for the help!

An important warning!

Spaces in file names are a BAD idea. It will bite you eventually, and hard.

Do you mean no spaces in the directory name or the .cpp itself?

Sorry for being such an annoying noob.

// test string program

include

include

include

using namespace std;

int main(int nnumberofargs, char* pszargs[])
<
// display instructions & ask for name
string name;
cout > name;

>
switch(verify)
<
case True:
cout system’ with no type E:/cpp-saves/namethingy.cpp:26: int system’ redeclared as different kind of
symbol
E:/Dev-Cpp/include/stdlib.h:373: previous declaration of int system(const char*)’ E:/cpp-saves/namethingy.cpp:26: invalid conversion from const char*’ to int’ E:/cpp-saves/namethingy.cpp:27: parse error before return’

I’ve looked through and there seems to be no problems. What’s wrong

If at any time you wish me to just shut the hell up, please say so.

Are you the original poster on this thread?

You log shows a much different setup than the previous log. What version of Dev are you using?

Yes, original poster.

This is version 4.9.8.0.

That is not the version you reported in an earlier post. Please be clear about your Basic 3 with each question. Features vary with version.

Now, with that quite old version of Dev, you may need to add

include

I am guessing a bit, that version is a couple of years old at least.

Is this a different computer than you were using earlier? I hope you didn’t install it instead of 4.9.9.2

Note you also have a LOT of other errors in your code. Missing ; problems with case sensitivity (True does not equal true), misuse of continue.

Yeah, it’s a different computer, but I’m running it off my portable hard drive and all these school computers have the same crap anyway.

Maybe a bit of background knowledge would help here. I’m learning C++ from (here it comes)
C++ for Dummies. I decided to switch back to the old version of Dev-C++ because it’s the one they include with the book. According to the book, the Include files for this version of dev-c++ don’t end in .h (only very old-fashioned programmers use .h according to them, lol)

But anyway I did try the

include

command and I get the same errors, parse error before ‘switch’ and such.

My goal is to make a crappy 2D RPG by the end of the year (using directx. which I have no idea how to reference yet. ) and I really could use some help with basics.

Thanks so much for putting up with my problems!

There is nothing wrong with either or . You need to read the error messages from the top. The first message:

E:/cpp-saves/namethingy.cpp:21: parse error before `switch’

Indicates that the compiler no longer regards the code as valid at that point. Just before that line you have a closing brace( > ), that terminated teh main() function. All the rest of the code is then outside of any function, and in that context makes no sense.

Always address the first reported error first, then consider if the others are ‘cascaded’ from the first, or separate issues. If in doubt, just re-compile.

You really should use 4.9.9.2, that is what most of the people that can help you here are using, so it helps if they need to reproduce your error.

I’m on the IRC support channel at #bloodshed that no one uses according to the title. Can someone join up there and talk me through some of the basic syntax and errors?

Are we talking about the same code you posted above? You should probably start more than one thread, you seem to have started several different subjects in one thread.

Please also sign your threads with a distinct moniker (or create a Sourceforge login); it is not always clear that we are talking to the same person — especially as you keep changing the subject!

The benefit of having problems discussed in this forum is that it benefts the whole community, and the information remains available for reference. IRC is more transient, and benefits very few. This is the place to get your problems solved.

If you are talking about the code posted earlier, then it does have mre problems that the stray brace I mentioned. Reading and understanding teh error messages is a skill you need to learn, they are your first source of help. If you are havig problems understanding them, post the log. If you provide god quality information — such as what version you are using today 😉 , the compile log and commented code — then you will generally get a fast response from here.

With respect yo your earlier code, after removing the stray brace:

The only values a bool type can take are true (non-zero), or false (zero). Values True and False (capitalised) are not defined — C++ is case sensitive).

If you ask the user to type True or False and assign the response to a bool, what do you expect t happen? The only response that I’d like to guarantee the result for are numeric values — zero for false, or non-zero for true. If the user types non-numeric text, I am not sure what will happen, probably always fales, always true, or undefined.

bool is a numeric type, not a string type. If you want to accept a text response, you need to use a string class object. You can’t then use switch, that is only valid for integer types. If it works for bool, that is probably only because of an implicit cast to int.

Switching on a bool type!? What’s the point? It only has two possible states, the default case is unreachable if you have a true and false case. A simple if-else construct will deal with a boolean value.

Источник

  1. HowTo
  2. C++ Howtos
  3. C++ Error ID Returned 1 Exit Status
  1. Common Causes of [Error]: Id returned 1 exit status in C++
  2. Solution of [Error]: Id returned 1 exit status in C++

C++ Error ID Returned 1 Exit Status

The C++ [Error]: Id returned 1 exit status is not a common error. It usually means that the program crashed, and it will be challenging to determine why without looking at the stack trace.

The C++ compiler will display this message when an error occurs in your code. This can be due to a syntax error or some other problem with your code.

The compiler will also display where the problem occurred, so you can correct it and try again.

Common Causes of [Error]: Id returned 1 exit status in C++

The possible causes of this error are:

  1. A syntax error in the C++ program.
  2. A mismatch between the compiler and the library.
  3. An incorrect link to a library.
  4. An incorrect or missing header file.

Solution of [Error]: Id returned 1 exit status in C++

The most common reason for this error is a mismatch in the compiler version. A compiler converts your code into machine language.

There are two major compiler versions: GCC and Microsoft Visual Studio.

Below are four ways to fix this problem.

  1. Download the latest version of the compiler from its website and install it on your computer.
  2. Update your system with the latest updates from Windows Update, including installing any recommended updates for Visual Studio or GCC.
  3. Use a different compiler, Clangor MinGW, to compile your code instead of GCC or Microsoft Visual Studio.
  4. Examine how the main() function is written. The function main() must be written in lowercase and with proper spelling.

Let’s discuss an example of this error.

#include <stdio.h>

int Main()    // main() is not written in lowercase
{
   printf("My name is Muhammad Adil");
return 0;
}

We wrote the first alphabet of the main function in capital letters in this example. That’s why we are getting this error.

We will write the main function in lowercase letters instead of capital letters to solve this error.

#include <stdio.h>

int main()    // main() is not written in lowercase
{
   printf("My name is Muhammad Adil");
return 0;
}

Click here to check the working of the code as mentioned above.

Muhammad Adil avatar
Muhammad Adil avatar

Muhammad Adil is a seasoned programmer and writer who has experience in various fields. He has been programming for over 5 years and have always loved the thrill of solving complex problems. He has skilled in PHP, Python, C++, Java, JavaScript, Ruby on Rails, AngularJS, ReactJS, HTML5 and CSS3. He enjoys putting his experience and knowledge into words.

Facebook

Related Article — C++ Error

  • Solved — Python.h: No Such File or Directory in C++
  • Jump to Case Label in the switch Statement
  • NULL Undeclared Error in C++
  • C++ std::bad_alloc Exception
  • Error: Cannot Call Member Function Without Object in C++
  • Solved: Expression Must Have Class Type Error in C++Ezoic
  • Понадобилась функция, делающая скриншот в программе и сохраняющая его в файл. Я нашёл несколько таких функций, но каждая (!) из них при добавлении в программу заставляет её выдавать при компиляции вот такую ошибку:

    C:{папка_с_файлом.cpp}collect2.exe [Error] ld returned 1 exit status

    Причём других ошибок нет, или я их исправляю. Обычно такая ошибка происходит, когда у меня код уже скомпилирован и запущен .exe, и я пытаюсь ещё раз его скомпилировать и запустить. Но, разумеется, я всё перепробовал, даже запускал код на другом компе (но тоже в Dev) — такая же ошибка.

    Если убрать эту функцию, то код снова нормально работает. Подскажите, что делать?

    Вот текущий код с одним из вариантов функции, делающий скриншот:

    #include <Winsock2.h>//Ws2_32.lib
    #include <ws2tcpip.h>
    #include <Windows.h>
    #include <iostream>
    #include <stdio.h>
    #include <stdlib.h>
    #include <conio.h>  //getch
    #include <string.h>
    #include <fcntl.h>
    #include <unistd.h>
    #include <sys/types.h>
    #include <sys/time.h>
    //#include <sys/socket.h>
    #define ever (;;)
    #include <gdiplus.h>
    #pragma comment(lib, "GdiPlus.lib")
    
    //Тут всякий другой код. Вообще, программа для работы с сетью (это клиент). 
    //Но она даже не запускается, выдаёт ту ошибку.
    
    using namespace std;
    using namespace Gdiplus; 
    
    static const GUID png = 
    { 0x557cf406, 0x1a04, 0x11d3, { 0x9a, 0x73, 0x00, 0x00, 0xf8, 0x1e, 0xf3, 0x2e } };
    
    
    int PrtScr()
    {
        GdiplusStartupInput gdiplusStartupInput;
        ULONG_PTR gdiplusToken;
        GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
    
        HDC scrdc, memdc;
        HBITMAP membit;
    
        scrdc = GetDC(0);
    
        int Height, Width;
        Height = GetSystemMetrics(SM_CYSCREEN);
        Width = GetSystemMetrics(SM_CXSCREEN);
    
        memdc = CreateCompatibleDC(scrdc);
        membit = CreateCompatibleBitmap(scrdc, Width, Height);
        SelectObject(memdc, membit);
    
        BitBlt(memdc, 0, 0, Width, Height, scrdc, 0, 0, SRCCOPY);
        HBITMAP hBitmap;
        hBitmap =(HBITMAP) SelectObject(memdc, membit);
         Gdiplus::Bitmap bitmap(hBitmap, NULL);
         char PerMin[12];
         strcpy (PerMin,"screen.png" );
        bitmap.Save((WCHAR*)PerMin, &png,NULL);
    
        DeleteObject(hBitmap);
    
        return 0;
    }
    
    
    
    /////////////////////////////////////////////////////  
    
    
    
    int main()
    {
    
        printf ("OK1n");
        getch();
        PrtScr();
        printf ("OK2n");
        getch();    
        //Тут всякий иной код
        return 0;
    }
    

    For some reason, when I try compiling a program, the compiler says permission denied and Id returned 1 exit status. Could anyone tell me what that means? Thank you

    #include <stdio.h>                                               /* Library inclusions */
    #include "genlib.h" 
    #include "simpio.h"
    
    int binSearch(int val, int numbers[], int size1);                /* prototypes */
    void sortArray (int numbers[], int size1);                       
    int indexMax (int numbers[], int low, int high);
    void swap (int numbers[], int loc, int loc1);
    void getArray (int numbers[], int size1);
    void displayArray (int numbers[], int size1);
    
    main()
    {
      int value, size1;
    
      printf("Enter the number of elements: ");
      size1=GetInteger(); 
      int numbers[size1];
      getArray(numbers, size1); 
      sortArray(numbers, size1); 
      displayArray(numbers, size1);
      printf("nEnter value to find: ");
      value=GetInteger();
      binSearch(value, numbers, size1);
      getchar();
    }
    
    void sortArray (int numbers[], int size1)                        /*Function sortArray*/
    {
     int i , maxInd;
    
     for (i= size1-1; i>=0;i--)
     {
         maxInd=indexMax(numbers, 0, i);
         swap (numbers, i, maxInd);
     }
    }
    
    void displayArray (int numbers[], int size1)                     /*Function displayArray*/
    {
     int i;
    
     printf("This is the sorted set of numbers: n");
     for (i=0; i< size1; i++)
     {
             printf ("%dt", numbers[i]); 
         }
    }
    
    void getArray (int numbers[], int size1)                         /*Function getArray*/
    {
     int i;
    
     for (i=0; i<size1; i++)
     {
         printf ("Enter the values of the %d elements: ", size1);
         numbers[i]=GetInteger();
     }
    }
    
    int indexMax (int numbers[], int low, int high)                  /*Function indexMax*/
    {
    int i, maxInd;
    
    maxInd=high;
    for (i=low;i<=high;i++)
    {
        if (numbers[i]>numbers[maxInd]) 
        {
                       maxInd =i;
        }
        }
        return (maxInd);
    }
    
    void swap (int numbers[], int loc, int loc1)                     /*Function swap*/
    {
     int temp;
    
     temp=numbers[loc];
     numbers[loc]=numbers[loc1];
     numbers[loc1]=temp;
    }
    
    int binSearch(int val, int numbers[], int size1)                 /*Function binSearch*/
    {
     int low, high, mid;
    
     low=0;
     high=size1-1;
     while(low<=high)
     {
                     mid=(low+high)/2;
                     if(val<numbers[mid])
                     {
                                     high=mid-1;                
                     }            
                     else if(val>numbers[mid])
                     {
                                     low=mid+1; 
                     }   
                     else if(val==numbers[mid])
                     {
                                     printf("Your number is in location %dn", mid+1);break;    
                     } 
                     else
                     {
                                     printf("Your value is not in the array.");        
                     }
       }
    }
    

    The above is the binary search algorithm code I tried to compile.

    For some reason, when I try compiling a program, the compiler says permission denied and Id returned 1 exit status. Could anyone tell me what that means? Thank you

    #include <stdio.h>                                               /* Library inclusions */
    #include "genlib.h" 
    #include "simpio.h"
    
    int binSearch(int val, int numbers[], int size1);                /* prototypes */
    void sortArray (int numbers[], int size1);                       
    int indexMax (int numbers[], int low, int high);
    void swap (int numbers[], int loc, int loc1);
    void getArray (int numbers[], int size1);
    void displayArray (int numbers[], int size1);
    
    main()
    {
      int value, size1;
    
      printf("Enter the number of elements: ");
      size1=GetInteger(); 
      int numbers[size1];
      getArray(numbers, size1); 
      sortArray(numbers, size1); 
      displayArray(numbers, size1);
      printf("nEnter value to find: ");
      value=GetInteger();
      binSearch(value, numbers, size1);
      getchar();
    }
    
    void sortArray (int numbers[], int size1)                        /*Function sortArray*/
    {
     int i , maxInd;
    
     for (i= size1-1; i>=0;i--)
     {
         maxInd=indexMax(numbers, 0, i);
         swap (numbers, i, maxInd);
     }
    }
    
    void displayArray (int numbers[], int size1)                     /*Function displayArray*/
    {
     int i;
    
     printf("This is the sorted set of numbers: n");
     for (i=0; i< size1; i++)
     {
             printf ("%dt", numbers[i]); 
         }
    }
    
    void getArray (int numbers[], int size1)                         /*Function getArray*/
    {
     int i;
    
     for (i=0; i<size1; i++)
     {
         printf ("Enter the values of the %d elements: ", size1);
         numbers[i]=GetInteger();
     }
    }
    
    int indexMax (int numbers[], int low, int high)                  /*Function indexMax*/
    {
    int i, maxInd;
    
    maxInd=high;
    for (i=low;i<=high;i++)
    {
        if (numbers[i]>numbers[maxInd]) 
        {
                       maxInd =i;
        }
        }
        return (maxInd);
    }
    
    void swap (int numbers[], int loc, int loc1)                     /*Function swap*/
    {
     int temp;
    
     temp=numbers[loc];
     numbers[loc]=numbers[loc1];
     numbers[loc1]=temp;
    }
    
    int binSearch(int val, int numbers[], int size1)                 /*Function binSearch*/
    {
     int low, high, mid;
    
     low=0;
     high=size1-1;
     while(low<=high)
     {
                     mid=(low+high)/2;
                     if(val<numbers[mid])
                     {
                                     high=mid-1;                
                     }            
                     else if(val>numbers[mid])
                     {
                                     low=mid+1; 
                     }   
                     else if(val==numbers[mid])
                     {
                                     printf("Your number is in location %dn", mid+1);break;    
                     } 
                     else
                     {
                                     printf("Your value is not in the array.");        
                     }
       }
    }
    

    The above is the binary search algorithm code I tried to compile.


    «Error: Id returned 1 exit status (an undefined reference to ‘main’)»

    is a very common C and C++ linker Error. Just by looking at the statement, we can tell that there is an error in the main function.

    In this article, we will talk about the

    Id returned 1 exit status

    error, the cause behind its occurrence, and a simple way to fix it. So, let’s get started!


    What is the main() function?

    • Every C++ and C program contains a mandatory inbuilt function called

      main().
    • The

      compiler

      starts the execution from the main function.

    • The compiler automatically invokes the main function and tries to compile all the code line by line from top to bottom.


    Linker Error

    Linker error generally occurs when we link different invalid object files with the main object file. In this error, the compiler is unable to load the executable file because of the wrong prototyping, and incorrect header files.


    Error Cause

    Here are the two key causes for the error:

    • The user commits some mistakes while writing the main function.
    • The

      main()

      function is not written in lower case.


    Error example:


    Example 1

    #include <stdio.h>
    int Main()    // main() is not written in lowercase
    {
       printf("Welcome to TechGeekBuzz");
    return 0;
    }


    Output:

    [Error]: Id returned 1 exit status (undefined reference to 'main')


    Example 2

    #include <stdio.h>
    
    int kain()    // Mistype main() with kain() 
    {
        printf("Welcome to TechGeekBuzz");
    return 0;
    }


    Output

    [Error]: Id returned 1 exit status (undefined reference to 'main')


    How to Fix the Error?

    • To fix the error, check how you have written the

      main()

      function.
    • The

      main()

      function must be written in lowercase with correct spelling.


    Example

    Let’s fix the above-mentioned error examples by writing the code appropriately as shown below:

    #include <stdio.h>
    int main() {
       printf("Welcome to TechGeekBuzz");
    return 0;
    }


    Output

    Welcome to TechGeekBuzz


    Conclusion

    C and C++ are case-sensitive languages, so it is necessary to use the correct letter case while writing the program. The error «undefined reference to main» occurs when we mistype or misspell the main() function.


    People are also reading:

    • WAP to Addition, subtraction and multiplication of two numbers

    • C Pattern Programs

    • Features of C

    • C Courses

    • Difference Between C and C++

    • C Matrix Multiplication

    • Best C Books for Beginners

    • C Interview Questions & Answers

    • Objective C vs Swift

    • Call by Value vs Call by Reference

    • Forum
    • Beginners
    • error: Id returned 1 exit status

    error: Id returned 1 exit status

    I have to make a program that codes it’s own queue(cola) class for plane(avion) type objects, but when compiling I receive this message without information of what line has caused the problem. I’d be very grateful if someone can tell me what’s wrong with my code because this is driving me crazy.

    The error message is;
    === Build: Debug in Prac1 (compiler: GNU GCC Compiler) ===
    error: Id returned 1 exit status
    === Build failed: 1 error (s), 0 warning (s) (0 minute (s), 0 second (s)) ===

    ————— Build: Debug in Prac1 (compiler: GNU GCC Compiler)—————

    mingw32-g++.exe -o binDebugPrac1.exe objDebugAvion.o Avion.h.gch objDebugCola.o objDebugmain.o objDebugNodo.o
    Avion.h.gch: file not recognized: File format not recognized
    collect2.exe: error: ld returned 1 exit status
    Process terminated with status 1 (0 minute(s), 0 second(s))
    1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

    My code:

    Cola.h (queue)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #ifndef COLA_H_INCLUDED
    #define COLA_H_INCLUDED
    #include <string>
    #include "Avion.h"
    #include "Nodo.h"
    
    using namespace std;
    
    class Cola
    {
    public:
        Cola();
        ~Cola();
        void encolar(Avion);
        string desencolar();
    
    private:
        pnodo ultimo, primero;
    };
    
    #endif 

    Cola.cpp

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    #include "Cola.h"
    #include <cstddef>
    
    using namespace std;
    
    Cola::Cola()
    {
        ultimo = NULL;
        primero = NULL;
    }
    
    Cola::~Cola()
    {
        while(primero) desencolar();
    }
    
    void Cola::encolar(Avion a)
    {
        pnodo nuevo;
        nuevo = new Nodo(a);
        if (ultimo) ultimo->siguiente = nuevo;
        ultimo = nuevo;
        if (!primero) primero = nuevo;
    }
    
    string Cola::desencolar()
    {
        pnodo nodo;
        string a;
        nodo = primero;
        if(!nodo) return NULL;
        primero = nodo->siguiente;
        a = nodo->avion.getId();
        delete nodo;
        if(!primero) ultimo = NULL;
        return a;
    }

    Avion.h (plane)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    #ifndef AVION_H_INCLUDED
    #define AVION_H_INCLUDED
    #include <string>
    
    using namespace std;
    
    class Avion{
        private:
            string id, origen, destino;
            int hSalida, hDestino, hLlegada, tEspera, combustible;
    
        public:
            Avion();
            Avion(string, string, string, int, int, int, int, int);
            string getId();
            int getHDestino();
            int getHLlegada();
            int getTEspera();
            int getCombustible();
    };
    
    
    #endif 

    Avion.cpp

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    #include "Avion.h"
    
    using namespace std;
    
    Avion::Avion()
    {
    
    }
    
    Avion::Avion(string iden, string orgn, string dest, int hS, int hD, int hL, int tE, int c)
    {
        id = iden;
        origen = orgn;
        destino = dest;
        hSalida = hS;
        hDestino = hD;
        hLlegada = hL;
        tEspera = tE;
        combustible = c;
    }
    
    string Avion::getId()
    {
        return id;
    }
    
    int Avion::getHDestino()
    {
        return hDestino;
    }
    
    int Avion::getHLlegada()
    {
        return hLlegada;
    }
    
    int Avion::getTEspera()
    {
        return tEspera;
    }
    
    int Avion::getCombustible()
    {
        return combustible;
    }

    Nodo.h (node)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #ifndef NODO_H_INCLUDED
    #define NODO_H_INCLUDED
    #include "Avion.h"
    
    using namespace std;
    
    class Nodo
    {
        private:
            Avion avion;
            Nodo *siguiente;
            friend class Cola;
    
        public:
            Nodo(Avion);
    };
    
    typedef Nodo *pnodo;
    
    
    #endif 

    Nodo.cpp

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    #include "Nodo.h"
    #include <cstddef>
    
    using namespace std;
    
    Nodo::Nodo(Avion a)
    {
        avion = a;
        siguiente = NULL;
    }

    main.cpp

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    #include <iostream>
    #include "Cola.h"
    #include "Avion.h"
    #include "Nodo.h"
    
    using namespace std;
    
    int main()
    {
        Cola c = Cola();
        Avion a1("ES1111", "MAD", "AGP", 1600, 1700, 1710, 0005, 40);
        Avion a2("GP0432", "CDG", "AGP", 1550, 1655, 1705, 0010, 35);
        c.encolar(a1);
        c.encolar(a2);
        cout << c.desencolar();
        cout << c.desencolar();
        cout << c.desencolar();
    
        return 0;
    }

    Last edited on

    Why don’t you say what compiler you are using? All modern compilers that I know of will say the line number that something is failing on.

    I didn’t actually compile your code, but while reading through it, I notice you have the following:

    1
    2
    3
    4
    5
    6
    7
    string Cola::desencolar()
    {
        pnodo nodo;
        string a;
        nodo = primero;
        if(!nodo) return NULL;
        ....

    NULL is the old way of signifying that you want to return a null pointer. It is most likely just a #defined way of saying 0. (i.e. #define NULL 0 ).

    Your method expects a string to be returned — you are trying to return a pointer or int.

    Edit: Didn’t realize std::string s = 0; is legal in C++… ignore this post.

    Last edited on

    Please post the FULL output text from your compiler.

    if the message is «ld returned exit status 1», that’s generally an indication of a linker error.
    The linker output (which you haven;t shown) should give an indication of the problem.

    Last edited on

    I’ve edited the post with the full output I receive.

    Usually when I have an error GCC indicates the line where it’s been produced, but apparently not this time.

    Also I’ve changed the line:

    1
    2
    3
    4
    5
    string Cola::desencolar()
    {
    ...
    if(!nodo) return NULL;
    ...

    For:

    1
    2
    3
    4
    5
    string Cola::desencolar()
    {
    ...
    if(!nodo) return " ";
    ...

    And it hasn’t solved it.

    According to your edited post, it doesn’t know what GCH files are.
    GCH seem to be GCC pre-compiled header files. Pre-compiled headers are used to reduce compilation time.

    However, as far as I know, pre-compiled headers do not work on mingw32.

    I would say, try cleaning your workspace/directories and re-compile/link.
    If that doesn’t work, perhaps someone more experienced in pre-compiled headers or MinGW can help.

    (PS: I forgot that C++ allows for implicit conversion from integer to string, so my previous post is irrelevant)

    Last edited on

    Just updated with the Build log, if it’s of any use.

    I think you have not included the avion.h file in your compiler.Some files have to be added manually to the compiler

    Well I’ve solved the problem, just had to uncheck «Compile File» and «Link File» in the properties of Avion.h so the compiler wouldn’t make that gch file. I use Code::Blocks by the way. Thanks for the help.

    Note that both std::string s = 0; and if(!nodo) return NULL; exhibit undefined behavior.
    Among every possible integer literal, only the literal zero is also a null pointer constant.
    That is, in this context, 0 is implicitly converted to a char*, and used to copy-initialize s. The behavior is undefined, because the null pointer doesn’t point to a zero-terminated array of characters.

    See the fifth constructor overload here:
    http://en.cppreference.com/w/cpp/string/basic_string/basic_string
    http://eel.is/c++draft/string.cons#12

    Last edited on

    Thanks for the gotcha info, mbozzi.

    Topic archived. No new replies allowed.

    Why is the collect error ld returned exit status happeningThe collect2: error: ld returned 1 exit status error message is easily fixed by removing an existing executable file inside your document. It is possible to remove the existing file that is running in the background by accessing the thread tools inside your system. The complete process is easy to do and only consists of a couple of steps.

    If you want to become an expert at fixing this undefined reference in your program, keep reading this complete guide that contains all the details.

    Contents

    • Why Is the collect2: Error: Ld Returned 1 Exit Status Happening?
    • How To Fix This Error Inside Your Program
      • – Listing All the Possible Methods for Debugging This Error
      • – A Common Error in the Gem Native Extension
      • – Using the Debugging Library Syntax for the collect2 Error
      • – Facing This Error in Dev C++
    • FAQs
      • – What Is collect2 Exe?
      • – What Does Error 1d Returned 1 Exit Status Mean?
      • – How To Combine Two Files in C++?
    • Final Conclusion and Further Notes

    Why Is the collect2: Error: Ld Returned 1 Exit Status Happening?

    This specific collect2: error: ld returned 1 exit status error message appears due to previous errors in your document, especially when working with C++. It represents one of the most common errors web developers face but it is also one of the easiest ones to fix. In other words, this error is there to indicate that the linking step in the process of creating faced certain problems.

    This is going to create an undefined reference because the exit status is more than the value of zero. You can run multiple steps to create a search thread that is going to eliminate the problem. We are going to list and explain the various methods you can use to fix this error in your document. Continue reading the following section of this article to learn more about the debugging process.

    How To Fix This Error Inside Your Program

    The easiest and most common method of fixing this error requires you to completely delete the existing executable file that is running in the background of your program. However, as is the case with most other bugs, this solution might not work for everyone and every single time. Lucky for you, programming languages allow users to fix an error in multiple ways, in case any of the previous ones does not work.

    This is called a process of debugging, where you are trying to completely remove an error you have encountered in your program. No matter how serious the error may be, the debugging process always starts with an inspection of the problem. After that, locate where the error is coming from and apply all the necessary changes to the code.

    Let us now learn something more about the ways of debugging this error.

    – Listing All the Possible Methods for Debugging This Error

    In this part of the guide, we are going to list the possible methods for debugging and also briefly explain their function. Let us take a deep dive at the following list that shows the most common ways of fixing this error:

    • Deleting the existing executable file inside your program: The file may have failed because it is locked in a different location, such as an antivirus.
    • It is possible to try and rename that specific executable file in your program. Then, you are supposed to restructure the contents, and you are done. Renaming the file helps the program to create an additional executable file.
    • In case none of this works, you should try restarting your computer and redo the first step. This solution shows that debugging does not always have to be complicated.

    In theory, this is all it takes to completely remove this error from your syntax. However, it is always best to learn from examples. That is why in the following section of this article, we are going to show you example codes to easily fix this error.

    – A Common Error in the Gem Native Extension

    Many web developers face certain problems once working with extensions for their browsers. One such bug appears when you are trying to install a gem inside the native extension on your browser.

    The reason why we are explaining the native extension is that the collect2 error usually appears during the process of installing a gem. To better understand what this means, you should take a look at the complete syntax.

    Take a closer look at the following code that is going to initiate the collect2 error:

    Building a proper native extension.  This might take a while…

    ERROR:  Error installing json:
    ERROR: Failed to generate gem native extension.
    /home/foobar/.rvm/ruby-2.4.7/bin/ruby -r ./siteconf134617815-3312439-1i9lahdrj.rb extconf.rb
    creating Makefile
    make “DESTDIR=” clean
    make “DESTDIR=”
    compiling generator.c
    linking shared-object json/ext/generator.so
    /usr/bin/ld: cannot find -lgmp
    collect2: error: ld returned 1 exit status
    make: *** [generator.so] Error 1
    make failed, exit code 2

    Gem files will remain installed in /home/foobar/.rvm/gems/ruby-2.4.7/gems/json-1.8.3 for inspection.

    Results logged to /home/foobar/.rvm/gems/ruby-2.4.7/extensions/x86_64-linux/2.2.0/json-1.8.3/gem_make.out

    As you can see, this is the complete code for the collect2 error inside your program. There is certainly something you can do to the syntax to debug this error and make the program functional again. Indeed, we are going to change some things in the library and this is going to completely remove the error. Take a look at the following section of this article to learn more.

    – Using the Debugging Library Syntax for the collect2 Error

    As previously explained, you are supposed to change certain things inside the library to fix this error. For this, you are going to need the gmp function to locate the correct files and return the incorrect status. Open the code with the cache search gmp function and include all the additional tools inside.

    The following syntax shows how to properly use the gmp function to fix this error:

    $ apt-cache search gmp
    libgmp-dev – Multiprecision arithmetic library developers tools
    libgmp10 – Multiprecision arithmetic library
    libgmp10-doc – Multiprecision arithmetic library example code
    libgmp3-dev – Multiprecision arithmetic library developers tools
    libgmpxx4ldbl – Multiprecision arithmetic library (C++ bindings)
    […]

    Be aware that the syntax may be subject to changes. As this example shows, the annoying collect2 error does not have to be complicated to locate and fix. However, pay attention to the exact location of the gmp function because this may sometimes be the difference between a correctly and incorrectly executed code. Let us now learn other things about this common error in your program.

    – Facing This Error in Dev C++

    As previously explained, the collect2 error may usually appear once working with Dev C++. It refers to a specific reference to a name where the linker cannot define the way it looks based on the object files. This also applies to all the libraries that make up your document.

    Lucky for you, fixing the error is done in the same manner as previously taught. All you have to do is to follow the steps discussed in this article and the problem is going to disappear. To learn more about this error, continue reading the FAQ section of this article.

    FAQs

    Here are the answers to some of your questions regarding this error.

    – What Is collect2 Exe?

    Collect2 represents a utility that web developers use to arrange certain initialization functions during the start time. In other words, it is used to link the program and the adequate functions, while creating a table inside a temporary file. Then, it is going to create a second link with the program but include a different file.

    – What Does Error 1d Returned 1 Exit Status Mean?

    The returned 1 status refers to an error in your document that is created due to previous errors. It is used as an indicator to point out that certain linking steps during the building process have bugs. To fix the error, you are supposed to refer to all the previous functions and locate the part of the program that is operating incorrectly.

    – How To Combine Two Files in C++?

    You can start combining two files in C++ by creating two separate source files on your server. The process of combining two C++ files is important because you can combine two different programs and functions. Since the collect2 error usually appears during this process, it is important to understand how the files are merged together.

    There are several steps you are supposed to closely follow, as shown in the following list:

    1. Create two separate C++ source files on your server.
    2. Both files should be saved inside the same location on the server.
    3. Open the Command Prompt tool and run the various commands from your files.
    4. The tool is going to merge the two separate source files together and comply their functions.
    5. Install the C++ Complier Program to run the newly-created file without any bugs.

    This is all it takes to create a complex C++ file without facing any collect2 errors in your server. You can use this method for any two C++ files.

    This section wraps everything important you were supposed to know about the collect2 error in your document. Let us now summarize the details.

    Final Conclusion and Further Notes

    This specific exit status error message is easily fixed by removing an existing executable file inside your document. Let us take a deep dive at the following list that contains all the important details from this article:

    • The collect2 error is easily fixed by shutting down a program that is running in the background
    • Web developers usually face this problem once working with Dev C++ and other files
    • The Gem native extension usually displays this error alongside the complete syntax but it can be easily fixed
    • It is important to know the meaning of collect2 to debug the error more efficiently
    • It is possible to merge two C++ source files in five basic steps without caring about this error

    How to fix collect error ld returned exit status errorWeb developers are constantly struggling with the collect2 error inside their syntax and are unable to debug it. Lucky for you, now you know all the details to remove this error from your document without affecting the rest of the syntax.

    • Author
    • Recent Posts

    Position is Everything

    Position Is Everything: Your Go-To Resource for Learn & Build: CSS,JavaScript,HTML,PHP,C++ and MYSQL.

    Position is Everything

    Понравилась статья? Поделить с друзьями:
  • Error id 1001 nox
  • Error icon svg
  • Error icon ico
  • Error icon free
  • Error i18n support is not compatible with next export