LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-25-2004, 07:27 PM   #1
SBrogan
LQ Newbie
 
Registered: Sep 2004
Posts: 3

Rep: Reputation: 0
Question Newbie stymied with C question


Ok gurus, heres a newbie question.

first let me say thanks for the help Ive recieved from good people of the realm

I am very interrested in learning C. I have been teaching myself. I was lead to the Linux comunity because I couldnt get a borland compiler to run on my win box, so the more I find out about Linux the more I love it.

Question: when Ive created a "new project" with Kdevelop (2.1.3) wrote the code, compiled, and debugged then how do I get an executable that I could send to my friend and he could run?

I get this file with like 31 files in it for a simple page long program that I wrote. All the explanations in the Kdevelop program seem to be geared at people who already know how to write code, and the book I have " C for Linux, in 21 days" only tells how to use a simple text editor, then compile from the command line. OK, so I forgo the beatiful IDE and try the old fashion way only to get several different files that wont execute.

Could someone point me to a good tutorial for K or a few pointers on how to get the program to execute.

(note; it appears the program is a success and debugs properly)
 
Old 09-25-2004, 07:33 PM   #2
Samsara
Member
 
Registered: May 2003
Distribution: Ubuntu, Mac OS X Tiger
Posts: 481

Rep: Reputation: 32
When compiling from the command line (i.e. gcc sourcefile.c), you get a file a.out which is executable.

You could always send your friend the code...

HTH,

Samsara
 
Old 09-25-2004, 09:45 PM   #3
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Teaching C and teaching someone about a specific IDE are usually 2 entirely different beasts. There's at least a hundred different IDEs out there so teaching both at the same time would be a tremendous amount of time.

I would suggest getting familiar with C programs (and components thereof) before learning how to use an IDE. Jump into the command line and fire up your favorite text editor. Type out the C program and save the file. Back at the command line type gcc -Wall myprog.c -o myprog assuming your C program is stored in a file called myprog.c and you want the final executable to be called myprog.

Here's a really simple thing to try:
Code:
itsme@dreams:~/C$ cat > hello.c
#include <stdio.h>

int main(void)
{
  printf("Hello, world!\n");
  return 0;
}
^D
itsme@dreams:~/C$ cat hello.c
#include <stdio.h>

int main(void)
{
  printf("Hello, world!\n");
  return 0;
}
itsme@dreams:~/C$ gcc -Wall hello.c -o hello
itsme@dreams:~/C$ ./hello
Hello, world!
itsme@dreams:~/C$ ls -l hello
-rwxr-xr-x    1 itsme    users       13252 Sep 25 19:43 hello*
itsme@dreams:~/C$
That final hello file would be the finished program you can send to your friend. All the bold stuff is stuff you should type yourself. The ^D is the key combination CTRL-d which represents End Of File (EOF) in Linux.

Last edited by itsme86; 09-25-2004 at 09:48 PM.
 
Old 09-25-2004, 09:48 PM   #4
tonyfreeman
Member
 
Registered: Sep 2003
Location: Fort worth, TX
Distribution: Debian testing 64bit at home, EL5 32/64bit at work.
Posts: 196

Rep: Reputation: 30
compile line options?

You only have one *.c file? Then a simple compile would be something like this:

Code:
gcc my_program.c
This will give you an "a.out" file ... which is your executable. You could also pass the "-o" option and give your own file name:

Code:
gcc my_program.c -o my_program
This will give you a "my_program" file ... which is your executable.

--Tony
 
  


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
Very Newbie Question. Please Help imfineru Linux - Newbie 8 08-20-2005 05:09 AM
Apache newbie question.. (very newbie question) tarballed Linux - Newbie 1 02-07-2003 08:41 PM
RE: Suse 8.0 hardware question {newbie question, pls help} Radiouk Linux - Distributions 2 06-04-2002 12:53 PM
RE: Samba question pls help {Newbie question} Radiouk Linux - Networking 4 06-03-2002 06:40 PM
Security question {newbie question} Radio Linux - Security 3 05-17-2002 06:32 PM

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

All times are GMT -5. The time now is 10:18 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