16

I've been looking for a while inside Arduino's files to find the core library. However, I haven't found them yet. Where on my hard drive can I obtain the core library files (.cpp and .h) necessary for all Arduino code?

Looking around on Google, I couldn't find a way to find the above files. I did see something about getting an .a file while Arduino is compiling, however, that isn't what I want. I want to browse the code and look at functions such as delay to see how they would react when given the values not expected. (i.e. Will my code stall if I use delay(-200); by not being to exit the loop, or will it create a black hole and disrupt the space-time continuum?)

2
  • I was interested in the question, but what I want is the source code for strcpy and strcat in assembler source code. I downloaded the Master Library but I cannot locate anything remotely similar to strcpy or strcat. OR Maybe I cannot see the wood for the trees?
    – bobzic
    Commented Dec 11, 2014 at 8:51
  • @bobzic I suggest that you ask another question specifying which files you want to find. Commented Dec 11, 2014 at 12:34

6 Answers 6

10

The base Arduino source files are in the Arduino installation, under cores/arduino/. Source for additional libraries included are in libraries/.

3
  • And don't forget /usr/lib/avr/include/ or whatever that translates to on non-Linux systems.
    – jippie
    Commented Mar 21, 2014 at 18:04
  • Too bad I installed it as Windows 10 app and cannot access the installation folder. Commented Apr 18, 2019 at 2:36
  • This information seems outdated. The libraries folder is empty now and hardware has moved Commented Apr 2, 2020 at 19:51
13

The code is also available online for those times you don't have the IDE installed:

https://github.com/arduino/Arduino

2
9

On a Mac, the path to the source code folder is:
Arduino.app/Contents/Resources/Java/Hardware/Arduino/Cores/Arduino. I'd expect it would be the same from /Java/ on down in other OSes.

Path to library sources (Arduino-Mac)

4

The arduino source files can be found on Github at https://github.com/arduino/Arduino, however the libraries have been moved to their own repositories:

3

There are multiple places where you can look. As at IDE 1.6.4 (Ubuntu version) some are in:

(install location)/libraries

But these are the high-level libraries, in particular:

Bridge
Esplora
Ethernet
Firmata
GSM
LiquidCrystal
Robot_Control
RobotIRremote
Robot_Motor
SD
Servo
SpacebrewYun
Stepper
Temboo
TFT
WiFi

That does not cover the low-level libraries like Tone, Print, main, etc. These are in:

(install location)/hardware/arduino/avr/cores/arduino

There you would find the Arduino core libraries like:

abi.cpp
Arduino.h
binary.h
CDC.cpp
Client.h
HardwareSerial0.cpp
HardwareSerial1.cpp
HardwareSerial2.cpp
HardwareSerial3.cpp
HardwareSerial.cpp
HardwareSerial.h
HardwareSerial_private.h
HID.cpp
hooks.c
IPAddress.cpp
IPAddress.h
main.cpp
new.cpp
new.h
Printable.h
Print.cpp
Print.h
Server.h
Stream.cpp
Stream.h
Tone.cpp
Udp.h
USBAPI.h
USBCore.cpp
USBCore.h
USBDesc.h
WCharacter.h
WInterrupts.c
wiring_analog.c
wiring.c
wiring_digital.c
wiring_private.h
wiring_pulse.c
wiring_shift.c
WMath.cpp
WString.cpp
WString.h

However even that does not locate things like strcpy. The header files for them can be found at:

(install location)/hardware/tools/avr/avr/include/

There you will find:

alloca.h
assert.h
ctype.h
errno.h
inttypes.h
math.h
setjmp.h
stdfix-avrlibc.h
stdint.h
stdio.h
stdlib.h
string.h

Even that is not the full story. In a subdirectory (avr) you will find the avr-related things, with files for different processors, such as (in part):

boot.h
builtins.h
common.h
cpufunc.h
crc16.h
delay.h
eeprom.h
fuse.h
interrupt.h
io1200.h
io2313.h
...
iox64d4.h
iox8e5.h
lock.h
parity.h
pgmspace.h
portpins.h
power.h
sfr_defs.h
signal.h
signature.h
sleep.h
version.h
wdt.h
xmega.h

As for the source of strcpy, I don't think it is in the distribution. They include the standard libraries, pre-compiled. For example, if you look in:

(install location)/hardware/tools/avr/avr/lib

You will see various pre-compiled libraries, for example:

libc.a
libm.a
libprintf_flt.a
libprintf_min.a
libscanf_flt.a
libscanf_min.a

To find the source you would need to find where the AVR source of libc is (possibly at http://www.nongnu.org/avr-libc/).


As for the Mac, all this stuff is a few levels down in the "Application Package" which you can view by right-clicking and selecting "Show Package Contents". Look in the Contents/Resources/Java folder.


None of these places are where you should put your own libraries (ones you write or download). They should go into the libraries folder which is a subdirectory of your sketchbook folder. Create the libraries folder if it does not exist. That way user-installed libraries persist from one version of the IDE to the next.

1

I think this may have changed in newer versions. On my Mac Big Sur, Arduino 1.8.15 they are here: /Applications/Arduino.app/Contents/Java/libraries

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.