0
votes

i'm working on a project programmed in c++, and don't ask why, i have to work on linux.

I've installed eclipse 3.7.2, i assume the latest version up to date.

In my ignorance, i started to work on the project when i realized i couldn't even compile. So i started with a simple hello world to see whats up. Created new project, done, new source file cpp, done, code a hello world, done.

#include <iostream>

using namespace std;

int main() {

cout << "hello world :( ....." << endl;
return 0;

}

This is the code. Yet when i to run it after it's compiled i get this error:

/bin/bash: /media/....../myprojectname: Permission denied
/bin/bash: line 0: exec: /media/....../myprojectname/Debug/myprojectname: cannot execute: Permission denied

I've already made research on this, but I'm not really experienced, more like college knowledge, but all the threads I read about it suggested trying to compile with makefiles (which i know nothing about it, and eclipse is there for it) and even though, that didn't fixed it, for what I read.

I've never had a problem doing this on eclipse for windows, and this is my first try on linux. For what I've also read, it seems it has to do with linux permissions... but then again not my greatest strength.

I guess my question is, how can I code a simple hello world using c++ and using as editor eclipse, and then make the program to just run.

Thanks in advance!

2
Could your executable lack x permissions? Try chmod +x yourexe. - user703016
Just out of curiosity, are you building under /media for a reason? That directory normally requires superuser permissions. - juanchopanza
What is your workspace directory? (The one you select when eclipse is launched) As pointed by @juanchopanza /media is owned by root. Also what kind of project did you select? - another.anon.coward
I just tried that, nothing changed. May i add that, when you right click the exe and you check for permissions, the "allow executing file as program" is unclicked, and when you click it, it automatically unclicks, weird huh? - Ale
My workspace is indeed inside media. The kind of project i selected is c++ project. - Ale

2 Answers

4
votes

That file system is probably mount(8)-ed with noexec option, so no matter what permission bits you set on your executable, you can't run it.

0
votes

Hi, I had the same problem, but in my case I was installing ubuntu with windows.

My problem was that the drive which contained the workspace for eclipse gave me a permission denied message.

This was because it was an NTFS drive.

I solved it by converting it into ext3 ... and later, if you want, it's possible to convert it from ext3 to ext4.

The steps:

  1. Check what's the complete specific name of the drive:

    # sudo blkid

    /dev/sd7 mydrive 105GB

  2. change the FileSystem & drive's label:

    # mkfs.ext3 -L mydrive /dev/sdaX (use -L for volume label)

  3. [Optional] Convert it to ext4 using tune2fs.

I hope that helps :)