Cpt Chuckles
New Member
henlo all
I am having a bit of trouble getting gcc to run via make. I discovered this problem while trying to install a ruby gem, which invokes make to build the extensions, and got the "make: gcc: Permission denied" error. I have since experimented with a C++ hello world project and then a C hello world project, only to find that make seems to be incapable of invoking gcc, even when it is perfectly able to invoke g++. very odd. here is what I am getting:
In this snippet you can see that i am perfectly able to invoke the gcc command myself, while make cannot.
In the following snippet, observe that make can invoke g++ without issue:
Here are the permissions on the relevant directories and binaries (tell me if you need more):
I really don't understand why make is having trouble invoking gcc. I've been asking around in IRC channels about this and I haven't got a solution yet.
EDIT: I have found a way to make it work. I have changed "gcc" in my makefile to "/usr/bin/gcc" and now it runs just fine.... It seems that having `which gcc` return "/usr/sbin/gcc" is some kind of problem. I'm running Artix linux, wherein /usr/sbin is a symlink to /usr/bin. Here are the permissions:
I have no idea why /usr/sbin/gcc is causing trouble to make, but it is. It's also something that's going to continue being a problem for me because until `which gcc` points to /usr/bin/gcc, i will remain unable to install ruby gems, because their makefiles are calling gcc and not explicitly /usr/bin/gcc. :s
EDIT 2: It seems that calling "/usr/sbin/gcc" from within the makefile also works. Now I have no idea what's going on. Why do i need to call the full path for it to work? :c
I am having a bit of trouble getting gcc to run via make. I discovered this problem while trying to install a ruby gem, which invokes make to build the extensions, and got the "make: gcc: Permission denied" error. I have since experimented with a C++ hello world project and then a C hello world project, only to find that make seems to be incapable of invoking gcc, even when it is perfectly able to invoke g++. very odd. here is what I am getting:
Bash:
[grendel@artix ~/docs/c/hello_world]
$ ls
main.c makefile
[grendel@artix ~/docs/c/hello_world]
$ cat main.c
#include <stdio.h>
int main(int argc, char* argv[]) {
printf("hello world\n");
return 0;
}
[grendel@artix ~/docs/c/hello_world]
$ cat makefile
build:
@echo "compiling C program with GCC, not even G++"
gcc -o thing main.c
[grendel@artix ~/docs/c/hello_world]
$ make build
compiling C program with GCC, not even G++
gcc -o thing main.c
make: gcc: Permission denied
make: *** [makefile:3: build] Error 127
[grendel@artix ~/docs/c/hello_world]
$ sudo make build
compiling C program with GCC, not even G++
gcc -o thing main.c
make: gcc: Permission denied
make: *** [makefile:3: build] Error 127
[grendel@artix ~/docs/c/hello_world]
$ gcc -o thing main.c
[grendel@artix ~/docs/c/hello_world]
$ ls
main.c makefile thing*
[grendel@artix ~/docs/c/hello_world]
$ echo wtf
wtf
[grendel@artix ~/docs/c/hello_world]
$
In the following snippet, observe that make can invoke g++ without issue:
Bash:
[grendel@artix ~/docs/c/hello_world]
$ cd ../../cpp/hello_world/
[grendel@artix ~/docs/cpp/hello_world]
$ rm thing
[grendel@artix ~/docs/cpp/hello_world]
$ ls
main.cpp makefile
[grendel@artix ~/docs/cpp/hello_world]
$ cat makefile
build:
@echo "compiling"
g++ -o thing main.cpp -std=c++17
[grendel@artix ~/docs/cpp/hello_world]
$ make build
compiling
g++ -o thing main.cpp -std=c++17
[grendel@artix ~/docs/cpp/hello_world]
$ ls
main.cpp makefile thing*
[grendel@artix ~/docs/cpp/hello_world]
$ echo "g++ works"
g++ works
[grendel@artix ~/docs/cpp/hello_world]
$
Here are the permissions on the relevant directories and binaries (tell me if you need more):
Bash:
[grendel@artix ~/docs/c/hello_world]
$ ls -ld ~ ~/docs/c/hello_world /usr/sbin/gcc /usr/sbin/make / /usr
drwxr-xr-x 17 root root 4096 Dec 23 17:04 //
drwx------ 28 grendel grendel 4096 Mar 17 17:55 /home/grendel/
drwxr-xr-x 2 grendel grendel 4096 Mar 17 17:58 /home/grendel/docs/c/hello_world/
drwxr-xr-x 9 root root 4096 Dec 23 17:05 /usr/
-rwxr-xr-x 3 root root 1133432 Mar 14 16:05 /usr/sbin/gcc*
-rwxr-xr-x 1 root root 243200 Feb 3 08:46 /usr/sbin/make*
I really don't understand why make is having trouble invoking gcc. I've been asking around in IRC channels about this and I haven't got a solution yet.
EDIT: I have found a way to make it work. I have changed "gcc" in my makefile to "/usr/bin/gcc" and now it runs just fine.... It seems that having `which gcc` return "/usr/sbin/gcc" is some kind of problem. I'm running Artix linux, wherein /usr/sbin is a symlink to /usr/bin. Here are the permissions:
Bash:
[grendel@artix ~/docs/c/hello_world]
$ ls -ld /usr/*bin /usr/*bin/gcc*
drwxr-xr-x 5 root root 77824 Mar 17 15:51 /usr/bin/
lrwxrwxrwx 1 root root 3 Nov 13 14:01 /usr/sbin -> bin/
-rwxr-xr-x 3 root root 1133432 Mar 14 16:05 /usr/bin/gcc*
-rwxr-xr-x 2 root root 35312 Mar 14 16:05 /usr/bin/gcc-ar*
-rwxr-xr-x 2 root root 35312 Mar 14 16:05 /usr/bin/gcc-nm*
-rwxr-xr-x 2 root root 35312 Mar 14 16:05 /usr/bin/gcc-ranlib*
-rwxr-xr-x 3 root root 1133432 Mar 14 16:05 /usr/sbin/gcc*
-rwxr-xr-x 2 root root 35312 Mar 14 16:05 /usr/sbin/gcc-ar*
-rwxr-xr-x 2 root root 35312 Mar 14 16:05 /usr/sbin/gcc-nm*
-rwxr-xr-x 2 root root 35312 Mar 14 16:05 /usr/sbin/gcc-ranlib*
I have no idea why /usr/sbin/gcc is causing trouble to make, but it is. It's also something that's going to continue being a problem for me because until `which gcc` points to /usr/bin/gcc, i will remain unable to install ruby gems, because their makefiles are calling gcc and not explicitly /usr/bin/gcc. :s
EDIT 2: It seems that calling "/usr/sbin/gcc" from within the makefile also works. Now I have no idea what's going on. Why do i need to call the full path for it to work? :c
Last edited: