Queries on the Compilation Process of C/C++ Codes in Arduino IDE

  1. I am basically an assembly language programmer using AVR Studio 4 where the inclusion of a file like
    .include "m32def.inc" is just enough to carry out the assembly process. All the symbols are
    clearly defined along with their respective numerical addresses.

  2. I have also some working experience on DOS C/C++ where all the required header files and library
    files were available in the relevant directories/folders. We could easily view the header files to see
    the structures of the function prototypes and the definitions of the symbols. The library file, as I
    believed, contained the pre-compiled relocatable executable codes for the language supported
    functions.

I have been trying to understand the structure of C/C++ of Arduino IDE in the light of Step-2; but frankly speaking, I could not make any progress at all. I am including the header file
#include <LiquidCrystal.h> and others similar to it, but I don't know what is there inside this file.

I have read in the Arduino Forum that members are talking about making library file for the built-in LED (L) of the ArduinoUNO. I wish to know the meaning of making library file for it, what does it do in the context of LED (L), and above-all how it is related with addressing and activating the LED(L).

Thanks in advance.

If you are looking for the contents of the library file, there's a few places to go looking on your hard drive.

User-installed (or created) libraries are in My Documents/Arduino/Libraries

Standard Arduino libraries are in Program Files (x86)/Arduino/Libraries (Also look there for the core files.)

Installed boards like the Due have things in C:\users\username\App Data\Local\Arduino15

Where the IDE keeps the libraries depends on the host OS.

Mac OS puts user-installed libraries in ~/Documents/Arduino/libraries

It hides the IDE's built-in libraries inside the Arduino App package (use "Show Package Contents" in contextual menu to get into it)

/Applications/Arduino/Contents/Java/Libraries/LiquidCrystal/src

I think the other OS's make it a bit simpler.

@MorganS

I have found it. I have known what I wanted to know, but I am not sure that I have understood
much. Anyway, thanks a lot for great help; another time I will appear with another query.

MorganS:
User-installed (or created) libraries are in My Documents/Arduino/Libraries

That's the default location on windows but actually it's more correct to say {sketchbook folder}/libraries where sketchbook folder is configured at File > Preferences > Sketchbook Location.

One thing to keep in mind regarding the libraries bundled with Arduino AVR Boards, there is a copy of this hardware package included with the Arduino IDE installation at hardware/arduino/avr but if you have installed a different version then the one in the Arduino IDE installation folder will not be used and instead the one in the Arduino15 (or portable if running in portable mode) folder will be used.

The easiest way to find the source files for a library is to do this:
File > Examples > {library name} > select any example sketch
Sketch > Show Sketch Folder - this will open the {library name}/examples/{example name} folder. You can navigate up to the root folder of the library and you will either find the source files there or in the src or utilities subfolders.

Note that the compiler folders are also in the include search path. This is found inside the tools folder, which may be in the Arduino IDE installation folder at hardware/tools or in the Arduino15/portable folder in various locations depending on which board you're compiling for.

Recent versions of the Arduino IDE will display some useful information in the black console window at the bottom of the Arduino IDE window after compilation if you check File > Preferences > Show verbose output during: > compilation (actually I think this was shown ever with verbose output off until the last release. For example:

Multiple libraries were found for "LiquidCrystal.h"
 Used: E:\Stuff\misc\electronics\arduino\libraries\LiquidCrystal
 Not used: E:\ArduinoIDE\arduino-nightly\libraries\LiquidCrystal
Using library LiquidCrystal at version 1.0.4 in folder: E:\Stuff\misc\electronics\arduino\libraries\LiquidCrystal

If you look through the output in the console you can also see the other folders where the Arduino IDE checks for included files.

GolamMostafa:
I have read in the Arduino Forum that members are talking about making library file for the built-in LED (L) of the ArduinoUNO. I wish to know the meaning of making library file for it, what does it do in the context of LED (L), and above-all how it is related with addressing and activating the LED(L).

Doesn't make sense to me. Please post a link to this thread and we can explain.

This is part of Arduino pre-processing, rather than part of C or C++.
When you add a line like "#include <liquidCrystal.h>" to your sketch, the pre-processor will notice this before it starts the compilation process. It scans a number of higher-level directories that it knows about, including the Arduino Library directory, the board or platform specific library folder, and perhaps elsewhere. If it finds a directory that matches the name of the library, it uses deep knowledge of what the internal structure of an Arduino Library directory is supposed to look like to figure out where the .h file for that library is supposed to be (and perhaps it checks for its existence, given that I think the library directory format may have changed over the years...) (repeat this for each of the #include statements in the sketch, building up a list of the directories.)
When it finishes this pre-processing, it has a list of directories that need to be searched for include files, and it adds those to the compile command that it builds, and the compiler is able to find it. (if it WASN'T in any of the Arduino Library directories, it hopes that it's in one of the compiler include directories.)

So, for the LiquidCrystal example (on my system) the pre-processing searches:

/Applications/arduino/Arduino-1.8.1.app/Contents/Java/libraries/   [color=red](not there.)[/color]
/Applications/arduino/Arduino-1.8.1.app/Contents/Java/hardware/arduino/avr/libraries/ [color=red] (not there either.)[/color]
 /Applications/arduino/Arduino-1.8.1.app/Contents/Java/portable/sketchbook/libraries/  [color=limegreen](ah hah!)[/color]
.../sketchbook/libraries/LiquidCrystal/src/LiquidCrystal.h [color=limegreen](and there is the .h file)[/color]

And the compile command becomes:

"/Applications/arduino/Arduino-1.8.1.app/Contents/Java/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10801 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-I/Applications/arduino/Arduino-1.8.1.app/Contents/Java/hardware/arduino/avr/cores/arduino" "-I/Applications/arduino/Arduino-1.8.1.app/Contents/Java/hardware/arduino/avr/variants/standard" [color=limegreen]"-I/Applications/arduino/Arduino-1.8.1.app/Contents/Java/portable/sketchbook/libraries/LiquidCrystal/src"[/color] "/var/folders/jz/5yb8f2hr8xjcpf0059bsfz4r0000gn/T/arduino_build_711108/sketch/Tardis.ino.cpp" -o "/var/folders/jz/5yb8f2hr8xjcpf0059bsfz4r0000gn/T/arduino_build_711108/sketch/Tardis.ino.cpp.o"