ldscripts directory location

Last post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I'm sort of new to AVR compiling in General. I'm using an Arduino board, which has an ATMega8 chip on it. I'm not using their IDE, but Makefiles to compile and upload code to the board.

When I create an environment, I have to symlink the ldscripts directory from binutils into the working directory (where the source files are):

ln -s /usr/lib/binutils/avr/2.16.1/ldscripts

If I don't do this, the cross-compiler linker, /usr/libexec/gcc/avr/ld, will fail to create the elf binary:

avr-gcc -mmcu=atmega8 -I. -gstabs -DF_CPU=16000000 -I../../usr/arduino -Os -Wall -Wstrict-prototypes -std=gnu99  ../../usr/arduino/pins_arduino.o ../../usr/arduino/wiring.o ../../usr/arduino/WInterrupts.o blink.o ../../usr/arduino/HardwareSerial.o ../../usr/arduino/WRandom.o  --output blink.elf 
/usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr4.x: No such file or directory
make: *** [blink.elf] Error 1

This is even though there are no direct references to the ldscripts directory from the Makefile or any of the source files.

Is there a possibility to build somehow so that one does not need to symlink the ldscripts directory?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Not sure how this relates to a Linux installation but in the WinAVR package the ldscripts are in \winavr\avr\lib\ldscripts - not sure if this helps you locate them in your installation. But if you just use "find -name=avr4.x" you should be able to find where they are lurking.

Cliff

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This for sure looks like the entire toolchain wasn't configured
with the same --prefix option. Normally, the compiler should tell
the linker the exact location of these scripts.

You can verify the command-line the compiler driver is using when
calling the linker by adding a -v to the options.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've installed avr-gcc by using crossdev on gentoo. the output with -v says:

$ avr-gcc -v
Reading specs from /usr/lib/gcc/avr/3.4.6/specs
Configured with: /var/tmp/portage/cross-avr/gcc-3.4.6/work/gcc-3.4.6/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/avr/gcc-bin/3.4.6 --includedir=/usr/lib/gcc/avr/3.4.6/include --datadir=/usr/share/gcc-data/avr/3.4.6 --mandir=/usr/share/gcc-data/avr/3.4.6/man --infodir=/usr/share/gcc-data/avr/3.4.6/info --with-gxx-include-dir=/usr/lib/gcc/avr/3.4.6/include/g++-v3 --host=x86_64-pc-linux-gnu --target=avr --build=x86_64-pc-linux-gnu --disable-altivec --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --disable-libgcj --enable-languages=c,c++ --enable-shared --disable-threads
Thread model: single
gcc version 3.4.6 (Gentoo 3.4.6, ssp-3.4.5-1.0, pie-8.7.9)

whereas ldscripts is under /usr/lib/binutils/avr/2.16.1/ldscripts

does this installation seem wrong?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, I meant you add the -v option to the avr-gcc command-line you use
when linking your job.

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.
Please read the `General information...' article before.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

darkeye wrote:
I've installed avr-gcc by using crossdev on gentoo.

There has to be something wrong with crossdev on gentoo. I have a colleague who has this issue, and there was another recent post on the avr-gcc-list about crossdev with the same problem.

My advice is to build the toolchain yourself and avoid crossdev until somebody fixes it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I too am new to AVR chips and installed the toolchain using crossdev on Gentoo.

To overcome the linker not finding the ldscripts you can use the -L option to give extra directories. I was surprised as I thought -L was only for directories with binary code to link against.

avr-gcc -Wl,-Map,AVREnvTest.map -L/usr/lib/binutils/avr/2.19.1/ -mmcu=atmega16 -o"AVREnvTest.elf"  ./main.o

man ld for more info on -L

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You might want to have a look here

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=42631

And build a recent toolchain

/Bingo