OK, I sent an email to the R-package-devel group regarding to this issue. And the following is the reply, and it does work!

Please adapt your BINPREF variable in R/etc/$Arch/Makeconf files appropriately to point to the coresponding compiler for each architecture - this is new with the new toolchain we use with R >= 3.3.0.

Answer from Zhe Liu on Stack Overflow
🌐
Stack Overflow
stackoverflow.com › questions › 72319110 › how-to-fix-bin-sh-gcc-11-3-0-1-command-not-found
r - How to fix /bin/sh: gcc-11.3.0_1: command not found - Stack Overflow
Running brew list --versions gcc, return gcc 11.3.0_1, ... Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include/c++/4.2.1 Apple clang version 13.0.0 (clang-1300.0.27.3) Target: arm64-apple-darwin21.3.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Discussions

Unable to find gcc installing rstan on Windows 10
I have been struggling for a day to get Rstan installed and working on my Windows 10 machine and I cannot figure out what isn’t working, even though my problem seems to be similar to some I’ve found on this forum by googling. I think it has something to do with my path and where R is looking ... More on discourse.mc-stan.org
🌐 discourse.mc-stan.org
1
0
October 1, 2020
windows - R CMD check not looking for gcc in Rtools directory - Stack Overflow
R has been installing packages just fine, but suddenly – I can't think of anything relevant that I modified or uninstalled – it can't find gcc when I run R CMD check in the command prompt, or devt... More on stackoverflow.com
🌐 stackoverflow.com
/bin/sh: gcc: command not found

base-devel installed? pacman -S base-devel

More on reddit.com
🌐 r/ManjaroLinux
2
3
January 23, 2019
gcc: command not found?
I'm experiencing a very similar problem on a factory-new machine. M3 macOS Sonoma 14.7.1. Here's the topic I created on discourse: https://discourse.nixos.org/t/error-tool-gcc-not-found-on-macos-14-7-1-with-m3/56238 More on reddit.com
🌐 r/Nix
1
3
September 30, 2023
🌐
Stack Overflow
stackoverflow.com › questions › 71025101 › r-install-packages-unable-to-find-gcc
R install.packages unable to find gcc - Stack Overflow
February 7, 2022 - I am unsure what the root cause of this issue was, but I was able to solve it by editing both Makeconf files at C:\Users\<username>\Documents\R\R-4.1.2\etc\i386 and C:\Users\<username>\Documents\R\R-4.1.2\etc\x64.
🌐
ETH Zurich
stat.ethz.ch › pipermail › r-devel › 2022-November › 082150.html
[Rd] RTools40 Error - sh: line 1: gcc: command not found
** package 'jsonlite' successfully unpacked and MD5 sums checked ** using staged installation ** libs gcc -I"C:/Users/XXXXXXX/AppData/Local/Programs/R/R-42~1.2/include" -DNDEBUG -Iyajl/api -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include" -D__USE_MINGW_ANSI_STDIO -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c base64.c -o base64.o sh: line 1: gcc: command not found make: *** [C:/Users/ XXXXXXX /AppData/Local/Programs/R/R-42~1.2/etc/x64/Makeconf:253: base64.o] Error 127 ERROR: compilation failed for package 'jsonlite' * removing 'C:/Users/375492/AppData/Local/Programs/R/R-4.2.2
🌐
GitHub
github.com › krlmlr › r-appveyor › issues › 61
gcc not found with Rtools installed? · Issue #61 · krlmlr/r-appveyor
So I guess I am doing something rather silly, but I can't see what (I find it interesting that it is looking for gcc under 'd:', when tools were installed under 'c:', but maybe that is OK). My appveyor.yml is as follows (I am dealing with a package in a subdirectory): ## https://github.com/krlmlr/r-appveyor/issues/34 ## http://stackoverflow.com/questions/33411765/check-multiple-subdirectories-using-appveyor environment: TEST_DIR: OncoSimulR R_VERSION: devel USE_RTOOLS: true before_build: - cp ../travis-tool.sh travis-tool.sh - cp travis-tool.sh.cmd %TEST_DIR%\travis-tool.sh.cmd - cd %TEST_DIR% - bash -c "echo '^travis-tool\.sh\.cmd$' >> .Rbuildignore" build_script: - travis-tool.sh install_bioc_deps test_script: - travis-tool.sh run_tests
Author   krlmlr
🌐
Bioconductor
support.bioconductor.org › p › 9148467
packages not installing from sources the package which needs compilation
December 19, 2022 - ** using staged installation ** libs gcc -I"C:/R/R-42~1.2/include" -DNDEBUG -I'C:/R/R-4.2.2/library/S4Vectors/include' -I"c:/rtools42/x86_64-w64-mingw32.static.posix/include" -O2 -Wall -std=gnu99 -mfpmath=sse -msse2 -mstackrealign -c R_init_DelayedArray.c -o R_init_DelayedArray.o sh: line 1: gcc: command not found make: *** [C:/R/R-42~1.2/etc/x64/Makeconf:253: R_init_DelayedArray.o] Error 127 ERROR: compilation failed for package 'DelayedArray' * removing 'C:/R/R-4.2.2/library/DelayedArray' * restoring previous 'C:/R/R-4.2.2/library/DelayedArray' * installing *source* package 'GenomicRanges' ...
🌐
Stan Forums
discourse.mc-stan.org › interfaces › rstan
Unable to find gcc installing rstan on Windows 10 - RStan - The Stan Forums
October 1, 2020 - I have been struggling for a day to get Rstan installed and working on my Windows 10 machine and I cannot figure out what isn’t working, even though my problem seems to be similar to some I’ve found on this forum by googling. I think it has something to do with my path and where R is looking ...
Find elsewhere
🌐
Delft Stack
delftstack.com › home › howto › linux › solve gcc command not found error in bash
How to Solve GCC Command Not Found Error in Bash | Delft Stack
March 11, 2025 - If you have installed GCC but still see the “command not found” error, the issue might be related to your system’s PATH variable. The PATH variable tells your system where to look for executable files.
🌐
Reddit
reddit.com › r/manjarolinux › /bin/sh: gcc: command not found
r/ManjaroLinux on Reddit: /bin/sh: gcc: command not found
January 23, 2019 -

I'm also getting the same for cc and pkg-config. I was trying to compile a kernel and install something from AUR. Searching around didn't give me any answers that I felt comfortable following as I couldn't establish that the contexts in which the issues occurred were similar enough. Any help appreciated.`

🌐
LinuxQuestions.org
linuxquestions.org › questions › linux-from-scratch-13 › make-gcc-command-not-found-948516
make: gcc: Command not found
Hello, My first question. I have been installing LFS 7.1 on my system during the last 3 days. I am reading the book to the letter. Everything has gone
🌐
Reddit
reddit.com › r/nix › gcc: command not found?
r/Nix on Reddit: gcc: command not found?
September 30, 2023 -

I've got source that builds fine on my computer (M1 mac) with make all; it's all C under there, afaik. I'm trying to wrap it in a flake and get nix to build it. nix build on my flake, however, fails with line 1: gcc: command not found.

I was under the impression, though, that gcc was always available for builds. When I go into nix develop and which gcc, I get /usr/bin/gcc, not some massive nix hash. Is this perhaps the problem, or an indication of the problem?

My flake is here; it's pretty much the same as the nixpkgs default.nix here, except that the source url and platforms are changed. Perhaps this is a linux/mac thing?

Top answer
1 of 1
3

You get an obscure error here because you included a file Makefile.win.

But the semantics of make, if such a file is found, it will be used ... which is not what you want here. R builds its own Makefile.win and you are supposed to only supply a snippet to be included -- which must be called Makevars.win.

That is rule number one. Rules number two is to not included all the material you would include in a Makefile -- as you would clobber what R already brings to the table. All this is in Writing R Extensions but could of course be clearer.

My pragmatic suggestion: take a package you know and like which has a working R build in win-builder, and modify it. You can test locally should you have access to an R system with Rtools etc pp.


Edit from OP:

I needed to compile an executable which relied on several libraries. The library codes were in src/libs and the executable's code was in src/apps. I ensured that running make within each subdirectory worked and set src/apps/Makefile to use relative paths to pull in the results of src/libs. The only problem then, was getting the whole chain running. To do so, I created a file src/Makevars.win which had the following structure:

.PHONY: all myprogram sublib1 sublib2

all: sublib1 sublib2 myprogram

myprogram: sublib1 sublib2
  @(cd apps/myprogram && $(MAKE) CXX="$(CXX)" CC="$(CC)" CFLAGS="$(CFLAGS) $(CPICFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)")

sublib1:
  @(cd lib/sublib1    && $(MAKE) CXX="$(CXX)" CC="$(CC)" CFLAGS="$(CFLAGS) $(CPICFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)")

sublib2:
  @(cd lib/sublib2    && $(MAKE) CXX="$(CXX)" CC="$(CC)" CFLAGS="$(CFLAGS) $(CPICFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)")

As I understand it, Makevars.win gets embedded in a dynamically generated Makefile that R produces. So, $(CC) is actually referencing this hidden code.

(There are probably more clever ways to do this.)

🌐
Narkive
cygwin.cygwin.narkive.com › NkaxgDH1 › gcc-command-not-found
gcc command not found
$x done Then check in your bin dir for all the appropriate names and links. cheers, DaveK I ran your for loop command and got this: bash: /usr/sbin/fix-libtool-scripts-for-latest-gcc-runtimes.sh: Permission denied So I changed the perms of the script to chmod 744 and then re-ran the for loop. It successfuly completed and I now see the appropriate sym links in /usr/bin. This makes me wonder if there are other post-install scripts that did not successfully execute due to incorrect permissions on files.
🌐
Reddit
reddit.com › r/olkb › qmk error avr-gcc: command not found
r/olkb on Reddit: QMK Error avr-gcc: command not found
December 30, 2021 -

I tried to compile a default key map and get the error message "sh: avr-gcc: comand not found".

When using make iris/rev2:default following error message appeared.

$ make iris/rev2:default
QMK Firmware 0.6.246
Making iris/rev2 with keymap default

/bin/sh: avr-gcc: command not found
sh: avr-gcc: command not found
sh: avr-gcc: command not found
make[1]: *** [tmk_core/rules.mk:256: gccversion] Error 127
Make finished with errors
make: *** [Makefile:544: iris/rev2:default] Error 1

I use windows10 and Msys2 64bit with "MSYS2 MinGW 64-bit".

I tried following to solve this error, but didn't solve the problem.

reinstall msys2 and qmk

rerun util/qmk_install.sh

run echo 'export PATH="/usr/local/opt/avr-gcc@7/bin:$PATH"' >> ~/.bash_profile and restart terminal

run pacman -S avr-gcc and "Error target not found: avr-gcc" appeared.

This is my first time of building key map, then I'm a beginner.

Any information would greatly help.

🌐
Prodigy
support.prodi.gy › t › installation-error-gcc-command-not-found › 551
Installation error: gcc command not found - solved - Prodigy Support
May 19, 2018 - I am installing Prodigy on a fresh RHEL (release 7.4) without SUDO privileges (i.e. I cannot install gcc via sudo yum install “Development Tools” Thus, I installed the latest Miniconda3 along with: conda install gxx_linux-64 followed by: export CC=/app/home/miniconda3/bin/x86_64-conda_cos6-linux-gnu-gcc export CXX=/app/home/miniconda3/bin/x86_64-conda_cos6-linux-gnu-g++ alias gcc=$CC alias g++=$CXX pip install prodigy-1.4.2-cp35.cp36-cp35m.cp36m-linux_x86_64.whl This results in the followin...