fearless_fool
fearless_fool

Reputation: 35219

How do I create a library (.a file) in Atmel Studio 7?

I have a body of code that's best packaged up as a library. How do I create a library in Atmel Studio 7?

Upvotes: 1

Views: 4115

Answers (1)

fearless_fool
fearless_fool

Reputation: 35219

Assume you have a specialized bit of hardware named "frob" for which you've created support code and you want to create a library that other programs can link against.

Creating the library

  1. Create an Atmel Studio 7 project named "frob"
  2. Under Project=>Properties, click on the "Build" tab
  3. Under Build Artifact, select Static Library
  4. Under artifact name, type "libfrob"
  5. (Optional) If your source code has a "main.c", right click on it and change its Properties => Build Action to "None".
  6. Compile the project. Verify that it created Debug/libfrob.a or Release/libfrob.a.

Using the library

To link a project against this library:

  1. Open your project
  2. In Project=>Properties, click on the Toolchain tab
  3. Under ARM/GNU Linker, click on Libraries
  4. In the Libraries (-l) window, click the "+" sign and add "frob" to the lst
  5. In the Library search path (-L) window, click on the "+" sign
  6. In the "Add Library search path (-L) dialog, click on the "..." button
  7. In the file dialog, navigate to the folder that contains libfrob.a
  8. Click okay.
  9. Under Project Properties => ARM/GNU Linker => Miscellaneous => Other Objects, add:
    -u _fstat
    -u _read
    -u _write

You now should be able to compile your project, linking against the files in the frob library.

Upvotes: 3

Related Questions