You probably need flex, byacc, bison, gcc, and libusb-dev:
sudo apt-get install flex byacc bison gcc libusb-dev
and libusb from libusb dot info, then use these commands in Terminal to install it from it's root installation directory:
./configure make sudo make install
or
sudo apt-get install libusb-1.0-0
Then download binutils: http://ftp.gnu.org/gnu/binutils/ configure it:
./configure --target=avr --program-prefix="avr-"
then make and install it. Afterward, download the latest version of GCC from: http://gcc.gnu.org/mirrors.html. It had errors after I tried to install it, saying I needed gmp, mpfr and mpc, so I downloaded them in this order from these websites:
https://gmplib.org/
https://www.mpfr.org/mpfr-current/
https://ftp.gnu.org/gnu/mpc/
and installed them using
./configure make sudo make install
in Ubuntu Terminal.
Luckily, after this, gcc installed successfully. Then you need to install avr-libc from: http://download.savannah.gnu.org/releases/avr-libc/
And avrdude to access the physical board: http://download.savannah.gnu.org/releases/avrdude/
Use
./configure --enable-linuxgpio
on avrdude to enable general purpose input/output (and set the pins reset, sck, mosi, and miso in avrdude.conf). Avrdude checks (at the end) if you have libelf, libftdi1 , libftdi, and libhid
Download libelf from https://web.archive.org/web/20160430090619/http://www.mr511.de/software/libelf-0.8.3.tar.gz or
sudo apt-get update -y sudo apt-get install -y libelf-dev
ftdi (for ftdi chips and ft chips which are usb to serial) which is optional, you can get it from intra2net or use these commands:
sudo apt-get update -y sudo apt-get install -y libftdi1-dev sudo apt-get install -y libftdi-dev
and finally libhid (human interface device):
sudo apt-get install libhidapi-dev
which it doesn't even detect for some strange reason.
You probably don't need to do all these steps. You could just try installing only avr for the minimum requirements but to be safe, it is recommended to go through the other steps.
When compiling an AVR program (compile the Arduino IDE libraries into a single library if you're using the IDE's code), you need to use g++, not gcc. This is some code and instructions to compile a simple program using Arduino:
//After calling it ardcpp.cpp, I compiled this and got it working for Arduino Uno (atmega328p) in Linux Terminal with the following 3 commands: //avr-g++ ardcpp.cpp -O1 -Os -Wall -DF_CPU=16000000L -mmcu=atmega328p -I/snap/arduino/41/hardware/arduino/avr/cores/arduino -I/snap/arduino/41/hardware/tools/avr/avr/include/ -I/snap/arduino/41/hardware/arduino/avr/variants/circuitplay32u4 -I/usr/include/ -o ardcpp.bin //avr-objcopy -j .text -j .data -O ihex ardcpp.bin ardcpp.hex //avrdude -c arduino -P /dev/ttyUSB0 -p m328p -U flash:w:ardcpp.hex #include <avr/io.h> #include <util/delay.h> //#include <Arduino.h> int main (void) { DDRB |= _BV(DDB4);//data direction register sets 4th bit as output (pin 12) //0 thru 7 bits equal pins 8 thru 13, GND, and AREF on Arduino (SDA, and SCL for input from devices such as a gyroscope or a pressure/temperature/humidity sensor are not in PORTB, so use I2C/TWI for them) while(1) { //4=12,5=13 PORTB |= (1<<4);//Set pin 12 to HIGH/ON _delay_ms(50);//wait 50 ms PORTB &= ~(1<<4);//Set pin 12 to LOW/OFF _delay_ms(50);//wait 50 ms } }
'