Cosa: An Object-Oriented Platform for Arduino programming

kowalski:
Hi MarsWarrior.

You really don't like reading documentation ;-). I was under the impression that you had already installed Cosa previously and was now attempting to use it with Code::Blocks and a new version of Arduino. I understand now that this assumption was wrong. Sorry about that.

Well, yes I don't like reading documentation as I am a visual thinker. Still I did read your blog. Started with the first application, but managed to skip the whole installation blog :smiley: I did however compile Cosa a few months back on another PC, but didn't know the special install anymore as you have noticed...

Cosa is not an Arduino library. The Arduino preprocessor cannot handle sub-directories within a library. I like to structure things so the include is "Cosa/XXX.hh" for header file and then there is even more structure like "Cosa/LCD.hh" and "Cosa/LCD/Driver/HD44780.hh".

Now how can we get the Arduino preprocessor (compiler include path) to recognize this? We put the Cosa directory into the arduino header/source directory! So the installation procedure is:

  1. Download Cosa as a zip file.
  2. Unzip in your libraries folder in your sketches folder.
  3. Move the Cosa (source/header) folder to the Arduino source/header folder. For 1.0.5 that is the folder "arduino-1.0.5/hardware/arduino/cores/arduino".

You havn't done step 3 yet. That's all.

Thanx for the explanation. During my search I came accross some problems about subdirectories & libraries and the fact that this was filed as a bug, accepted, but then again rejected and considered as an Arduino feature! On the other side I use multiple libraries for my own projects (I was told to do so), and guess not able to use subdirectories is a reason, but I never realized this...

I wonder if Code::Blocks suffers from the same problem, as I'm using the Arduino compatible version, but haven't had time to check this.
Code::Blocks btw caches already compiled files, so should be a lot faster, certainly if Cosa is compiled for each sketch, as pito mentioned.

Update: Result from compiling CosaPins.ino in Code::Blocks with the Cosa library in the Arduino folder:

-------------- Build: Arduino Uno in CosaPins (compiler: GNU AVR GCC Compiler)---------------

Compiling: CosaPins.ino
Linking console executable: build\CosaPins_uno.elf
CosaPins.ino: In function 'void setup()':
CosaPins.ino:83: warning: only initialized variables can be placed into program memory area
CosaPins.ino:86: warning: only initialized variables can be placed into program memory area
CosaPins.ino:89: warning: only initialized variables can be placed into program memory area
CosaPins.ino:90: warning: only initialized variables can be placed into program memory area
CosaPins.ino:91: warning: only initialized variables can be placed into program memory area
CosaPins.ino:92: warning: only initialized variables can be placed into program memory area
CosaPins.ino:93: warning: only initialized variables can be placed into program memory area
CosaPins.ino:94: warning: only initialized variables can be placed into program memory area
CosaPins.ino:95: warning: only initialized variables can be placed into program memory area
CosaPins.ino:96: warning: only initialized variables can be placed into program memory area
CosaPins.ino:97: warning: only initialized variables can be placed into program memory area
CosaPins.ino:98: warning: only initialized variables can be placed into program memory area
CosaPins.ino:99: warning: only initialized variables can be placed into program memory area
CosaPins.ino:100: warning: only initialized variables can be placed into program memory area
CosaPins.ino:113: warning: only initialized variables can be placed into program memory area
CosaPins.ino:115: warning: only initialized variables can be placed into program memory area
CosaPins.ino:117: warning: only initialized variables can be placed into program memory area
CosaPins.ino:119: warning: only initialized variables can be placed into program memory area
CosaPins.ino: In function 'void loop()':
CosaPins.ino:131: warning: only initialized variables can be placed into program memory area
CosaPins.ino:134: warning: only initialized variables can be placed into program memory area
CosaPins.ino:138: warning: only initialized variables can be placed into program memory area
CosaPins.ino:143: warning: only initialized variables can be placed into program memory area
CosaPins.ino:146: warning: only initialized variables can be placed into program memory area
CosaPins.ino:147: warning: only initialized variables can be placed into program memory area
CosaPins.ino:148: warning: only initialized variables can be placed into program memory area
CosaPins.ino:149: warning: only initialized variables can be placed into program memory area
build\CosaPins.o: In function `global constructors keyed to _Z11free_memoryv':
CosaPins.ino:(.text._GLOBAL__I__Z11free_memoryv+0x8): undefined reference to `ExternalInterrupt::ExternalInterrupt(Board::ExternalInterruptPin, ExternalInterrupt::Mode)'
CosaPins.ino:(.text._GLOBAL__I__Z11free_memoryv+0xec): undefined reference to `PWMPin::set(unsigned char)'
CosaPins.ino:(.text._GLOBAL__I__Z11free_memoryv+0x120): undefined reference to `vtable for AnalogPin'
CosaPins.ino:(.text._GLOBAL__I__Z11free_memoryv+0x122): undefined reference to `vtable for AnalogPin'
C:\Users\xyz\My Documents\CosaPins\build\/core_uno_16.a(main.cpp.o): In function `main':
main.cpp:(.text.main+0x8): undefined reference to `setup'
main.cpp:(.text.main+0x10): undefined reference to `loop'
Process terminated with status 1 (0 minutes, 4 seconds)
6 errors, 28 warnings (0 minutes, 4 seconds)

Hmmm. Almost there, but not yet :slight_smile: Never seen such errors, but I already discovered that Code::Blocks seems to be more strict than the Arduino IDE.
I don't have an Arduino IDE installed here, but assume that Cosa will compile if installed right!