Codeblock won't run my program, I get sh: filepath: Permission Denied Ubuntu 10.04

18,599

Solution 1

Correctly set up a project in code::blocks. (I will walk you through setting up a simple Console Application)

Frist Select "Console Application"

Then Select C or C++

Then Set your project Title and location

And then select the default compiler (GNU GCC Compiler)

Finally some template "hello world" code should appear, press F9 to compile and run.

For other future examples Just check out the Code::Blocks User manual: http://www.codeblocks.org/user-manual or Google

note This came from our conversation where we discovered he misc-onfigured Code::Blocks

Solution 2

If it's an imported project (or you just copied/downloaded it to your hard drive) try rebuilding it.

Start Codeblocks IDE => Open the project => Right click => Rebuild => Click 'Yes' on the prompt.

This happens every time I copy my old projects from USB to HDD after clean system install or system update.

I hope this is the case with you as well, because I tried a lot of 'permission related' solutions first time I encountered this and they didn't get me far.

Best of luck and I'm looking forward to your feedback.

Solution 3

Not sure what OS you're using.. but if it's Ubuntu, I use CodeBlocks on Ubuntu and have had this exact problem MANY times.

The "user" option (in etc/fstab) by default sets up "noexec".

so in /etc/fstab just add ,exec after user. i.e. mine looks like this: /dev/sda6 /media/DATA vfat uid=kenny,gid=kenny,users,user,exec 0 0 Though, the spacingis a bit off... but you get the idea.

This may be a bit tough if you're new to linux. So google about the fstab file. Also, make back up before you try to edit anything (sudo cp /etc/fstab /etc/fstab.backup)

sudo gedit /etc/fstab will open up the fstab file so you can see if the filesystem has exec in it

Solution 4

I just clicked the Abort button adjacent to Build and Run and it gave this error

permission denied

I solved the problem by going to Build > Select Target > Release

Solution 5

it may be because the directory/file is not given execute permission you can fix this by using command on terminal sudo chmod +x [path to your directory or path to individual file]

like in my case all my codes are in /home/nikhil/code so sudo chmod +x /home/nikhil/code

it worked in my case

Share:
18,599
samuraiseoul
Author by

samuraiseoul

Updated on June 13, 2022

Comments

  • samuraiseoul
    samuraiseoul almost 2 years

    So I'm trying to get this program to run, but code blocks throws me this error when I try to run it.

    sh: : Permission Denied.

    I'm pretty much 100% noob, so links to figure out how to fix it or educational stuff on the issue would be great for learning I think, but any ideas would be helpful really. :)

  • samuraiseoul
    samuraiseoul over 13 years
    So I looked into it, I don't have this line you're talking about uid=kenny,gid=kenny,users,user,exec 0 0 On the articles i read about it, all of theirs look more like mine, Which is like this proc /proc proc nodev,noexec,nosuid 0 0 I found the noexec you said, but it was followed with something different and I want to make sure this is correct line before I edit it. Also, It didn't have many of the entries you listed such as users, user stuff like that.
  • samuraiseoul
    samuraiseoul over 13 years
    Also as stated above it was Ubuntu 10.04
  • Kenny Cason
    Kenny Cason over 13 years
    copy yours exactly as is. if its , noexec 0 0 just change it to exec 0 0
  • samuraiseoul
    samuraiseoul over 13 years
    I got proc /proc proc nodev,noexec,nosuid 0 0 So I guess the big thing is that I got nosuid after mine?
  • Kenny Cason
    Kenny Cason over 13 years
    I really don't know. But back up your fstab file (like i said above) and change noexec to exec. Save the file, and restart.
  • Kenny Cason
    Kenny Cason over 13 years
    Oh and if we break it i'll give you my IM info and we'll fix it :)
  • samuraiseoul
    samuraiseoul over 13 years
    It didn't break, but it also didn't fix the problem, same problem as before.
  • Kenny Cason
    Kenny Cason over 13 years
    yeah.. i'm not surprised as i have the same settings as you. for mounting the primary partition.. but that was what did the trick for me on other partitions that I tried executing code from..
  • Kenny Cason
    Kenny Cason over 13 years
    so what happens if you just type g++ main.cpp then ./a.out. does the./a.out error? (i'm assuming your just trying to get one simple file, like "main.cpp" running)
  • Kenny Cason
    Kenny Cason over 13 years
    Then the only thing i can guess is that you set your project up wrong. create a new project(Console Application) then press F9 and tell me what happens.
  • Jahanzeb Khan
    Jahanzeb Khan almost 10 years
    It works if I put the project on ubuntu, but if I want the project on my usb it gives permission denied. I need it to work at school too on windows pcs. please help!
  • Khushal Dave
    Khushal Dave almost 10 years
    Thanks @Nikhil... That helped.