Creating a static library and use it in an project

Hello there

Is there anyone here who can direct me to a good site/book, that tells me how to build a static library and then add it to the makefile that comes with the Arduino? I have searched everywhere but I cant find any good articles/books that can give me the insight on how to make static libraries to the Arduino (.a libraries), and then make it available to a project (ie, put it in the Arduino include and library path). How do I do that?

I don’t think that the Arduino IDE supports static libraries. All the libraries I’ve seen are compiled and linked as part of the build process for building a sketch.

Why do you want to build a static library?

Okay. I thought so. Well I am in the process of making this server / client framework, and I first want to implement it so I can compile it and unit test the code on an x86. After the test, in the future runs and tells me that everything is okay, then Im going to implement the parts thats is Arduino related. Why Im set up to make an static library, I acctually dont know :-?, but then I have to find another way. I dont want to use the IDE, so I think that I have to include the specific files into the Arduino library path, /Applications/Arduino.app/Contents/Resources/Java/libraries (on Mac OS X)? And then use the makefile in my project dir. I think it can locate the library at "maketime"?

I dont want to use the IDE

To be perfectly frank, I can take it or leave it. I mean, I think it's "OK" for small stuff, but I like complete control for "real" projects. See Footnote. I tend to do everything from a command line. (How 20th century is that? And not even late 20th century, right?)

unit test the code---

A very sound methodology!

...include the specific files into the Arduino library path,....

For starters:

In the Arduino IDE, hold down the 'Shift' key when you compile a sketch. (In Arduino, you click on what is---inexplicably---called the "Verify" button. The one on the left.)

You can see all of the command line switches and sequence of steps that Arduino uses to create a library from the core function files and link it in with the .cpp file that Arduino creates from your .pde file. You can use that as the basis of your Makefile. By examining the files in the temporary directory that Arduino creates, you can also see how Arduino makes a real .cpp file from your sketch.

I do this for projects on my Linux system (Centos 5.5). I also create an "upload" target in the Makefile that calls avrdude.

Actually I have an "upload_tty" target that uses /dev/ttyS0 and and an "upload_usb" target that uses /dev/ttyUSB0, since sometimes I connect the Arduino board to the serial port and sometimes to USB. I set the default to USB, since that's my usual connection, but that can be overriden from the command line when I invoke the "make" program.

For me, I find that the ability to use the command-line options "-Wall -W -Werror" that support (enforce, actually) my self-imposed requirement for a completely clean compile (for my own stuff) has helped reduce debugging time. The goal of the Arduino team to keep people from having to learn "everything" about C++ is admirable, and it gets lots of people started without actually learning (much) C++, but I like the option to break away when I feel like it.

I never change anything about Arduino IDE or its library files. That way I can go back to the IDE for testing if I suspect that I didn't "do it right" when I abstracted the Arduino stuff into my external build process.

Also, it mans that I can compare results with things that I see on this forum from the mainly "pure Arduino" users. I learn a lot from seeing other people's approach to problem solving and I like to be able to reproduce their results---or not.

Regards,

Dave

Footnote: Control. Complete control. I like to pretend that I am in control. I'm funny that way.