Error : sh1 : avr-g++ not found

I am not able to build and upload my code to arduino nano wth Atmega328p. When I run “pio run” it says avr-g++ not found. That happens with toolchain-atmelavr @ 1.50400 version. Then I manually installed the updated toolchain using toolchain-atmelavr-linux_armv6l-1.70300.191015.tar.gz from PlatformIO Storage website but it is uninstalled automatically when I run “pio run” and the 1.504xxx version is installed. Then I get the error saying the avr-g++ file not found. I am using PlatformIO Core inside Termux app in my Android Tablet. Please help

This happens when I use the old tool chain i.e toolchain-atmelavr 1.50400 which is installed by default.

You should add

platform_pacakges = 
    toolchain-atmelavr @

in the platformio.ini to make it a permanet change for that project.

In regards for the actual error: Can you manually execute the 1.50400 version binaries when you cd into the /home/<user>/.platformio/packages/toolchain-atmelavr/bin folder and execute avr-g++? Seems like there might be a binary compatibility issue.

Thank you very much for your reply. When I tried to exrecute the binary as you said, this happened

The same happened with newer binares (1.70300.191015 a.k.a 7.3.0)

Update= After this noon when I try “pio run” with the new toolchain installed (1.70300.191015) it is still recognized as the older version (Now it doesn’t go for downloading the old packages and uninstalling the new one) and then it gives the same error as above!

This happened just now when I tried with the new toolchain (1.70300.191015). I had to post again as I cannot upload two screenshots at the same post

You need to do a ./avr-g++ --version otherwise it will attempt to execute the system installed one in the PATH, which doesn’t exist.

Remove the toolchain-avr* folders within the PlatformIO packages folder, pio should redownload them.

I did as you said. But then this happened

Does it mean that I need clang or gcc, glibs installed in termux?
It is to be noted that these bin files are installed by PlatformIO itself. I removed the .platformio file as you said and after “pio run” these toolchain and framework files were installed automatically. Both the default toolchain and the manually installed toolchain files (Ones I installed myself e.g 1.703 and 1.504) give the same error.So removing the .platformio file doesn’t work.

Can you give the output of the following commands

uname -a 
file ~/.platformio/packages/toolchain-atmelavr/bin/avr-g++
ldd ~/.platformio/packages/toolchain-atmelavr/bin/avr-g++

Very weird indeed… I just installed PlatformIO on my own termux Android install, and it just doesn’t seem to work even it seems like it should…

@maxgerhardt You asked for the very info I was just checking on as I thought it was armhf binaries on arm64/aarch64 :laughing: I did avr-gcc instead as avr-g++ is a symbolic link.

Maybe it’s the old kernel version?

$ uname -a 
Linux localhost 3.18.66-g849f17f #1 SMP PREEMPT Wed Feb 26 15:29:23 CST 2020 aarch64 Android
$ file ~/.platformio/packages/toolchain-atmelavr/bin/avr-gcc
/data/data/com.termux/files/home/.platformio/packages/toolchain-atmelavr/bin/avr-gcc: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/, for GNU/Linux 3.7.0, BuildID[sha1]=0b74a8d59e6ab4d51097b246f60e436df1f64ea2, stripped
$ ldd ~/.platformio/packages/toolchain-atmelavr/bin/avr-gcc

Here you go. Can you tell me what’s wrong here?

@pfeerick Thanks for the attention. Here my tablet has an ARMv7 (32bit) cpu and I am running armhf binaries on termux (meh! Trying to run.:roll_eyes:). So I don’t think it will be a compatiablity issue.

1 Like

Well even though you are running a armv7l, it should still be able to execute armv6l binaries (binary compatible).

I was hoping the ldd output would show something useful but it just shows the required vs found libraries / interpreters I think. On a Linux PC this is much more descriptive

$ file ~/.platformio/packages/toolchain-atmelavr/bin/avr-g++
/home/max/.platformio/packages/toolchain-atmelavr/bin/avr-g++: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/, for GNU/Linux 2.6.15, stripped
$ ldd ~/.platformio/packages/toolchain-atmelavr/bin/avr-g++ (0x00007ffdb4143000) => /lib/x86_64-linux-gnu/ (0x00007f563e997000) => /lib/x86_64-linux-gnu/ (0x00007f563e7a6000)
	/lib64/ (0x00007f563eb01000)

Note that the “for GNU/Linux 2.6.15” binary runs perfectly fine on my 5.3.0-46 kernel on PC.

Is the interpreter / main loader there at /lib/ on your system? As well as the standard liibc and libm libraries? (Though I think if those weren’t there, your system wouldn’t be running…). Maybe compiling - “No such file or directory” when executing a cross-compiled program on a Raspberry Pi - Unix & Linux Stack Exchange helps?

Actually termux is a bit different than linux as far as I know (runs using Android API, daemons and such). And I think (I am not sure at all) that it is caused because glibc and gcc are not insalled in termux. I had the same kind of issue for compiling code in the past because I didn’t had the clang compiler installed in termux. If you know way of installing glibc and g++ in termux then let me know. I will try for now with clang installed. Then I will share with you what happens.
By the way…can you explain me this?libllvm: add experimental target avr by Grimler91 · Pull Request #4552 · termux/termux-packages · GitHub
This is about running avr-libc on termux using clang.

I could fix the issue by installing PlatformIO in chroot. I got esired toolchain by modifying the platform.json file and now I can install the updated toolchain (1.70300.191015 version) in both termux an in chroot. But the issue of avr-g++ no such file or directory remains. I can’t build my project at all. Please help.

1 Like