I've been trying for long time to solve an apparent problem with compiling simple C code into an executable. I've made a simple C code that should print the size in bytes of a double to a .txt file via makefile. It doesn't compile an executable on my system, but works flawlessly on my university's Linux server. I'm running Linux Mint 17.1 64bit with cc version "cc (Ubuntu 4.8.2-19ubuntu1) 4.8.2". My test C-code is in the file temp.c:
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
printf("sizeof(double) returns %lu\n", sizeof(double));
return 0;
}
My makefile looks like this:
CFLAGS = -Wall -m64 -std=c99
all: A;
A:out.txt
out.txt: temp;
./temp > out.txt
chmod go+r
temp: temp.o
clean:
rm temp.o
rm temp out.txt
Typing cc -dumpversion while logged in on my universitys linux server returns "cc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-50)", and typing "cc-dumpmachine" returns "x86_64-redhat-linux"
I don't understand why make all on my machine returns
cc -Wall -m64 -std=c99 -c -o temp.o temp.c
cc temp.o -o temp
./temp > out.txt
/bin/sh: 1: ./temp: Permission denied
make: *** [out.txt] Error 126
Additional info:
temp.c is in a folder on an NTFS partition which is auto mounted at boot with option exec. Compiling temp.c without -c from the shell instead of makefile doesn't do the job. Anytime I try to run ./temp or whatever the outcome of the compiling returns the "Permission denied" statement.
As mentioned by the OP in the comments, the executable file is in an NTFS formatted partition. By default, Ubuntu (and hence I would assume Mint) does not mount NTFS in such a way that files can be executed.
Quoting from an answer on AskUbuntu by @Sebastian (with modifications), the following change is to be made on /etc/fstab:
The solution was to write the
execmount option after theusersoption. That's because theusersoption implicitly activate thenoexecoption, so you have to explicitly specifyexec.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With