LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   gcc compile problem (https://www.linuxquestions.org/questions/programming-9/gcc-compile-problem-527931/)

just_me_then 02-12-2007 05:26 PM

gcc compile problem
 
Hello,

Im have very little experience with any of this, and as such i have been thron by an error! If anyone could help i would be very helpfull!

To complie im running this command:

gcc /crypt.c -o bin/crypt -lcrypt


The code that im trying to compile is this: (i can take no credit for this! was writen by someone else in this forum!)

Quote:

#define _XOPEN_SOURCE
#include <unistd.h>

int main (int argc, char* argv[]) {
char *result;

result= crypt (argv[1], "$1$");

// printf ("the encrypted password for %s is %s\n", argv[1], result);
printf ("%s\n", result);
return (0);
}

And the error is:

Quote:

/usr/bin/ld: cannot open output file bin/crypt: No such file or directory
collect2: ld returned 1 exit status

Where have i gone wrong? Mant thanks!

just_me_then 02-12-2007 05:36 PM

Ok... Very stupid mistake. Fixed it!

Peter_APIIT 02-13-2007 12:59 AM

How you compiled to c file and output the result at terminal ?

i only know this:

gcc the-cfile -0 thecilfe.o

Something like that.

brianL 02-14-2007 02:44 PM

gcc -o filename filename.c
./filename

Peter_APIIT 02-18-2007 02:37 AM

Thanks for your help.

Peter_APIIT 02-18-2007 02:41 AM

I have try the following command:

gcc - o Date date.c ./Date

but the terminal complaint that no Date file or directory. I don't know what wrong with it.


Your help is greatly appreciated by me and others.


Thanks for your help.

graemef 02-18-2007 04:20 AM

You are putting two commands on to the same line
gcc --- compile the program
./ --- execute the program
Try it on two separate lines:
gcc -o Date date.c
./Date

Also you had a space between the - and o (minus lowercase o) they need to be together.
You could probably combine it with a pipe, but that is probably not a good habit to get into.

Peter_APIIT 02-20-2007 12:07 AM

Thanks for your help. I have done it with no problem occurs. Your help is very valuable.


All times are GMT -5. The time now is 11:27 AM.