LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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


Reply
  Search this Thread
Old 02-19-2012, 01:10 PM   #1
sraweber369
LQ Newbie
 
Registered: Feb 2012
Location: California
Posts: 12

Rep: Reputation: Disabled
Problem getting my C program to run


I am having problems getting my C program to run it compiles OK but when I try to run it from a terminal I get an error command not found here is some output

linux-dhj2:/usr/lib/cprogs # cat helloworld.c
#include <stdio.h>
main()
{
printf("hello world\n");
}



linux-dhj2:/usr/lib/cprogs # gcc -o helloworld helloworld.c
linux-dhj2:/usr/lib/cprogs # chmod 744 helloworld
linux-dhj2:/usr/lib/cprogs # helloworld
If 'helloworld' is not a typo you can use command-not-found to lookup the package that contains it, like this:
cnf helloworld
linux-dhj2:/usr/lib/cprogs #

I know C programming fairly well having worked on a comercial mfc C++ project (mfc sucks)

what am I doing wrong
 
Old 02-19-2012, 01:13 PM   #2
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
In Linux, your current directory is normally not in your path. Many people believe there are important safety benefits from not having the current directory in the path.

So you need to type
Code:
./helloworld
in order to run an executable named helloworld in your current directory.

Last edited by johnsfine; 02-19-2012 at 01:15 PM.
 
Old 02-19-2012, 01:14 PM   #3
Heraton
Member
 
Registered: Apr 2011
Location: Germany
Distribution: Mint 10, openSuSE
Posts: 58

Rep: Reputation: 3
Wink

Hi!

Try this one!
Code:
./helloworld
most likely your current working directory is not on your search path (for security reasons)...


Regards,

Heraton

Last edited by Heraton; 02-19-2012 at 01:15 PM. Reason: Typo
 
Old 02-19-2012, 01:17 PM   #4
sraweber369
LQ Newbie
 
Registered: Feb 2012
Location: California
Posts: 12

Original Poster
Rep: Reputation: Disabled
Thanks that helped.
 
  


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
[SOLVED] Problem trying to run java program rmknox Linux - Software 14 05-10-2011 10:07 AM
Simple C++ Program: Program Compiles But Won't Run (Segmentation Fault) violagirl23 Programming 3 01-09-2008 12:09 AM
sudo problem. Want permission to run a sbin program without a password inverted.gravity Linux - Software 11 03-21-2007 03:34 PM
Viewing program messages when program isn't run from command line? Locura Linux - Software 1 09-27-2003 08:19 AM

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

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