Install libopencm3 for Cygwin

The libopencm3 project is an open-source firmware library for ARM microcontrollers. Its Makefile configuration does not work for Cygwin/Windows 8.1 environment, the GNU make stops work at the AR procedure:

  AR      libopencm3_stm32f0.a
C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q2\bin\arm-none-eabi-ar.exe: /src/libopencm3/libopencm3/lib/libopencm3_stm32f0.a: No such file or directory
../../Makefile.include:35: recipe for target '/src/libopencm3/libopencm3/lib/libopencm3_stm32f0.a' failed
make[1]: *** [/src/libopencm3/libopencm3/lib/libopencm3_stm32f0.a] Error 1
Makefile:67: recipe for target 'lib/stm32/f0' failed
make: *** [lib/stm32/f0] Error 2cd cd

To overcome, the stm32f0 and other targets can be done separately

$ cd lib/stm32/f0
$ make clean
$ make

This builds libopencm3_stm32f0.a and puts it with libopencm3_stm32f0.ld in parent folder, i.e. ../ or ../../lib.

Do same work in f1 f2 f3 f4 l0 l1 folders under the stm32. Then do same work also following folders:


Last, do make in the libopencm3’s root src folder, my example

$ cd /src/libopencm3/libopencm3/
$ make

Now we have all libraries built and ready for installation.

Destination folder

We have to figure out the correct folder for installing destination, so the cross compiler (ARM gcc) can find libraries and headers of the libopencm3 as its system resource. For example,  to include a header in a C source code:

#include <libopencm3/stm32/rcc.h>

and tell gcc to link a library:

arm-none-eabi-gcc ... -l libopencm3_stm32f1.a ...

To find the folder, do a pseudo compiling with verbose flag:

$ touch foo.c
$ arm-none-eabi-gcc -v -c foo.c

got output messages like these:

Using built-in specs.
COLLECT_GCC=C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2015q2\bin\arm-none-eabi-gcc.exe
Target: arm-none-eabi

#include "..." search starts here:
#include <...> search starts here:
 c:\program files (x86)\gnu tools arm embedded\4.9 2015q2\bin\../lib/gcc/arm-none-eabi/4.9.3/include
 c:\program files (x86)\gnu tools arm embedded\4.9 2015q2\bin\../lib/gcc/arm-none-eabi/4.9.3/include-fixed
 c:\program files (x86)\gnu tools arm embedded\4.9 2015q2\bin\../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/include
End of search list.
GNU C (GNU Tools for ARM Embedded Processors) version 4.9.3 20150529 (release) [ARM/embedded-4_9-branch revision 224288] (arm-none-eabi)
        compiled by GNU C version 4.7.4, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9d74dec9c13b63cc54577fa808c91d66
 c:/program files (x86)/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/as.exe -v -meabi=5 -o foo.o D:\cygwin\tmp\ccoAfeh1.s
GNU assembler version 2.24.0 (arm-none-eabi) using BFD version (GNU Tools for ARM Embedded Processors)
COMPILER_PATH=c:/program files (x86)/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/;c:/program files (x86)/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/;c:/program files (x86)/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/
LIBRARY_PATH=c:/program files (x86)/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/;c:/program files (x86)/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/;c:/program files (x86)/gnu tools arm embedded/4.9 2015q2/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/lib/;c:/program files (x86)/gnu tools arm embedded/4.9 2015q2/bin/../arm-none-eabi/lib/

See from the colored text summarized the destination in Cygwin file system
Include folder

/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/arm-none-eabi/include

Library folder

/cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/arm-none-eabi/lib

Cygwin can write to destination

If Cygwin can write to the destination folders directly, just replace text in the root Makefile

DESTDIR ?= /usr/local


DESTDIR ?= /cygdrive/c/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2

then make install

Cygwin can’t write to destination

If current user is in the Administrator group of Windows, use Windows Explorer. For example, make install with the default destination, i.e /cygwin/usr/local
After make install, use Windows Explorer to move or copy



/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/arm-none-eabi/include/
/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/arm-none-eabi/lib/
/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/arm-none-eabi/share/

The installation is done and the libopencm3 is a system resource of ARM gcc.


One thought on “Install libopencm3 for Cygwin

  1. Pingback: Set up Cygwin for Deviation Development | Compusilli

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s