cmicrocontrolleravravr-gccavrdude

Where are avr-gcc libraries stored?


I'm trying to locate the .c files that are related to the #include header files in avr.

I want to have a look at some of the standard libraries that are defined in the avr-gcc library, particularly the PORT definitions contained in <avr/io.h>. I searched through the library in /usr/lib/avr/include/avr and found the header file, however what I am looking for is the .c file. Does this file exist? If so, where can I find it? If not, what is the header file referencing?


Solution

  • The compiler provided libraries are precompiled object code stored in static libraries. In gcc, libraries conventionally the extension .a (for "archive" for largely historic reasons), and the prefix "lib".

    At build time, the linker will search the library archives to find the object-code modules necessary to resolve references to library symbols. It extracts the required modules and links them to the binary image being built.

    In gcc a library libXXX.a is typically linked using the command line switch -lXXX - so the libXXX.a naming convention is important in that case. So for example the standard C library libc.a is linked by the switch -lc.

    So to answer your question, there are normally no .c files for the compiler provided libraries provided with the toolchain. The library need not even have been written in C.

    That said, being open source, the source files (.c or otherwise) will be available from the repositories of the various libraries. For example, for the standard C library: https://www.nongnu.org/avr-libc/.

    For other AVR architecture and I/O support libraries, you might inspect the associated header files or documentation. The header files will typically have a boiler-plate comment with a project URL for example.