.exe file created by c programming through gcc compiler isn't executing.

Asked by Dharmesh Patadiya on 2012-08-17

I am new in linux. I am using ubuntu 12.04 LTS. I am writing c program which contains math. I am creating executable file through the command:

gcc -o filename.exe filename.c -lm

this will create a filename.exe file. I can now execute it through terminal command:


I have laptop. It has ubuntu 11.04. These sequence of commands works well in my laptop. But if same file I copy in my desktop, which is ubuntu 12.04 LTS, and then runs then it doesn't work. I searched in internet. One solution I got is:

chmod -R 777 /media/partition where partition is ntfs type.

This will change the partition to rw mode. But this is also not solving my problem.

Please help me.

Patadiya Dharmesh M.

Question information

English Edit question
Ubuntu wine Edit question
No assignee Edit question
Solved by:
Dharmesh Patadiya
Last query:
Last reply:
Thomas Krüger (thkrueger) said : #1

You have done some typical new user mistakes.
The first one is just an convention thing: on Linux executable files are not named .exe. This is a windows only thing. UNIX-like systemw do not care much about the file extension.
The second thing is about file systems. NTFS has a permission system, but it is not directly compatible with the UNIX permission system. You can not set the executable bit for specific files. You can only set it on a global level. It is recommended that you programm, compile and run UNIX code from a file system that is Linux compatible. You home folder for example should be a good choice.

Dharmesh Patadiya (dmp-mech) said : #2

I understand this. Previously I used to write programs in file system only. But the problem in that case was my OS got crashed. For that I need to format the previous OS and reinstall the new. If I store data in file system( or home folder) then it will be formatted while reinstalling. And also if the problem is of home folder and NTFS then same file could not have executed in my laptop's NTFS partition.

Thomas Krüger (thkrueger) said : #3

You can recover your files from the system partition with an Ubuntu (or any other) live CD if the operating system does not run anymore. Also your system will not safe you if the harddrive fails.

What you really need is a backup strategy, maybe a revision control system. git, for example, allows you to track your source code changes and push them to an external location (maybe a server or an external media).
Alternativly you could use an online sync service like Ubuntu One (built-in) or Dropbox.

And to come back to your initial question: There is no simple way to set the execute bit on an NTFS partition on a per file level.
Non-simple ways would involve tricky things like stacked file systems and even a Libnux pro would have a lot of work setting this up.

New to Ubuntu be sure to read this useful manual http://ubuntu-manual.org/

Dharmesh Patadiya (dmp-mech) said : #5

I solved the problem. I followed the following link:


Thank you for reply.