Hi,
how can I solve this error message;
"collect2: ld returned 1 exit status"
thank you.
Hi,
how can I solve this error message;
"collect2: ld returned 1 exit status"
thank you.
Well, since my crystal ball is currently in for service and the martians are jamming the forum's mind reading code again... I'd say you should post your code --in code tags-- and let us have a look at it.
here is my code;
Code:#include <stdio.h> #define MAXWEIGHT 100 void fill_sack(int c[], int v[], int W, int n) { int a[MAXWEIGHT]; /* a[i] holds the maximum value that can be obtained using at most i weight */ int last_added[MAXWEIGHT]; /* I use this to calculate which object were added */ int i, j, k=0, m; int totalweight=0; int totalvalue=0; char names[MAXWEIGHT]; int weights[MAXWEIGHT]; int values[MAXWEIGHT]; int aux; char ch; for (i = 0; i <= W; ++i) { a[i] = 0; last_added[i] = -1; } a[0] = 0; for (i = 1; i <= W; ++i) for (j = 0; j < n; ++j) if ((c[j] <= i) && (a[i] < a[i - c[j]] + v[j])) { a[i] = a[i - c[j]] + v[j]; last_added[i] = j; } for (i = 0; i <= W; ++i) if (last_added[i] != -1) printf("Weight %d; Benefit: %d; To reach this weight I added object %d (%d$ %dKg) to weight %d.\n", i, a[i], last_added[i] + 1, v[last_added[i]], c[last_added[i]], i - c[last_added[i]]); else printf("Weight %d; Benefit: 0; Can't reach this exact weight.\n", i); printf("---\n"); aux = W; while ((aux > 0) && (last_added[aux] != -1)) { names[k]=last_added[aux]+1; values[k]=v[last_added[aux]]; weights[k]=aux-c[last_added[aux]]; k=k+1; aux -= c[last_added[aux]]; } for(m=0; m<k;m++) { totalvalue=totalvalue+values[m]; totalweight=totalweight+weights[m]; printf("%s;", names[m]); } printf("%s",names[m+1]); printf("/n%d;TOTAL VALUE IN BAG",totalvalue); printf("/n%d;TOTAL WEIGHT IN BAG",totalweight); ch=getchar(); } int main(void) { char ch; int n = 3; /* The number of objects */ int c[10] = {8, 6, 4}; /* c[i] is the *COST* of the ith object; i.e. what YOU PAY to take the object */ int v[10] = {16, 10, 7}; /* v[i] is the *VALUE* of the ith object; i.e. what YOU GET for taking the object */ int W = 10; /* The maximum weight you can take */ fill_sack(c, v, W, n); ch=getchar(); return 0; }
Throwing your quoted string at Google answers your question a bajillion times.
If you read the output, it should also tell you the problem; output, which I might add, you didn't share.
Soma
Have you ever successfully built a program in this (miserable) IDE?
simple programs are not even compiled also.
i have mingw installed also, i am trying gcc compilation it does not work either, giving the same error "ld returned 1 exit status"
before installing mingw Devc was working fine. i could not understand the problem exactly.
Last edited by madennn; 03-29-2011 at 09:49 AM.
Ok... Do you do any C++ coding, or is it all just plain C?
The DEV IDE and compiler are abandonware. They haven't been supported in nearly a decade and things like updating the compiler are going to cause you irresolvable problems... like you're having now.
For "just plain C" (C-99, to be exact) your best tool is Pelles-C
If you are doing C and C++ on windows, look into Visual C++
In either case DEVC++ and TurboC++ are dinosaurs that just won't go extinct. Neither has even the first bit of support, neither will be updated --ever-- and both suffer problems that are mainly the result of time having left them behind.
That's a known issue. The installers setup some environment variables and the different installations trip over each other. You'll have to manually fix the paths and the environment. Unless it has been deleted, you'll find a "step-by-step" at the board for "Dev-C++".before installing mingw Devc was working fine. i could not understand the problem exactly.
The DEV IDE and compiler are abandonware.O_oneither will be updated --ever--
GCC and the compiler that was "Turbo C++" are updated every year.
With this in mind, it makes even less sense for people to stick with old or just bad compilers. (They have several excellent, free, and modern compiler suites to choose from.)
Soma
Turbo C++ Community
... C++Builder XE Starter Edition... $194.76 after 30 day evaluation expires.Turbo C++ is no longer available. We invite you to learn more about C++Builder XE and download a free trial
Pelles C ... free ... with more features than XE Starter.
MSVC++... free... need to find 3rd party resource editor (also free)
Last edited by CommonTater; 03-29-2011 at 10:24 AM.
In Pelles C you have to create a project...
Click File->New->Project... choose your project type (probably "Win32 console Program") and give it a name at the bottom... then click OK.
Now right click on the project name in the tree window and Add Files ... Add your source file and it should be able to compile it for you right away...
Pelles C is a complete build environment, it's a bit different than you're used to, but a couple of times through the "new project" loop and you'll be fine...
Also look in the help file ... it's VERY complete. Everything the IDE does is detailed as are all function calls in the library.