Close

Building on Windows

A project log for Stubby the (Teaching) Hexapod

100% open source robot platform with accessability and affordability in mind: teaching children of all ages about robots & programming

the-big-oneThe Big One 12/30/2014 at 20:130 Comments

I don't use Windows at all, so my workflow has always been very Linux-centric. A couple days ago, Chris emailed me with some questions about building on Windows... it turns out that there were a few problems. There were symlinks in my git repo, some filenames didn't work properly on Windows, and compilation failed with a few different problems when using the (older - released in 2010) avr-gcc for Windows.

To get things working better, I split Stubby source into its own github repository (previously, it was lumped in with all my other projects), and removed all symlinks. I fixed the code in a couple places where Windows didn't like it. However there was still the problem when compiling using avr-gcc versions older than 4.8; when you tried to do this, you would get a bunch of errors from the math libraries:

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr51\libm.a(atan2.o): In function `atan2':(.text.avr-libc.fplib+0x70): relocation truncated to fit: R_AVR_13_PCREL againstsymbol `__addsf3' defined in .text section in

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/avr51\libgcc.a(_addsub_sf.o)

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr51\libm.a(inverse.o): In function `inverse':(.text.avr-libc.fplib+0xc): relocation truncated to fit: R_AVR_13_PCREL againstsymbol `__divsf3' defined in .text section in

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/avr51\libgcc.a(_div_sf.o)

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr51\libm.a(pow.o): In function `pow':(.text.avr-libc.fplib+0x94): relocation truncated to fit: R_AVR_13_PCREL againstsymbol `__mulsf3' defined in .text section in

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/avr51\libgcc.a(_mul_sf.o)

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr51\libm.a(square.o): In function `square':(.text.avr-libc.fplib+0x4): relocation truncated to fit: R_AVR_13_PCREL againstsymbol `__mulsf3' defined in .text section in

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/avr51\libgcc.a(_mul_sf.o)

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr51\libm.a(log.o): In function `log':(.text.avr-libc.fplib+0x46): relocation truncated to fit: R_AVR_13_PCREL againstsymbol `__addsf3' defined in .text section in

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/avr51\libgcc.a(_addsub_sf.o)

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr51\libm.a(log.o): In function `log':(.text.avr-libc.fplib+0x4e): relocation truncated to fit: R_AVR_13_PCREL againstsymbol `__addsf3' defined in .text section in

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/avr51\libgcc.a(_addsub_sf.o)

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr51\libm.a(log.o): In function `log':(.text.avr-libc.fplib+0x6a): relocation truncated to fit: R_AVR_13_PCREL againstsymbol `__floatsisf' defined in .text section in

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/avr51\libgcc.a(_si_to_sf.o)

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/avr51\libm.a(modf.o): In function `modff':(.text.avr-libc.fplib+0x3e): relocation truncated to fit: R_AVR_13_PCREL againstsymbol `__subsf3' defined in .text section in

c:/winavr-20100110/bin/../lib/gcc/avr/4.3.3/avr51\libgcc.a(_addsub_sf.o)make: *** [stubby.out] Error 1

This problem is apparently quite common, and there are tons of references on how to fix it (specifically, don't use -mshort-calls option). However I was not using it. Finally I found a post on a forum which indicated that the problem is that the linker was trying to get the math functions from libgcc rather than avr-libc. The solution was to put -lc and -lm near the beginning of the compiler command, and -lc again at the end. Sure enough, it works! I have now fixed the Makefile, and things should be working on winavr as well as other older versions of avr-gcc.

To recap: to compile in Windows, you need to download the code (see the links section at the side for the Github Stubby repository), and then compile using whatever semi-modern avr-gcc you want to (I used the 2010-01-10 version but feel free to use more recent ones if you can find them).

Discussions