3

I have just installed the arduino IDE on my gentoo laptop. I then installed the toolchain with the following command:

crossdev -s4 avr

This does a stage 4 install of the toolchain, with all its dependecies etc.

I am following a tutorial, with my arduino uno, which I am assuming is using the Amtel ATmega328 chipset. This tutorial is simply going to turn an led on and off.

I click the verify button and I get the following errors:

/usr/libexec/gcc/avr/ld: cannot find crtatmega328p.o: No such file or directory

/usr/libexec/gcc/avr/ld: cannot find -latmega328p

collect2: error: ld returned 1 exit status

I downloaded the source files "avr-libc" compiled them and noticed inside the directory

/avr-libc-1.8.1/avr/lib/avr5/atmega328p

That the compiled module is named crtm328p.o which is available on my pc under the directory:

/usr/avr/lib/

I dont understand what is wrong and why this is not working. The only posts relating to missing files are over 5 years old and those solutions are not working.

  • The IDE should already have the toolchain in it - no need to compile and install anything else. – Majenko Jan 7 '16 at 15:37
  • 1
    @Majenko this is not the case when you install it on gentoo. – tensai Jan 7 '16 at 16:34
  • 1
    I installed it with "emerge -av arduino" This installs the package "dev-embedded/arduino-1.0.5-r1::gentoo" which is the java version. Arduino IDE. It then tells me during the install that avr is missing and i have to install it by entering crossdev -s4 avr on the command line – tensai Jan 7 '16 at 17:01
  • 3
    1.0.5 is ancient. You want 1.6.7 from arduino.cc/en/Main/Software – Majenko Jan 7 '16 at 17:02
  • 1
    Just download the tar,xz file, extract it, then run the arduino program from within it - that will give you everything you need without any more installation needed. – Majenko Jan 7 '16 at 17:04
2

I do not use Gentoo, but I can tell you how things work on Ubuntu 14.04, which also installs Arduino 1.0.5. I assume Gentoo should not be that different... The dependency tree is like this:

  • The package named "arduino", version 1.0.5, contains the IDE. It depends on Java and on arduino-core.
  • arduino-core, version 1.0.5 also, has the Arduino core libraries. It depends on gcc-avr, avrdude and avr-libc.
  • gcc-avr comes as version 4.8, avr-libc is version 1.8.0.

When you compile a program for an Uno, on the link stage avr-g++ gets called, and it is asked to link your object files with libcore.a (the Arduino core) and -lm (the math library). avr-g++ in turn calls the linker (collect2) and asks it to link together /usr/lib/avr/lib/avr5/crtm328p.o (the C runtime), your object files, libcore.a, -lgcc (the GCC support libraries), -lm and -lc (avr-libc). Notice that there is no crtatmega328p.o, it's called crtm328p.o instead. And there is no -latmega328p.

For diagnosing your problem, you can set an IDE preference so that it shows you the exact command lines it runs for compiling your program. You can then copy and paste the last command (link stage) on a terminal. If you add the -v option (meaning “verbose”), you will see what gcc is asking the linker to put together.

You may be able to fix your problem with a simple symlink from crtm328p.o to crtm328p.o. If you are using vanilla Gentoo packages, you should then file a bug to the packager. On Ubuntu, you type sudo apt-get install arduino and it just works.

| improve this answer | |
  • FYI: Using sudo apt-get install arduino gets you an ancient version of Arduino IDE, it is much better idea to download the latest from Arduino's site. – Avamander Feb 29 '16 at 20:50
  • @Avamander: I tried that, but the install is a mess: it completely ignores all the standard conventions of a Linux file system. I am a lot happier with an ancient core (I do not use the IDE) that is at least cleanly installed. – Edgar Bonet Feb 29 '16 at 21:24
  • What do you mean by standard conventions of a Linux file system? The install is fairly clean, it keeps it's stuff where the IDE was unpacked and only uses the Sketchbook what you've set. It's similar to Steam, not the most elegant but it works and you don't have to compile anything yourself and the developers have a standard set of libraries. – Avamander Feb 29 '16 at 21:59
  • I mean mostly the Filesystem Hierarchy Standard. After unpacking the IDE, I did a regular install of the AVR development toolchain, and ended up with lots of duplicates. This is the Arduino package completely ignoring good practices of putting stuff in the right place and correctly identifying its dependencies. – Edgar Bonet Mar 1 '16 at 8:26
  • Uhh, the toolchains are bundled with the IDE so that there would be no need to install dependencies, plus many things are not redistributable through a repository due to licence issues. It ain't ignoring, it can't do what you hope. There are issues related to updating the package open on Github. – Avamander Mar 1 '16 at 8:32
1

I had the same error, but I did everything as says in arduino wiki: https://wiki.gentoo.org/wiki/Arduino#Install_the_toolchain_using_crossdev

and solved it, after read this discussion: https://wiki.gentoo.org/wiki/Talk:Arduino

helped: build the avr toolchain without '--stable' part of crossdev command line :

USE="-openmp -hardened -sanitize -vtv" crossdev -s4 --portage --verbose --target avr

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.