Re: documentation question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Ian Lance Taylor writes:
> Jim Beecher <jbeecher@xxxxxxxxxxxxxxxxxx> writes:
>> Is there documentation on how to create '.lib' (library) files in the
>> GCC docs-- or is this covered in 'make' docs?  I have read the gcc.pdf
>> manual and found nothing on creating a library.  I would like be able
>> to make libraries via WinAVR (through the IDE, that is-- is this
>> possible already?).
> The compiler does not make libraries.  On Unix or GNU/Linux libraries
> are created using the ar command, which is not part of the compiler.  I
> assume that on Windows there is some similar command, but I don't know
> what it is.  You may do better to ask on a Windows mailing list.q
>
> Ian
As a generic query, I'd recommend using libtool for a *nix system, as it
will
take care of using ar, arcane linker parameters or whatever needed to create
shared or dynamic libraries.

In this case, however, the ar suggestion seems right. There are no
dynamic libraries
there, and the host is irrelevant, too as you're cross-compiling. There
is an ar.exe command
provided with WinAVR.

You could create the .o files, then join them all in a library using
  ar r libFOO.a file1.o file2.o ...

Note that the filename you choose *must* begin with "lib" and end with
".a". This way you
can use -lFOO as a parameter to the linker and it will grab the libFOO.a
file.

I don't know which IDE you're using (WinAVR is the compiler bundle, not
an IDE), but I
don't think it'll support creating the libraries. You can however make
use of your libraries
in your IDE.
A further consideration: the libraries hold object files. That's code
already compiled for an
architecture. If you later change the microcontroller you're targetting,
or the cpu frequency
(and it's used inside the library, of course), the library won't notice.
You'd need to regenerate it
or to several different copies with different profiles, and link with
the appropiate one.

Best regards



[Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

Add to Google