LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 12-21-2004, 02:21 PM   #1
killos
LQ Newbie
 
Registered: Dec 2004
Posts: 14

Rep: Reputation: 0
HELP!! Compiling on C


HELP!! Compiling on C (I think I may of placed this in the wrong forum b4, sorry!)

anywayz

I just have a quick question regarding compiling of C, I believe it simple (well not to me), and any help would be much appreciated.

Basically I am a beginner at C programming language and I am having difficult at compiling any code.

At the moment I placed the following code onto notepad and saved it as samp.c:

#include <stdio.h>

int main()
{
printf("This is output from my first program!\n");
return 0;
}


The problems is when I try to compile the code whether through cc or gcc, by doing gcc samp.c –o samp.exe I always get the following response:

“No such file or directory”

How do I overcome this problem ?? (also on my computer I have several dives)
 
Old 12-21-2004, 02:21 PM   #2
killos
LQ Newbie
 
Registered: Dec 2004
Posts: 14

Original Poster
Rep: Reputation: 0
HELP!! Compiling on C

HELP!! Compiling on C (I think I may of placed this in the wrong forum b4, sorry!)

anywayz

I just have a quick question regarding compiling of C, I believe it simple (well not to me), and any help would be much appreciated.

Basically I am a beginner at C programming language and I am having difficult at compiling any code.

At the moment I placed the following code onto notepad and saved it as samp.c:

#include <stdio.h>

int main()
{
printf("This is output from my first program!\n");
return 0;
}


The problems is when I try to compile the code whether through cc or gcc, by doing gcc samp.c –o samp.exe I always get the following response:

“No such file or directory”

How do I overcome this problem ?? (also on my computer I have several dives)
 
Old 12-21-2004, 02:46 PM   #3
jollyjoice
Member
 
Registered: Aug 2003
Location: UK
Distribution: Gentoo 64
Posts: 383

Rep: Reputation: 30
er, linux doesn't use exes. Try it without the .exe bit.
 
Old 12-21-2004, 03:00 PM   #4
vinaymudgil007
LQ Newbie
 
Registered: Sep 2004
Location: india
Distribution: pcqlinux
Posts: 10

Rep: Reputation: 1
Lightbulb

###########################################################
At the moment I placed the following code onto notepad and saved it as samp.c:

#include <stdio.h>
int main()
{
printf("This is output from my first program!\n");
return 0;
}
############################################################

now save da file where ever u want to save on ur PC and
try this out------------>

(1) cc (full path name)\samp.c -test
(2) ./test
here test is the output file

u can also use
(1) cc (full path name)\samp.c
(2) ./a.out

this is da default output file--> a.out
 
Old 12-21-2004, 03:02 PM   #5
JunctaJuvant
Member
 
Registered: May 2003
Location: Wageningen, the Netherlands
Distribution: OS X & Linux Mint
Posts: 488

Rep: Reputation: 31
Have you tried specifying the complete path to sample.c?
Your program looks fine, and sample.exe should run fine too allthough I don't think you really need the .exe extension. Unless I'm mistaken that's something Windows needs to recognize it as a "executable" file.
You could also do "gcc sample.c -o sample.bladiebla" and run it just fine.
Just a thought.
 
Old 12-21-2004, 03:16 PM   #6
killos
LQ Newbie
 
Registered: Dec 2004
Posts: 14

Original Poster
Rep: Reputation: 0
Thanx for the response I'll try it now
 
Old 12-21-2004, 03:25 PM   #7
killos
LQ Newbie
 
Registered: Dec 2004
Posts: 14

Original Poster
Rep: Reputation: 0
I tried it, but 'its like' it can not Recognise the directory...which are one of two

(1)H:\my documents\samp.c
(2)H:\samp.c

does the C language come with a default directory like Javas J Builder ???
 
Old 12-21-2004, 03:31 PM   #8
JunctaJuvant
Member
 
Registered: May 2003
Location: Wageningen, the Netherlands
Distribution: OS X & Linux Mint
Posts: 488

Rep: Reputation: 31
Assuming you are using linux, you need to mount the windows partition and use "tab-completion" to change into the correct directory. Linux does not use drive letters.
 
Old 12-21-2004, 03:43 PM   #9
perfect_circle
Senior Member
 
Registered: Oct 2004
Location: Athens, Greece
Distribution: Slackware, arch
Posts: 1,783

Rep: Reputation: 53
DO YOU USE LINUX???
DO YOU HAVE GCC INSTALLED???
 
Old 12-21-2004, 04:15 PM   #10
mjrich
Senior Member
 
Registered: Dec 2001
Location: New Zealand
Distribution: Debian
Posts: 1,046

Rep: Reputation: 45
You definitely do have gcc installed, and within your path ? (What happens when you just type gcc <enter> into a shell ?)
 
Old 12-21-2004, 04:38 PM   #11
jollyjoice
Member
 
Registered: Aug 2003
Location: UK
Distribution: Gentoo 64
Posts: 383

Rep: Reputation: 30
perfect_circle, considering he was trying to compile it as an exe and now mentions H:\ I'd guess not!
killos, NOTE the PENGUINS!
 
Old 12-21-2004, 04:49 PM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

http://www.linuxquestions.org/rules.php


http://www.linuxquestions.org/questi...hreadid=268875
 
  


Closed Thread



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
Compiling narcussist Fedora 6 01-18-2006 12:50 PM
compiling z9_87 Linux - Software 4 12-23-2004 05:29 PM
Various Compiling Errors (GCC compiling Openal, GUIlib, xmms-wma) gregorya Linux - Software 2 08-27-2004 05:03 AM
Compiling in ACPI support on Compaq 2135CA (system crashes while compiling) Dag Linux - Laptop and Netbook 20 07-30-2004 07:56 PM
Kernel compiling and module compiling tarballed Linux - General 1 12-22-2002 05:31 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:51 AM.

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