Pages: [1]   Go Down
Author Topic: Want to compile sketches without the Arduino IDE  (Read 763 times)
0 Members and 1 Guest are viewing this topic.
Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 808
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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



Logged

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Which operating system are you using?
Logged

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.

Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 808
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Which operating system are you using?

Linux (Ubuntu 64 bit).
Logged

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 808
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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.

Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 808
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!)  smiley
Logged

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Offline Offline
God Member
*****
Karma: 32
Posts: 830
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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.)

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6637
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Krupski, if you post the makefile then it will be easier to provide help.
Logged

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.

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

-br
Logged

Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 808
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Pages: [1]   Go Up
Jump to: