LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-12-2007, 06:26 PM   #1
just_me_then
Member
 
Registered: Dec 2006
Posts: 59

Rep: Reputation: 15
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!
 
Old 02-12-2007, 06:36 PM   #2
just_me_then
Member
 
Registered: Dec 2006
Posts: 59

Original Poster
Rep: Reputation: 15
Ok... Very stupid mistake. Fixed it!
 
Old 02-13-2007, 01:59 AM   #3
Peter_APIIT
Member
 
Registered: Dec 2006
Posts: 618

Rep: Reputation: 31
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.
 
Old 02-14-2007, 03:44 PM   #4
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,311
Blog Entries: 61

Rep: Reputation: Disabled
gcc -o filename filename.c
./filename
 
Old 02-18-2007, 03:37 AM   #5
Peter_APIIT
Member
 
Registered: Dec 2006
Posts: 618

Rep: Reputation: 31
Thanks for your help.
 
Old 02-18-2007, 03:41 AM   #6
Peter_APIIT
Member
 
Registered: Dec 2006
Posts: 618

Rep: Reputation: 31
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.
 
Old 02-18-2007, 05:20 AM   #7
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 02-20-2007, 01:07 AM   #8
Peter_APIIT
Member
 
Registered: Dec 2006
Posts: 618

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile GCC 2.9 using GCC 3.x kassle Linux - Software 3 11-27-2006 10:37 PM
Weird problem, can't compile kernel: gcc: Internal error:Segmentation fault (prgm as) abefroman Linux - Software 4 08-01-2006 06:28 PM
Problem with gcc powerpc cross compile !! rohya_joshi Linux - Software 2 02-07-2006 01:44 AM
Qmail Compile Problem with GCC-3.3 Richard7890 Linux - Software 3 06-22-2005 08:17 AM
GCC + STL Compile Problem Hairein Programming 6 09-23-2004 09:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration