basic linux programming/compiling question (permissions error)
Hey there,
I hate to ask such a seeming dumb question, but I can't seem to figure this one out. I am definitely new to C and programming in general, though I have been doing a bit on my ibook laptop over the past few months. In osx I usually write the code (I'm only using C right now) in xcode, then compile the c file from a terminal. I use these commands to compile and run the program. Code:
cc xxx.c Code:
cc hello.c What am I doing wrong? Thanks |
Interesting. Please show us how the permissions and ownership looks after you compile. Run:
ls -l a.out and post the result. |
Not sure... is 'cc' the same as 'gcc' on your machine? (It is on my Gentoo box, but you never know.) Try using 'gcc' instead of 'cc', to see if that makes a difference. I'd also suggest giving an output filename, instead of using the default a.out, like so:
Code:
gcc -Wall hello.c -o hello No clue if these things will help, but it's all I can think of. I hope it helps! |
ok so to help you guys out and give a little more information...
I tried all of these things, but I will do it all again to try and paint the complete picture. Code:
bash-2.05b# ls |
It may not be a compiler/program problem at all.
My guess: you're working in a partition that was mounted as noexec in fstab. |
I read your reply and immediately felt stupid...one of those duh moments...
I am trying to do all of this on my home partition, so I then double checked fstab: Code:
/dev/hda6 /home reiserfs defaults,noatime,user,notail 0 3 so is my /home partition mounted noexec by default? I appreciate your time, I am certainly needed another pair of eyes. |
Just two doubts, I don't think they'll matter, but why you've in the 6th parameter 3 when the choices (if i'm not wrong) are 0,1 or 2, and why you allow user to mount/umount the /home directory? (I think this doesn't matter because it's mounted by root, and as long as root don't umount it other users can't)
|
Now that you mention it, I think you are right in that it really doesn't matter; a regular won't need to unmount or mount it the /home partition. I am the only user at the computer so I set it up that my regular user would have access to things like that, though in this case it really doesn't matter.
So I copied the executable to /root/ and ran it just fine. Any ideas? Is /home/ mounted noexec despite my fstab options? |
I don't see anything in those options that would prevent execution, but I don't have much experience with reiserfs (translation: none). I might check your startup scripts to see if it gets remounted later with different options, and to make sure no other partition is being mounted "on top" of it. That's really just guessing though.
If you cat /etc/mtab, it might list what options each partition was mounted with. It seems to list them on my system (LFS), but the point of LFS is to be unique... yours could very well be different. |
[Edit] Stupid suggestion as you were trying to run it as root on your home folder.
Well, another posibility is with your user... can you run other programs inside your home directory? Try creating another account and trying there. |
from cat /etc/mtab:
Code:
/dev/hda6 /home reiserfs rw,noexec,nosuid,nodev,noatime,notail 0 0 here is the relevent section of dmesg, I don't know if this will help: Code:
ReiserFS: hda5: found reiserfs format "3.6" with standard journal |
I am not doing my coding work on a "data" partition mounted exec. I guess this has become a mounting problem. If people would like I can post this issue in the relevent forum and spare getting off topic here. Though it doesn't look like it is a big problem, just a small detail I am overlooking somewhere.
I thank all of you who helped. :D |
All times are GMT -5. The time now is 09:55 PM. |