user30464: I've written 6 C++ classes on the CLion IDE to be used on Arduino. One of these classes uses a C++ library called "Adafruit_PWMServoDriver.cpp" provided by Adafruit to use the PWM driver they sell. I'm trying to test my code in a main.cpp, but upon building my code, I noticed that "Adafruit_PWMServoDriver.cpp" has the following code:
#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif

Naturally, I copied Arduino.h from the Arduino installation folder to my C++ project header directory. But for reasons I don't know, ARDUINO is apparently not greater than or equal to 100, so it attempts to include "WProgram.h." Because I cannot find this header file, I changed my code to only attempt to include Arduino.h.
#if ARDUINO >= 100
 #include "Arduino.h"
#else
 #include "Arduino.h"
#endif

However, Arduino.h itself includes several header files, and I am not sure where I can find all the find them, or if it is even necessary to try to do so. I need to get my test code running, so I don't want to directly test it in the Arduino IDE yet. What can I do to overcome #include Arduino.h and #include WProgram.h?

user7508: The #if defined (AVR_<various_names>) you see here have nothing to do
with Arduino: this is the avr-libc trying to import the IO register
definitions for the AVR chip you are using. Whenever you compile an AVR
program, you pass the option -mmcu=<mcu-name> to avr-gcc, and it
automatically defines the proper macro. For example, the Arduino Uno is
built around an ATmega328P. Programs for the Uno must then be compiled
with -mmcu=atmega328p, which makes the compiler define
__AVR_ATmega328P__, which directs the avr-libc to
#include <avr/iom328p.h>, which contains all the IO register
definitions for that chip.
As for the ARDUINO macro, this one is defined by the Arduino IDE to be
the version of you Arduino installation, without the dots. For example,
if you downloaded the core files from Arduino 1.8.2, then you should
compile with -DARDUINO=182.
Also, you should avoid copying all the library headers to your project,
and instead use the proper -I options. And don't forget to tell the
compiler your clock frequency with -DF_CPU=..., as it is needed by
some avr-libc and Arduino stuff.
In the end, you will see you need quite a lot of compiler options to
properly compile Arduino code. The easiest way to do it is definitely to
use the Arduino IDE, as it handles all this for you. If you don't like
the IDE (understandable...), you could try Arduino
Builder, which should be
entirely compatible. If you want to compile from just a Makefile, I
recommend you take a look at Sudar Muthu’s Arduino
Makefile.

user10794: The libraries from Adafruit and elsewhere assume you are using the Arduino IDE. If you choose not to use that you will have difficulties compiling your own code. The header files you ask about are in the IDE download. You can always grab a copy of that and put the appropriate .h files into your "include" search path.

However, in my io.h file, there is a long list of #if defined (AVR_various_names).

Well, do a test compile using the Arduino IDE, using "verbose compiling" and see what defines are generated for your particular board (which you haven't mentioned). There won't be that many of them. Then you can put that on the build commands for your IDE.

Or can I avoid all this and somehow create C++ classes independently?

You can create C++ classes inside the Arduino IDE. I don't see how this relates to your other issues.

The Arduino IDE basically generates build commands for avr-g++ - it isn't some horrible beast you should avoid using.

30464: <p>I've written 6 C++ classes on the CLion IDE to be used on Arduino. One of these classes uses a C++ library called "Adafruit_PWMServoDriver.cpp" provided by Adafruit to use the PWM driver they sell. I'm trying to test my code in a main.cpp, but upon building my code, I noticed that "Adafruit_PWMServoDriver.cpp" has the following code:</p>

<pre><code>#if ARDUINO &gt;= 100
 #include "Arduino.h"
#else
 #include "WProgram.h"
#endif
</code></pre>

<p>Naturally, I copied Arduino.h from the Arduino installation folder to my C++ project header directory. But for reasons I don't know, ARDUINO is apparently not greater than or equal to 100, so it attempts to include "WProgram.h." Because I cannot find this header file, I changed my code to only attempt to include Arduino.h.</p>

<pre><code>#if ARDUINO &gt;= 100
 #include "Arduino.h"
#else
 #include "Arduino.h"
#endif
</code></pre>

<p>However, Arduino.h itself includes several header files, and I am not sure where I can find all the find them, or if it is even necessary to try to do so. I need to get my test code running, so I don't want to directly test it in the Arduino IDE yet. What can I do to overcome #include Arduino.h and #include WProgram.h?</p>
 7508: <p>The <code>#if defined (AVR_&lt;various_names&gt;)</code> you see here have nothing to do
with Arduino: this is the avr-libc trying to import the IO register
definitions for the AVR chip you are using. Whenever you compile an AVR
program, you pass the option <code>-mmcu=&lt;mcu-name&gt;</code> to avr-gcc, and it
automatically defines the proper macro. For example, the Arduino Uno is
built around an ATmega328P. Programs for the Uno must then be compiled
with <code>-mmcu=atmega328p</code>, which makes the compiler define
<code>__AVR_ATmega328P__</code>, which directs the avr-libc to
<code>#include &lt;avr/iom328p.h&gt;</code>, which contains all the IO register
definitions for that chip.</p>

<p>As for the <code>ARDUINO</code> macro, this one is defined by the Arduino IDE to be
the version of you Arduino installation, without the dots. For example,
if you downloaded the core files from Arduino 1.8.2, then you should
compile with <code>-DARDUINO=182</code>.</p>

<p>Also, you should avoid copying all the library headers to your project,
and instead use the proper <code>-I</code> options. And don't forget to tell the
compiler your clock frequency with <code>-DF_CPU=...</code>, as it is needed by
some avr-libc and Arduino stuff.</p>

<p>In the end, you will see you need quite a lot of compiler options to
properly compile Arduino code. The easiest way to do it is definitely to
use the Arduino IDE, as it handles all this for you. If you don't like
the IDE (understandable...), you could try <a href="https://github.com/arduino/arduino-builder" rel="nofollow noreferrer">Arduino
Builder</a>, which should be
entirely compatible. If you want to compile from just a Makefile, I
recommend you take a look at <a href="https://github.com/sudar/Arduino-Makefile" rel="nofollow noreferrer">Sudar Muthu’s Arduino
Makefile</a>.</p>
 10794: <p>The libraries from Adafruit and elsewhere <em>assume</em> you are using the Arduino IDE. If you choose not to use that you will have difficulties compiling your own code. The header files you ask about are in the IDE download. You can always grab a copy of that and put the appropriate .h files into your "include" search path.</p>

<blockquote>
  <p>However, in my io.h file, there is a long list of #if defined (AVR_various_names).</p>
</blockquote>

<p>Well, do a test compile using the Arduino IDE, using "verbose compiling" and see what defines are generated for your particular board (which you haven't mentioned). There won't be that many of them. Then you can put that on the build commands for your IDE.</p>

<blockquote>
  <p>Or can I avoid all this and somehow create C++ classes independently?</p>
</blockquote>

<p>You can create C++ classes inside the Arduino IDE. I don't see how this relates to your other issues.</p>

<hr>

<p>The Arduino IDE basically generates build commands for avr-g++ - it isn't some horrible beast you should avoid using.</p>
