LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 04-30-2008, 07:59 PM   #1
Ace Blackwell
Member
 
Registered: Mar 2004
Location: Kentucky, USA
Distribution: SlamD 12.1 / Slack 12.0 ~ 14.2_64
Posts: 345

Rep: Reputation: 54
Executable


All,

I have been trying to use KDevelop to compile and run a simple hello world program program with SVGALib. It hasn't worked, so I opted to use Kate and compile from the prompt. It compiled fine but the file it gave me "command not found"

So how does one make an executable file with gcc. After compiling do I have to link the file or do some sort of make install?

Thanks
Ace
 
Old 04-30-2008, 08:26 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,337

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
gcc creates object files whose names end in .o. You have to run the object files through a linker to create an executable file. Most people use make files to coordinate the object files being fed to the linker to create an executable file.

Here is a gcc HOWTO on compiling and linking a program.

http://www.faqs.org/docs/Linux-HOWTO/GCC-HOWTO.html

--------------
Steve Stites

Last edited by jailbait; 04-30-2008 at 08:30 PM.
 
Old 04-30-2008, 09:09 PM   #3
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
For the compiling part:
Code:
gcc -Wall myfile.c -o myprogram
To run the resulting myprogram (note the dot slash before the name of the program).
Code:
wim@desktop1:~$ ./myprogram
 
Old 05-01-2008, 01:55 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
[QUOTE=Wim Sturkenboom;3138321]For the compiling part:
Code:
gcc -Wall myfile.c -o myprogram
Note that to link libraries, you'll need to use the "-l" flag (that's a lowercase L). You may also need to tell gcc where to find the headers and library files, using "-I" and "-L", respectively. This is only if those files are not in "standard" places.
 
  


Reply



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
Executable permissions jared78 Linux - General 3 12-03-2005 08:54 PM
Running a Java executable class from another executable class LUB997 Programming 22 07-24-2005 04:57 AM
Firefox executable babyphil Linux - Software 1 10-21-2004 03:32 AM
Perl to executable ganninu Programming 4 12-18-2003 12:23 PM
Executable, but not in path. Sledge Red Hat 0 12-03-2003 08:48 PM

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

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