Code: Select all
sudo ./ProgramNameCode: Select all
sudo chmod +x ProgramNameCode: Select all
#include <stdio.h>
int main()
{
printf( "Hello Raspberry World\n" );
return( 0 );
}
Code: Select all
pi@raspi3 /tmp $ gcc -o hello hello.c
Code: Select all
pi@raspi3 /tmp $ ./hello
Hello Raspberry World
Code: Select all
pi@raspi3 /tmp $ ls -l hello
-rwxr-xr-x 1 pi pi 5732 Feb 10 09:17 hello
Code: Select all
pi@raspi3 ~ $ sudo mount -o fmask=0,uid=pi /dev/sda1 /media
pi@raspi3 ~ $ cp /tmp/hello /media
pi@raspi3 ~ $ ls -l /media/hello
-rwxrwxrwx 1 pi root 5732 Feb 10 14:03 /media/hello
pi@raspi3 ~ $ /media/hello
Hello Raspberry World
I didn't notice what was actually in the hello.c file. Did you post that? Did you delete and recreate the hello file using this code? Something is weird somewhere and it seems to go beyond permissions.PabloMack wrote:pi@raspberrypi:~Apps $ ./hello
Inconsistency detected by ld.so: dl-lookup.c: 871 _dl_setup_hash: Assertion `(bitmask_nwords & (bitmask nwords - 1)) == 0' failed!
pi@raspberrypi:~Apps $
I also did this and it didn't solve the problem (but it didn't complain):
pi@raspberrypi:~Apps $ sudo chmod +x hello
Apparently the file was already marked as executable by the linker which is what I would expect.
That error message looks like what you'd get if you try running ld to make an executable and pass it an executable rather than object files and libraries. And having hello.a seems strange, .a is by convention a static library, not something you'd expect being used in a small single file program.PabloMack wrote:This is what I did just now:
pi@raspberrypi:~Apps $ chmod 755 hello
pi@raspberrypi:~Apps $ ls -l
-rw-r--r-- 1 pi pi 0 Feb 28 16:09 save.txt
-rwxr-xr-x 1 pi pi 5976 Feb 28 16:00 hello
-rw------- 1 pi pi 5832 Feb 28 16:00 hello.a
-rw------- 1 pi pi 106 Feb 28 16:00 hello.c
pi@raspberrypi:~Apps $ ./hello
Inconsistency detected by ld.so: dl-lookup.c: 871 _dl_setup_hash: Assertion `(bitmask_nwords & (bitmask nwords - 1)) == 0' failed!
pi@raspberrypi:~Apps $
Code: Select all
gcc -c -o hello.o hello.cWhich modern compiler does that???PabloMack wrote:Most compilers will compile to object then you have to use the linker.
Code: Select all
gcc -o hello hello.cCode: Select all
./hello