Go Down

Topic: Want to compile sketches without the Arduino IDE (Read 917 times) previous topic - next topic

Krupski

Hi all,

As the title says, I wish to compile sketches without using the Arduino IDE.

I already read the section on how to do it (Arduino "Build Process") and I think I'm close... the problem I'm running into now is the compiler not finding the libraries.

Here's a test sketch I'm using:

File: test.cpp
Code: [Select]

#include <Arduino.h>

#define uno.build.mcu atmega328p // from boards.txt
#define uno.build.f_cpu 16000000L
#define uno.build.core arduino
#define uno.build.variant standard

void setup(void)
{
        Serial.begin(9600);
}

void loop(void)
{
        Serial.print("It works!\r\n");
        delay(1000);
}


To compile the file, I run "make" and use a generic Makefile (with the proper filename inserted for the CPP file).

This is the error I get:

Quote
test.cpp:1:21: fatal error: Arduino.h: No such file or directory
compilation terminated.
make: *** [test.o] Error 1


And I suspect it's because of an error in the Makefile:

Quote
# List any extra directories to look for include files here.
#     For a directory that has spaces, enclose it in quotes.

EXTRAINCDIRS += "/usr/share/arduino-1.0.2/libraries"
EXTRAINCDIRS += "/usr/share/arduino-1.0.2/hardware/arduino/cores/arduino"


Anyone have any ideas? Are there other library directories I need to point to?

Any help will be appreciated. Thanks!

-- Roger



Gentlemen may prefer Blondes, but Real Men prefer Redheads!

dc42

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Krupski

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

dc42

In that case, I would expect Arduinio.h to be in directory "/usr/share/arduino-1.0.2/hardware/arduino/cores/arduino". Is it?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Krupski


In that case, I would expect Arduinio.h to be in directory "/usr/share/arduino-1.0.2/hardware/arduino/cores/arduino". Is it?


Yes it is, and I pointed to it in the Makefile (see post #1). That's what has me confused.
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

dc42

How is EXTRAINCDIRS used? I've never seen += used in a makefile - are you sure it has the desired effect?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Krupski


How is EXTRAINCDIRS used? I've never seen += used in a makefile - are you sure it has the desired effect?


No, I'm not sure at all.

I just took a makefile from another project and modified it to my needs. I guess I didn't do it correctly.

I've tried all kinds of things. I've even used "#include /usr/share/whole/darn/path/to/library.h" in the source and it still fails.

So that's what I am trying to do... figure out how to compile a sketch without using the Arduino IDE.

As it is, I edit the source with NANO, then click the "upload" button on a very tiny Arduino IDE stuffed up in the corner of my screen. I'd like to get rid of it altogether and use a "real" IDE (oops I know that will bring some wrath down upon me!)  :)
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

pico

There are already several variants of a makefile that have been written to do just what you are (re)doing. I believe they all branch from a version by Martin Oldfield, which in turn stems from a version that actually came with earlier versions if the IDE (but is no longer officially supported.)

I use Martin Oldfield's current version with success. I use Emacs as my editor, and use the M-x compile cmd to invoke the makefile from within Emacs. The compiler warnings/error messages pop up in their own window, as usual, and clicking on any message will take you directly to that line in the file. So a bit more IDE than the "official" IDE, I guess, and certainly a better editor, but if you want integrated hardware debugging, you have to go to an Atmel product and their supporting hardware, at least at this stage. The debugging protocols are proprietary, and they're not telling, apparently.

I haven't tried any of the other variants available, so I can't really comment on relative advantages/disadvantages, but Martin Oldfield's version works fine for me.
WiFi shields/Yun too expensive? Embeddedcoolness.com is now selling the RFXduino nRF24L01+ <-> TCP/IP Linux gateway: Simpler, more affordable, and even more powerful wireless Internet connectivity for *all* your Arduino projects! (nRF24L01+ shield and dev board kits available too.)

dc42

Krupski, if you post the makefile then it will be easier to provide help.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

billroy

Might be good ideas in this one, too: http://ed.am/dev/make/arduino-mk

-br

Krupski

Thank you all (especially PICO). The Makefile by Martin Oldfield worked perfectly. More importantly, it showed me what STEPS need to be done to make "bare" Arduino code compilable.

I've got it all working. Thanks again to all!

-- Roger
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Go Up