| View previous topic :: View next topic |
| Author |
Message |
Bob Leny Apprentice


Joined: 18 Aug 2006 Posts: 189
|
Posted: Sun Dec 05, 2010 1:50 am Post subject: [SOLVED] I need help with gcc and avr linking... |
|
|
I am running gcc 4.4.4.
I ran this command
to get the AVR toolchain.
That seemed to go fine.
I navigated to the directory that has the program source code for the AVR.
I then ran make to get this output:
| Quote: |
make dfu
Compiling C: MicropendousKeyboardTest.c
avr-gcc -c -mmcu=at90usb647 -I. -gdwarf-2 -DF_CPU=16000000UL -DF_CLOCK=16000000UL -DBOARD=BOARD_USER -D USB_DEVICE_ONLY -D FIXED_CONTROL_ENDPOINT_SIZE=8 -D FIXED_NUM_CONFIGURATIONS=1 -D USE_FLASH_DESCRIPTORS -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=./MicropendousKeyboardTest.lst -I../../libs/LUFA/ -I../../libs/avrlib/ -std=gnu99 -Wundef -MMD -MP -MF .dep/MicropendousKeyboardTest.o.d MicropendousKeyboardTest.c -o MicropendousKeyboardTest.o
Compiling C: ../../libs/LUFA/LUFA/Drivers/USB/Class/Host/HIDParser.c
avr-gcc -c -mmcu=at90usb647 -I. -gdwarf-2 -DF_CPU=16000000UL -DF_CLOCK=16000000UL -DBOARD=BOARD_USER -D USB_DEVICE_ONLY -D FIXED_CONTROL_ENDPOINT_SIZE=8 -D FIXED_NUM_CONFIGURATIONS=1 -D USE_FLASH_DESCRIPTORS -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=./../../libs/LUFA/LUFA/Drivers/USB/Class/Host/HIDParser.lst -I../../libs/LUFA/ -I../../libs/avrlib/ -std=gnu99 -Wundef -MMD -MP -MF .dep/HIDParser.o.d ../../libs/LUFA/LUFA/Drivers/USB/Class/Host/HIDParser.c -o ../../libs/LUFA/LUFA/Drivers/USB/Class/Host/HIDParser.o
... More compiling without errors ...
Linking: MicropendousKeyboardTest.elf
avr-gcc -mmcu=at90usb647 -I. -gdwarf-2 -DF_CPU=16000000UL -DF_CLOCK=16000000UL -DBOARD=BOARD_USER -D USB_DEVICE_ONLY -D FIXED_CONTROL_ENDPOINT_SIZE=8 -D FIXED_NUM_CONFIGURATIONS=1 -D USE_FLASH_DESCRIPTORS -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" -Os -funsigned-char -funsigned-bitfields -ffunction-sections -fno-inline-small-functions -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wundef -Wa,-adhlns=MicropendousKeyboardTest.o -I../../libs/LUFA/ -I../../libs/avrlib/ -std=gnu99 -Wundef -MMD -MP -MF .dep/MicropendousKeyboardTest.elf.d MicropendousKeyboardTest.o Descriptors.o ../../libs/LUFA/LUFA/Drivers/USB/LowLevel/DevChapter9.o ../../libs/LUFA/LUFA/Drivers/USB/LowLevel/Endpoint.o ../../libs/LUFA/LUFA/Drivers/USB/LowLevel/Host.o ../../libs/LUFA/LUFA/Drivers/USB/LowLevel/HostChapter9.o ../../libs/LUFA/LUFA/Drivers/USB/LowLevel/LowLevel.o ../../libs/LUFA/LUFA/Drivers/USB/LowLevel/Pipe.o ../../libs/LUFA/LUFA/Drivers/USB/HighLevel/Events.o ../../libs/LUFA/LUFA/Drivers/USB/HighLevel/USBInterrupt.o ../../libs/LUFA/LUFA/Drivers/USB/HighLevel/USBTask.o ../../libs/LUFA/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.o ../../libs/LUFA/LUFA/Drivers/USB/Class/Device/HID.o ../../libs/LUFA/LUFA/Drivers/USB/Class/Host/HID.o ../../libs/LUFA/LUFA/Drivers/USB/Class/Host/HIDParser.o --output MicropendousKeyboardTest.elf -Wl,-Map=MicropendousKeyboardTest.map,--cref -Wl,--relax -Wl,--gc-sections -lm
/usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory
collect2: ld returned 1 exit status
make: *** [MicropendousKeyboardTest.elf] Error 1
|
I really don't know much about the file structure of gcc or how it works exactly, I just use it. However, I do know when I see an error, which I have made bold above.
I did a file search for avr5.x in the /usr directory, this is what it found:
| Code: |
/usr/local/atmel/avr/lib/ldscripts/avr5.x
/usr/lib64/binutils/avr/2.20.1/ldscripts/avr5.x
|
What directory should avr5.x be in?
I really don't know what to do about this. I know so little about the workings of gcc...
Thanks! _________________ -- www.firemelt.net --
01000010 01101111 01110111 00100000 01100010 01100101 01100110 01101111 01110010 01100101 00100000 01001101 01100101 00100001
Cheer up, the worst is yet to come...
Last edited by Bob Leny on Thu Dec 09, 2010 7:45 pm; edited 1 time in total |
|
| Back to top |
|
 |
Bob Leny Apprentice


Joined: 18 Aug 2006 Posts: 189
|
Posted: Mon Dec 06, 2010 12:14 am Post subject: |
|
|
Oh, I forgot to mention that I have tried to compile several different programs with both "make dfu" and "make" and I always get the same exact error:
| Quote: | | /usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory |
_________________ -- www.firemelt.net --
01000010 01101111 01110111 00100000 01100010 01100101 01100110 01101111 01110010 01100101 00100000 01001101 01100101 00100001
Cheer up, the worst is yet to come... |
|
| Back to top |
|
 |
Bob Leny Apprentice


Joined: 18 Aug 2006 Posts: 189
|
Posted: Thu Dec 09, 2010 7:45 pm Post subject: |
|
|
Ok, for anyone who might happen across this thread with the same problem as I, this was my solution.
Note, this may not be a good idea, but it did work for me. Use at your own peril...
First, locate the avr linker script.
Mine was located here:
| Quote: | | /usr/lib64/binutils/avr/2.20.1/ldscripts/ |
At this point you might be able to use the linker option -L and set it equal to "/usr/lib64/binutils/avr/2.20.1/ldscripts/"
| Quote: | | -L/usr/lib64/binutils/avr/2.20.1/ldscripts/ |
That did not work for me so I did the following...
Next, find the location of the linker program ("ld").
Mine was found here:
| Quote: | | /usr/libexec/gcc/avr/ |
However, that was a symbolic link to here:
| Quote: | | /usr/x86_64-pc-linux-gnu/avr/binutils-bin/2.20.1/ |
Then I created symbolic link of the link script location to the location of my linker program.
| Quote: | | ln -s /usr/lib64/binutils/avr/2.20.1/ldscripts/ /usr/x86_64-pc-linux-gnu/avr/binutils-bin/2.20.1/ |
Now it works! _________________ -- www.firemelt.net --
01000010 01101111 01110111 00100000 01100010 01100101 01100110 01101111 01110010 01100101 00100000 01001101 01100101 00100001
Cheer up, the worst is yet to come... |
|
| Back to top |
|
 |
OmSai l33t


Joined: 30 Sep 2007 Posts: 603 Location: Manchester, CT, USA
|
Posted: Thu Jan 13, 2011 2:13 am Post subject: |
|
|
Thanks! This worked for me (same paths and versions) _________________ Gentoo is the stick-shift of Linux.
You work it manually, it has somewhat better performance, but it's really for the fun of it. |
|
| Back to top |
|
 |
mikegpitt Advocate


Joined: 22 May 2004 Posts: 3194
|
Posted: Fri Dec 30, 2011 4:57 pm Post subject: |
|
|
This bug is still apparently around... fixed it by doing this today:
Error 1: | Code: | | /usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory | Fix 1: | Code: | | ln -s /usr/lib/binutils/avr/2.22/ldscripts /usr/avr/lib/ldscripts |
Error 2: | Code: | | /usr/libexec/gcc/avr/ld: cannot find crtm328p.o: No such file or directory | Fix 2: | Code: | | ln -s /usr/avr/lib/avr5/crtm328p.o /usr/avr/lib/crtm328p.o |
|
|
| Back to top |
|
 |
avion23 n00b

Joined: 20 Jul 2009 Posts: 7
|
Posted: Tue Jan 31, 2012 6:54 pm Post subject: |
|
|
I've the same problem using crtm168p.o and crtm168.o. The message is
| Code: | | /usr/libexec/gcc/avr/ld: cannot find crtm168.o: No such file or directory |
Is there a way around linking several files? |
|
| Back to top |
|
 |
mikegpitt Advocate


Joined: 22 May 2004 Posts: 3194
|
Posted: Tue Jan 31, 2012 8:04 pm Post subject: |
|
|
| avion23 wrote: | I've the same problem using crtm168p.o and crtm168.o. The message is
| Code: | | /usr/libexec/gcc/avr/ld: cannot find crtm168.o: No such file or directory |
Is there a way around linking several files? | I wasn't able to figure out a way around the symlinks. I tried a few things, like adding it to my LD_LIBRARY_PATH, but couldn't get anything to work. Maybe you will have better luck. If you do, be sure to post back! |
|
| Back to top |
|
 |
Gentree Watchman


Joined: 01 Jul 2003 Posts: 5164 Location: France, Old Europe
|
Posted: Mon Jul 09, 2012 9:08 am Post subject: |
|
|
| Code: | find /usr -iname avr5.x
/usr/lib/binutils/avr/2.20.1/ldscripts/avr5.x
/usr/lib/binutils/avr/2.21.1/ldscripts/avr5.x
|
So what is this about?
Is this something that binutils ebuild should be installing but isn't ?
A LDPATH that needs setting up
In fact the ldscripts directory is missing!
| Code: | bash-4.2#ls /usr/avr/lib/
avr25 crt86401.o crts4433.o crttn22.o crttn45.o libprintf_min.a
avr3 crtc8534.o crts4434.o crttn2313.o crttn461.o libscanf_flt.a
avr31 crts1200.o crts8515.o crttn24.o crttn84.o libscanf_min.a
avr35 crts2313.o crts8535.o crttn25.o crttn85.o
avr4 crts2323.o crttn11.o crttn261.o crttn861.o
avr5 crts2333.o crttn12.o crttn26.o libc.a
avr51 crts2343.o crttn13.o crttn28.o libm.a
avr6 crts4414.o crttn15.o crttn44.o libprintf_flt.a |
any ideas how this _should_ be set up rather than symlink workarounds?
TAI _________________ Linux, because I'd rather own a free OS than steal one that's not worth paying for.
KX7-333 , AthlonXP1800+ @2.3GHz
AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86 |
|
| Back to top |
|
 |
Gentree Watchman


Joined: 01 Jul 2003 Posts: 5164 Location: France, Old Europe
|
Posted: Mon Jul 09, 2012 9:28 am Post subject: |
|
|
| Code: | 224472 lrwxrwxrwx 1 root root 52 Feb 22 2011 elfedit -> /usr/i686-pc-linux-gnu/avr/binutils-bin/2.21/elfedit
224475 lrwxrwxrwx 1 root root 51 Feb 22 2011 ld.bfd -> /usr/i686-pc-linux-gnu/avr/binutils-bin/2.21/ld.bfd
|
| Code: |
/usr/i686-pc-linux-gnu/avr/binutils-bin/2.20.1:
addr2line as gprof nm objdump readelf strings
ar c++filt ld objcopy ranlib size strip
/usr/i686-pc-linux-gnu/avr/binutils-bin/2.21.1:
addr2line as elfedit ld nm objdump readelf strings
ar c++filt gprof ld.bfd objcopy ranlib size strip
|
Those two are broken links, note the directory name is 2.21 instead of 2.20.1
Looks like someone got their ${PN} or whatever variables mixed up in the ebuild.
My guess would be a similar error has prevented the ldscripts getting installed or the LDPATH getting set correctly. _________________ Linux, because I'd rather own a free OS than steal one that's not worth paying for.
KX7-333 , AthlonXP1800+ @2.3GHz
AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86 |
|
| Back to top |
|
 |
Gentree Watchman


Joined: 01 Jul 2003 Posts: 5164 Location: France, Old Europe
|
Posted: Mon Jul 09, 2012 9:33 am Post subject: |
|
|
| Code: | etcat binutils
[ Searching for package 'binutils' in all categories among: ]
* installed packages
[I--] [ ] cross-avr/binutils-2.20.1-r1 (avr)
[I--] [ ] cross-avr/binutils-2.21.1-r1 (0)
[I--] [ ~] sys-devel/binutils-2.22-r1 (0)
[I--] [ ] sys-devel/binutils-config-3-r3 (0)
|
Also the new avr binutils has gone into slot 0 , I think I'm going to remove this version until the ebuild is doing what it should.  _________________ Linux, because I'd rather own a free OS than steal one that's not worth paying for.
KX7-333 , AthlonXP1800+ @2.3GHz
AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86 |
|
| Back to top |
|
 |
Gentree Watchman


Joined: 01 Jul 2003 Posts: 5164 Location: France, Old Europe
|
Posted: Mon Jul 09, 2012 9:37 am Post subject: |
|
|
| Code: | # Workaround fuer "/usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory"
CFLAGS += -L/usr/i686-pc-linux-gnu/avr/lib |
h/t
http://code.google.com/p/mcpg/source/browse/trunk/Schulungen/Software/01-taster/Makefile?r=9 _________________ Linux, because I'd rather own a free OS than steal one that's not worth paying for.
KX7-333 , AthlonXP1800+ @2.3GHz
AthlonXP-M on A7N8X @ 2.6/2.4GHz (winter/summer)
2.6.32-hh1 : portage ~x86 |
|
| Back to top |
|
 |
schorsch_76 n00b

Joined: 19 Jun 2012 Posts: 44
|
Posted: Thu Oct 11, 2012 7:43 pm Post subject: |
|
|
Just want to leave a breadcrumb here for others, if they expierience the problem, that the crtm168p.o or an other crt can not be found:
| Code: |
# Workaround for /usr/libexec/gcc/avr/ld: cannot open linker script file ldscripts/avr5.x: No such file or directory
CFLAGS += -L/usr/x86_64-pc-linux-gnu/avr/lib/
# Workaround for /usr/libexec/gcc/avr/ld: crtm168.o: No such file: No such file or directory
CFLAGS += -B/usr/avr/lib/avr5/
|
I've put this into the projekt makefile.
i'm using
avr-gcc-4.5.4
bin-utils 2.20
Host: amd64
Bye
schorsch |
|
| Back to top |
|
 |
|