Using custom libraries

Hello,

I would like information about how to get the Arduino software interface to compile custom libraries. I have my own .c .a and .h files that I would like to compile separate from the standard Arduino libraries. I made a new library directory and included my files. The problem is that the compile process seems to call main() in main.cxx which I don't want to call. Ideally, I would like to have the compile button reference my own Makefile, but short of that allow me to compile my libraries without other functions being called. Is this possible? I would appreciate any help.

Thanks,
Sam

This topic was discussed just recently and may give you some ideas.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254803151

Thanks for the link, though I am not sure this is what I am looking for. I have no problem creating, editing and even getting the Arduino IDE to compile my libraries. What I want is for the Arduino IDE to compile only my libraries or at least not call the functions in main.cxx.

Perhaps then you need to explain in some more detail what you're after. I may not be able to assist you either way, but then the topic could possibly appeal to more people.

Keep in mind also that Arduino is a source distribution and libraries (including the Arduino core) gets recompiled every time you build your sketch. Hence having precompiled "libraries" doesn't make a lot of sense.

You mention "main" in your posts, but libraries do not have a main function so I'm not sure I follow you here. Still you will typically need a test program (with a main function) also when you develop libraries.

If you look for a platform/IDE to build static true libraries (such as the AVR-libc ".a" files) then you're probably better off looking at alternatives (e.g. WinAVR).

I have my own custom .c .h files for Arduino hardware. I have no problem editing, compiling files and creating my own .a libs. I can also use these files to program the Arduino mostly from the command line. Now I want to be able to compile these same files from the Arduino IDE without the IDE calling its own functions. It definitely does call main which if it is the one included in main.cxx also calls an init(), a setup() and calls loop() infinitely. I would like to avoid this.

Sam

Do you want to use any of the built-in Arduino code? If not, one thing you can do is make your own core, and put your files there. These are in the hardware/cores sub-directory of the Arduino application directory (or on the Mac, inside of the Content/Resources/Java sub-directory of the package contents of Arduino.app). Then you can edit the boards.txt file in the hardware directory to create a board that uses your new core. Just be sure to include a main.cxx and a WProgram.h file (since the IDE is hardcoded to look for those file names).

Thanks. This is very helpful, but would you mind giving me a little more advice. Here is what I have done so far.

  1. I added a new board section to boards.txt
  2. I changed the core line to read atmega168.build.core=newcore
  3. I created a newcore directory in cores which included empty files for main.cxx and WProgram.h
  4. I added just one custom header max.h to newcore.
  5. I then restarted the IDE and selected my new board type from the Tools/boards menu.
  6. I edited the blank document with
    #include "max.h" and a simple int main (void) function.
  7. When I compile I get the error no such file or directory.
    I think I am pretty close but would appreciate any more help.

Thanks!
Sam

Hello,

Is there a FAQ or other resources for learning how to create custom cores for the Arduino IDE? I would appreciate any information.

Thanks,
Sam

Did it say which file it couldn't find?

If I try to run the demo library :-
http://www.arduino.cc/playground/Code/Library

I get :-

c:/users/peter/downloads/arduino-0017/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr51/crtm1280.o:(.init9+0x0): undefined reference to `main'