Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12th July 2011, 03:51 AM
surajms Offline
Registered User
 
Join Date: May 2011
Posts: 2
linuxfirefox
Exclamation C program execution using gcc.

hi guys i m using gcc to compile certain programs.they get successfully compiled but fail to execute.Here is a sample code and the error
[tommy@tommy cprog]$ vi test.c

#include<stdio.h>
int main()
{
printf("hello"); /
return 0;

}


[tommy@tommy cprog]$ gcc test.c -o test.out
[tommy@tommy cprog]$ ./test.out
bash: ./test.out: Permission denied

a similar problem arises with codeblocks for the same program
the error is the same even when it is just main() and absence of return 0;
the problem exists also on c++.
i m using Fedora 15
Reply With Quote
  #2  
Old 12th July 2011, 04:54 AM
MAmundson Offline
Registered User
 
Join Date: Jul 2009
Posts: 4
linuxfirefox
Re: C program execution using gcc.

It worked for me. It looks like your file permissions are not correct. Check them by trying:

Code:
[mark@localhost ~]$ ls -al test.out
-rwxrwxr-x. 1 mark mark 4740 Jul 11 22:47 test.out
If you do not see an "x" as a file permission, try:

Code:
chmod 775 test.out
Reply With Quote
  #3  
Old 12th July 2011, 09:45 AM
markkuk Offline
Registered User
 
Join Date: Apr 2005
Location: Finland
Posts: 5,076
windows_xp_2003firefox
Re: C program execution using gcc.

Fedora mounts removable storage (USB-sticks, external hard drives, etc.) with the "noexec" option by default. If your "cprog" directory is on such a device, you can't run your compiled programs. Move your software projects to a directory under your $HOME.
Reply With Quote
  #4  
Old 12th July 2011, 09:47 AM
shakthi Offline
Registered User
 
Join Date: Jul 2011
Posts: 3
windows_xp_2003ie
Re: C program execution using gcc.

try sudo gcc if u ve permission..
Reply With Quote
  #5  
Old 12th July 2011, 12:33 PM
surajms Offline
Registered User
 
Join Date: May 2011
Posts: 2
linuxfirefox
Re: C program execution using gcc.

thank you so much guys... i tried out all three suggestions...
it seems i cant execute any program which is in a removable device which happens to be the partition of my hdd.... the program worked when i executed it from the home folder...
the chmod command did not seem to affect the file permissions...

[ tommy@tommy cprog]$ ls -al test.out
-rw-------. 1 tommy tommy 4740 Jul 11 20:32 test.out
[tommy@tommy cprog]$ chmod 775 test.out
[tommy@tommy cprog]$ ls -al test.out
-rw-------. 1 tommy tommy 4740 Jul 11 20:32 test.out

is it possible to toggle the noexec option for such files
Reply With Quote
  #6  
Old 12th July 2011, 01:22 PM
scoon's Avatar
scoon Offline
Registered User
 
Join Date: Apr 2005
Location: philadelphia, pa
Posts: 172
windows_xp_2003firefox
Re: C program execution using gcc.

Hey there,

remount with the exec option.

hth
Reply With Quote
Reply

Tags
execution, gcc, program

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
file execution aquarianutsav Linux Chat 1 1st February 2010 03:29 PM
vsftp program execution problem umituzun84 Servers & Networking 0 10th June 2009 07:35 AM
tracing a program execution larryt Using Fedora 4 5th September 2007 08:12 PM
Measure program execution time stevewillis Using Fedora 9 7th August 2005 08:18 PM
Help with execution code ianmac Using Fedora 3 14th April 2005 11:20 PM


Current GMT-time: 20:00 (Wednesday, 22-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat