Ubuntu 16.04 compilation of empty projects fails

Hello, I am quite experienced C and embedded user. I never used arduino. I have fresh instalation of Arduino IDE on Ubuntu Linux.

When I compile empty project I get error:

avr-g++: error trying to exec '/home/darek/programy/arduino-1.6.12/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/as': execv: Exec format error exit status 1 Błąd kompilacji dla płytki Arduino/Genuino Uno.

(ang: compilation failure for Arduino/Genuino Uno board

Can somebody give me a tip?

Regards, Darek

I can’t reproduce that (exactly). With an empty file I get this message:

/tmp/ccTQilcZ.ltrans0.ltrans.o: In function `main':
ccTQilcZ.ltrans0.o:(.text.startup+0x86): undefined reference to `setup'
ccTQilcZ.ltrans0.o:(.text.startup+0x8e): undefined reference to `loop'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Uno.

That was with Ubuntu 14.04 and IDE 1.6.12.

If I may suggest: don’t compile empty projects! What is the point?

Your minimal code should be:

int main (void) { }

That compiles without errors. (Same as using C).

Thank you for your response.

I think the problem is not what is in code. It is rather something wrong with IDE installation.

My code is: a "bare minimum" example:

void setup() {
  // put your setup code here, to run once:


void loop() {
  // put your main code here, to run repeatedly:


the same happens with this code:

int main(void)

so not the code is the problem.

My error is exactly:

Arduino:1.6.12 (Linux), Płytka:"Arduino/Genuino Uno"

/home/darek/arduino-1.6.12/arduino-builder -dump-prefs -logger=machine -hardware /home/darek/arduino-1.6.12/hardware -tools /home/darek/arduino-1.6.12/tools-builder -tools /home/darek/arduino-1.6.12/hardware/tools/avr -built-in-libraries /home/darek/arduino-1.6.12/libraries -libraries /home/darek/Arduino/libraries -fqbn=arduino:avr:uno -ide-version=10612 -build-path /tmp/arduino_build_59866 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/home/darek/arduino-1.6.12/hardware/tools/avr -prefs=runtime.tools.avrdude.path=/home/darek/arduino-1.6.12/hardware/tools/avr -verbose /tmp/arduino_modified_sketch_194224/ReadAnalogVoltage.ino /home/darek/arduino-1.6.12/arduino-builder -compile -logger=machine -hardware /home/darek/arduino-1.6.12/hardware -tools /home/darek/arduino-1.6.12/tools-builder -tools /home/darek/arduino-1.6.12/hardware/tools/avr -built-in-libraries /home/darek/arduino-1.6.12/libraries -libraries /home/darek/Arduino/libraries -fqbn=arduino:avr:uno -ide-version=10612 -build-path /tmp/arduino_build_59866 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=/home/darek/arduino-1.6.12/hardware/tools/avr -prefs=runtime.tools.avrdude.path=/home/darek/arduino-1.6.12/hardware/tools/avr -verbose /tmp/arduino_modified_sketch_194224/ReadAnalogVoltage.ino Using board 'uno' from platform in folder: /home/darek/arduino-1.6.12/hardware/arduino/avr Using core 'arduino' from platform in folder: /home/darek/arduino-1.6.12/hardware/arduino/avr Detecting libraries used... "/home/darek/arduino-1.6.12/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10612 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/darek/arduino-1.6.12/hardware/arduino/avr/cores/arduino" "-I/home/darek/arduino-1.6.12/hardware/arduino/avr/variants/standard" "/tmp/arduino_build_59866/sketch/ReadAnalogVoltage.ino.cpp" -o "/dev/null" Generating function prototypes... "/home/darek/arduino-1.6.12/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10612 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/darek/arduino-1.6.12/hardware/arduino/avr/cores/arduino" "-I/home/darek/arduino-1.6.12/hardware/arduino/avr/variants/standard" "/tmp/arduino_build_59866/sketch/ReadAnalogVoltage.ino.cpp" -o "/tmp/arduino_build_59866/preproc/ctags_target_for_gcc_minus_e.cpp" "/home/darek/arduino-1.6.12/tools-builder/ctags/5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/tmp/arduino_build_59866/preproc/ctags_target_for_gcc_minus_e.cpp" Kompilowanie szkicu... "/home/darek/arduino-1.6.12/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10612 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-I/home/darek/arduino-1.6.12/hardware/arduino/avr/cores/arduino" "-I/home/darek/arduino-1.6.12/hardware/arduino/avr/variants/standard" "/tmp/arduino_build_59866/sketch/ReadAnalogVoltage.ino.cpp" -o "/tmp/arduino_build_59866/sketch/ReadAnalogVoltage.ino.cpp.o" avr-g++: error trying to exec '/home/darek/arduino-1.6.12/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/as': execv: Exec format error exit status 1 Błąd kompilacji dla płytki Arduino/Genuino Uno.

Maybe see http://superuser.com/questions/973566/compiler-tools-execv-and-exec-format-error-under-s390x-chroot

That is sad it doesn't work just as it is installed. Fresh installation of Ubuntu, fresh installation of Arduino IDE. Why not work? I don't understand.

I like Linux, but most things don't work here.

Thank you

Hi all,

i experiencing the same error as Darek (cwanish):

Arduino: 1.6.12 (Linux), Board: "Arduino Duemilanove or Diecimila, ATmega328"

/home/stefan/arduino-1.6.12/arduino-builder -dump-prefs -logger=machine -hardware /home/stefan/arduino-1.6.12/hardware -hardware /home/stefan/_LocalData/projects/_arduino_sketchbook/hardware -tools /home/stefan/arduino-1.6.12/tools-builder -tools /home/stefan/arduino-1.6.12/hardware/tools/avr -built-in-libraries /home/stefan/arduino-1.6.12/libraries -libraries /home/stefan/_LocalData/projects/_arduino_sketchbook/libraries -fqbn=arduino:avr:diecimila:cpu=atmega328 -ide-version=10612 -build-path /tmp/arduino_build_669922 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/home/stefan/arduino-1.6.12/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/home/stefan/arduino-1.6.12/hardware/tools/avr -verbose /tmp/untitled1652527720.tmp/sketch_oct08a/sketch_oct08a.ino
/home/stefan/arduino-1.6.12/arduino-builder -compile -logger=machine -hardware /home/stefan/arduino-1.6.12/hardware -hardware /home/stefan/_LocalData/projects/_arduino_sketchbook/hardware -tools /home/stefan/arduino-1.6.12/tools-builder -tools /home/stefan/arduino-1.6.12/hardware/tools/avr -built-in-libraries /home/stefan/arduino-1.6.12/libraries -libraries /home/stefan/_LocalData/projects/_arduino_sketchbook/libraries -fqbn=arduino:avr:diecimila:cpu=atmega328 -ide-version=10612 -build-path /tmp/arduino_build_669922 -warnings=none -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=/home/stefan/arduino-1.6.12/hardware/tools/avr -prefs=runtime.tools.avr-gcc.path=/home/stefan/arduino-1.6.12/hardware/tools/avr -verbose /tmp/untitled1652527720.tmp/sketch_oct08a/sketch_oct08a.ino
Using board 'diecimila' from platform in folder: /home/stefan/arduino-1.6.12/hardware/arduino/avr
Using core 'arduino' from platform in folder: /home/stefan/arduino-1.6.12/hardware/arduino/avr
Detecting libraries used...
"/home/stefan/arduino-1.6.12/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10612 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR   "-I/home/stefan/arduino-1.6.12/hardware/arduino/avr/cores/arduino" "-I/home/stefan/arduino-1.6.12/hardware/arduino/avr/variants/standard" "/tmp/arduino_build_669922/sketch/sketch_oct08a.ino.cpp" -o "/dev/null"
Generating function prototypes...
"/home/stefan/arduino-1.6.12/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10612 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR   "-I/home/stefan/arduino-1.6.12/hardware/arduino/avr/cores/arduino" "-I/home/stefan/arduino-1.6.12/hardware/arduino/avr/variants/standard" "/tmp/arduino_build_669922/sketch/sketch_oct08a.ino.cpp" -o "/tmp/arduino_build_669922/preproc/ctags_target_for_gcc_minus_e.cpp"
"/home/stefan/arduino-1.6.12/tools-builder/ctags/5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/tmp/arduino_build_669922/preproc/ctags_target_for_gcc_minus_e.cpp"
Compiling sketch...
"/home/stefan/arduino-1.6.12/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10612 -DARDUINO_AVR_DUEMILANOVE -DARDUINO_ARCH_AVR   "-I/home/stefan/arduino-1.6.12/hardware/arduino/avr/cores/arduino" "-I/home/stefan/arduino-1.6.12/hardware/arduino/avr/variants/standard" "/tmp/arduino_build_669922/sketch/sketch_oct08a.ino.cpp" -o "/tmp/arduino_build_669922/sketch/sketch_oct08a.ino.cpp.o"
avr-g++: error trying to exec '/home/stefan/arduino-1.6.12/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/as': execv: Exec format error
exit status 1
Error compiling for board Arduino Duemilanove or Diecimila.

this is a long standing problem for me - last IDE that worked for me is 1.6.1. i also have tried to investigate this some more in this post: http://forum.arduino.cc/index.php?topic=358370 (without success)

i read the suggestion by Nick Gammon - - indeed i have qemu used/installed as i also do embedded development and have used it to 'crosscompile' for an armel board in a chroot with it.. after reading i tried with removing - restarting and installing again the qemu-user-static package. after each step starting the current IDE version (1.6.12) but every time got the same error message (as posted above)

as Darek has written:

cwanish: I am quite experienced C and embedded user...

@ cwanish do you also have installed / use qemu?

the funny thing is - if i just try to use it in an fresh clean user profile on the same maschine - it just works... so it has to do with something that is configured in the user profile/enviroment - and i thought that the arduino package is self contained - but that seems to be not really true....

has someone an idea how to debug this some more? iam lacking the knowledge till now to know what i have to search for...

hope we get this solved.

sunny greetings stefan

If it works for a new user you possibly have something corrupted in the '.arduino15' hidden file in your home directory. Close the IDE, rename that file (you may need some of the information in your preferences.txt file, you will at least need the path to your 'sketchbook') and then start the IDE. Fixed??

When you removed qemu did you do a purge to remove the config files, if any? Did you test your system when qemu was removed?

I am very grateful of your response. I am experienced in PIC microcontrollers, on Arduino not that much. Everything I ever proggramed was on Windows, not Linux. Now I thought I could also code in Linux… but not yet works.

I will try to somemething today with this problem.

Sorry, but I don’t yet know what QEMU is. I will read about it.

I didnt’t install qemu myself. If Ubuntu distribution contains, qemu, then I have it

Still don’t knoqw what is qemi (some virtualisation…)
I tried:

sudo apt-get purge qemu-user-static
then I deleted /home/darek/.Arduino folder
and then I installed qemi once again:
sudo apt-get install qemu-user-static

but in none of this step Adruino IDE worked. Just the .Arduino folder was recreated

Edit once again!!!

I just typed “arduino” in terminal. Terminal said: “arduino is not installed, you can install it with: sudo apt install arduino.” The arduino was previously installed, I have this nice icon on desktop. When double click on this icon, Arduino IDE opens, but gives that error with compilation. The error I describen in first post.

But if I type “arduino” in empty terminal, Arduino IDE launches and works properly. It is A micracle I guess.

I don’t know how to check it, but I guess it made me another, separate arduino installation. So I have now two Arduino installations: first not compiling, and the second that is able to compile.

I like Linux, but when something works here, I don’t know why… :slight_smile:

How did you install arduino the first time? Using the download from arduino.cc, or using the apt-get utility?

Hi Darek,

qemu is a visualisation system. if you did not have it installed yourself at first we know that this is should not be the source of the problem.

as you correctly thought - now you have two versions installed: the one you installed with 'apt-get install arduino' and the one you previously installed - i think with downloading and unzipping. the arduino version you get if you run the arduino command from a terminal is likely an older version. pleas can you have a look and let us know what version this is? (for me its 1.0.5)

pleas can you test and create a second user account and install (download and unpack) the latest version (1.6.12 https://www.arduino.cc/en/Main/Software)

@tf68: i did test between every step - after removing qemu - after restarting - after installing - every time the same error.. i did not remove the config files - i only uninstalled the package.

also the renaming of the ~/.arduino15 folder did not change the message. (i could verify that it made a new directory and all my previous settings were reset to default.)

are there other things i can look into / test? some more debuginformation in some way? or is there a list/information what external things the ide is falling back at?!

sunny greetings stefan

Arduino which is installed firstly, downloaded from arduino.cc has version 1.6.12. It doesn,t compile programs. Arduino which I installed using apt install arduino has version 2:1.0.5+dfsg2-4. It compiles without errors.

I Can't install arduino from file downloaded from arduino.cc this time (on the newly created admin user account). I double click arduino-builder file as I did before but now the arduino icon doesn't appear on the desktop. I also tried: sudo ./install.sh but it makes a not-working icon on the desktop, with the extension .desktop.

Hi Darek,

this installation is only for the icon. you can start it from the commandline: navigate to the folder you unzipped it and then try with ./arduino the ./ means 'here in this folder' so with this command you start the arduino-program that is contained in this folder. i don' t know why the desktop icon does not work - i don't use it or tried to install it..

sunny greeetings stefan

Hi Stefan,

Thank you for this basic information :)

I did as you wanted, launched unzipped arduno with ./arduino.

It is asu U said: doesn't compile in my main linux user account, but works well and compile on another linux user account.

Meybe it is problem with linux groups? I don't have much knowledge about groups.

If you want to do more experiments, I am willing to test your ideas.

Best regards, Darek

Here is my experience installing into Linux. The fact , verified by Arduino.cc developers, is that Install,sh was kept to install 1.0.5 IDE for non technical reasons AKA procedures and politics. It was only recently corrected to install anything but 1.0.5. by bpassing / not using the original repository of 1.0.5.

It was never published in which release the Install,sh was changed.

That is why you would get different installs from github and from Arduino.cc

It is not Linux issue , unfortunately Arduino.cc / LLC / org or whatever name they go by, does not give a hoot. Jim

But how do you explain that ide downloaded from arduino.cc works on one linux account but doesn't on another?

cwanish: But how do you explain that ide downloaded from arduino.cc works on one linux account but doesn't on another? [/quote Can't even guess why, I still do not trust install.sh. I think you can install it without using install.sh , but not sure now. It is oneof those - if it works , don;t fix it. I'll let you know if I decide to "upgrade" from1.6.11 - so far have no desire to go thru that mess again. Jim

@Jim - i never have tried to use the install.sh script. i just manually created a new entry in my applications menu. and i have multiple ides sitting site by site. they all working fine- only thing to consider - they use the same preferences...

sunny greetings stefan

I never run any scripts when I download it (for Ubuntu). I just unzip the directory and run the executable from it.

@s-light Maybe the problem is an environment variable? Try this, cd into your arduino directory and run this command 'env -i DISPLAY=:0 ./arduino', without the quotes. This runs arduino with no environment variables, except for the X display. If the DISPLAY setting is wrong for your system just run 'env' and find the DISPLAY= value for your system in the output.

thanks tf68 for the idea!
i didn’t know that this is possible in this simple way. (i can learn something new about linux every day :wink: )
something changed - the font-style and scrollbars… :slight_smile:
(i have added two screenshots. )
but sadly it did not change something in the errormessage.
normal - no env

sunny greetings