# No .cpp or .h files in arduino-timer library

**URL:** <https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577>\
**Category:** Libraries\
**Created:** [April 10, 2022, 9:53pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577 "2022-04-10T21:53:28Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgmoroz](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jgmoroz](https://forum.arduino.cc/u/jgmoroz)\
**Post date:** [April 10, 2022, 9:53pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/1 "2022-04-10T21:53:28Z")

</div>

I have experience with a few libraries and assumed that there must be a .cpp and .h fils included in the library along with examples and other stuff.

I tried to compile and sketch errored on the #include \<arduino-timer.h\>.

The library was listed in IDE library manager folder (installed), and I can see it in the Audrino/Libraries shown below.

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/d/6/9/d6962f0c957a7c1c4f2addd15a983d2a83988826.png)

Please advise  
Jim

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [April 10, 2022, 10:02pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/2 "2022-04-10T22:02:02Z")

</div>

What files are in the src folder of the library ?

I have  
 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/7/d/3/7d328851a2290bfafc2e28264499566e8ad755d7.png)

Exactly which sketch were you trying to compile ?

---

<div class="post-metadata">

**Author:** ![jgmoroz](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jgmoroz](https://forum.arduino.cc/u/jgmoroz)\
**Post date:** [April 11, 2022, 7:09pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/3 "2022-04-11T19:09:23Z")

</div>

I used the timer\_full sketch which is one of the examples from the arduino-timer lib  
It faulted on the bolded statement below:

```arduino
/*
 * timer_full
 *
 * Full example using the arduino-timer library.
 * - Setting a different number of tasks with microsecond resolution
 * - disabling a repeated function
 * - running a function after a delay
 * - cancelling a task
 *
 */
#include <arduino-timer.h>
****auto timer = timer_create_default()**;** // create a timer with default settings
Timer<> default_timer; // save as above

```

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_--

The Output window showed the following

> Alternatives for arduino-timer.h: []  
> ResolveLibrary(arduino-timer.h)  
> -\> candidates: []  
> C:\Users\jgmor\OneDrive\Documents\Microcontroller Hardware and Software\Arduino\Anemometer\timer\_full\Using%20Clock%20only%20Failed\_copy\_20220411120655\Using%20Clock%20only%20Failed\_copy\_20220411120655.ino:14:10: fatal error: arduino-timer.h: No such file or directory  
> compilation terminated.
> 
> Compilation error: exit status 1

* * *

I also have your header files, and I thought that I need the arduino-timer.cpp file that contains the code like my other libraries.

Please explain  
Thanks

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [April 11, 2022, 7:41pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/4 "2022-04-11T19:41:06Z")

</div>

Whilst there is a convention that both .h and .cpp files must be used in a C++ library they do not have to be. It is sufficient for there to be just a .h file and for all of the library code to be in it, not just declarations of variables and functions

---

<div class="post-metadata">

**Author:** ![jgmoroz](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jgmoroz](https://forum.arduino.cc/u/jgmoroz)\
**Post date:** [April 12, 2022, 3:59am UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/5 "2022-04-12T03:59:23Z")

</div>

Thanks

I checked and made sure that arduino-timer is compatible with UNO and it is.

The complier stopped at:  
timer\_create\_default(), // create a timer with the default settings

I searched the .h file and found:  
inline Timer\<\>  
timer\_create\_default()  
{  
return Timer\<\>();

I cant find "inline" but it looks like this is the function invoked by the .ini sketch.

I am really stuck. I don't understand why the compiler fails on an example listed within it the example list within its own library.

Any suggestions?

Jim

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [April 12, 2022, 4:23am UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/6 "2022-04-12T04:23:41Z")

</div>

First of all, let's remove as much irrelevant complexity from the system as possible.

You are getting distracted by looking at this code, but it is almost certain that it is irrelevant to the problem. If you examine the error message:

> [@jgmoroz](#):
>
> ```plaintext
> fatal error: arduino-timer.h: No such file or directory
> 
> ```

It clearly points to the problem being with this line of the sketch:

> [@jgmoroz](#):
>
> ```cpp
> #include <arduino-timer.h>
> 
> ```

This can be checked via a simple experiment.

Change the sketch code to this:

```cpp
#include <arduino-timer.h>
void setup() {}
void loop() {}

```

Now try compiling the sketch again. Does the error still occur?

---

<div class="post-metadata">

**Author:** ![jgmoroz](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jgmoroz](https://forum.arduino.cc/u/jgmoroz)\
**Post date:** [April 12, 2022, 2:30pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/7 "2022-04-12T14:30:13Z")

</div>

> [@in0](#):
>
> This may be helpful. Please explain what this proves and next steps.
> 
> ```arduino
> #include <arduino-timer.h>
> void setup() {}
> void loop() {}
> 
> ```

```arduino
Using board 'uno' from platform in folder: C:\Users\jgmor\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5
Using core 'arduino' from platform in folder: C:\Users\jgmor\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5
Detecting libraries used...
"C:\\Users\\jgmor\\AppData\\Local\\Arduino15\\packages\\arduino\\tools\\avr-gcc\\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Users\\jgmor\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.5\\cores\\arduino" "-IC:\\Users\\jgmor\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.8.5\\variants\\standard" "C:\\Users\\jgmor\\AppData\\Local\\Temp\\arduino-sketch-9823A3348E53AA13FABDFF2DF01EF4D5\\sketch\\arduino-timer test.ino.cpp" -o nul
Alternatives for arduino-timer.h: []
ResolveLibrary(arduino-timer.h)
C:\Users\jgmor\OneDrive\Documents\Microcontroller Hardware and Software\Arduino\Anemometer\arduino-timer test\arduino-timer test.ino:1:10: fatal error: arduino-timer.h: No such file or directory
 void setup() {
          ^ ~~~~            
compilation terminated.
  -> candidates: []

Compilation error: exit status 1

```

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [April 12, 2022, 3:11pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/8 "2022-04-12T15:11:15Z")

</div>

> [@in0](#):
>
> This may be helpful.

I think so, in that we are distilling the problem down to something more simple and thus easier to troubleshoot.

> [@in0](#):
>
> Please explain what this proves

This proves that none of the code from the more complex sketch is related to the error. So we don't need to think about any of that. We know for certain that here is nothing wrong with the bare minimum part of the sketch code:

```cpp
void setup() {}
void loop() {}

```

> [@in0](#):
>
> next steps.

Please do this:

1. Select **File \> Preferences** from the Arduino IDE menus.
2. Select and copy the contents of the " **Sketchbook location**" field
3. Press **Ctrl+A** to select all the text.
4. Press **Ctrl+C**.  
This will [copy](https://lifehacker.com/how-to-copy-cut-and-paste-for-beginners-5801525) the selected text to the clipboard.
5. Use **Ctrl+V** to paste the copied output to a reply here.

---

<div class="post-metadata">

**Author:** ![jgmoroz](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jgmoroz](https://forum.arduino.cc/u/jgmoroz)\
**Post date:** [April 12, 2022, 5:54pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/9 "2022-04-12T17:54:20Z")

</div>

c:\Users\jgmor\OneDrive\Documents\Microcontroller Hardware and Software\Arduino\Anemometer

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [April 12, 2022, 6:21pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/10 "2022-04-12T18:21:07Z")

</div>

OK, I see the problem now.

Libraries must be saved to the `libraries` subfolder of the path specified by the " **Sketchbook location**" preference.

So in your case the " **arduino-timer**" library would need to be installed here in order for the Arduino build system to find it while compiling your sketch:

```plaintext
c:\Users\jgmor\OneDrive\Documents\Microcontroller Hardware and Software\Arduino\Anemometer\libraries\arduino-timer

```

But from the screenshot [you shared](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577), I can see that the library is in a different location:

```plaintext
c:\Users\jgmor\OneDrive\Documents\Microcontroller Hardware and Software\Arduino\libraries\arduino-timer

```

 ![image](https://europe1.discourse-cdn.com/arduino/original/4X/2/d/1/2d1b7d6790172f9fa9bfe3b3ab2161f084e120a4.png)

So if you want to keep your current " **Sketchbook location**" setting, you should reinstall the library. I'll provide you with instructions for doing that:

1. Select **File \> Quit** from the Arduino IDE menus if it is running.
2. Start the Arduino IDE.  
**ⓘ** This restart is needed due to a bug in the beta phase Arduino IDE 2.x (which I can tell you are using from the output): [`arduino/arduino-ide#796`](https://github.com/arduino/arduino-ide/issues/796)
3. Select **Sketch \> Include Library \> Manage Libraries...** from the Arduino IDE menus to open the " **Library Manager**" view.
4. Click on the " **Filter your search...**" field.
5. Enter the following text: `arduino-timer`
6. You should see " **arduino-timer by Michael Contreras**" in the " **Library Manager**" search results. Click on it.
7. Click the INSTALL button.
8. Wait until you see the notification:

> Successfully installed library arduino-timer:2.3.1

Now try compiling your sketch again.

You will also need to reinstall any other libraries you installed before changing your " **Sketchbook location**" preference (and even any you installed during the session after changing the preference due to [`arduino/arduino-ide#796`](https://github.com/arduino/arduino-ide/issues/796)).

---

<div class="post-metadata">

**Author:** ![jgmoroz](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jgmoroz](https://forum.arduino.cc/u/jgmoroz)\
**Post date:** [April 13, 2022, 10:05pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/11 "2022-04-13T22:05:02Z")

</div>

Still trying to get my head around the file Arduino file schema.

Please confirm my understanding below:

1. Set the sketchbook location to the folder that contains the library folder:  
c:\Users\jgmor\OneDrive\Documents\Microcontroller Hardware and Software\Arduino  
This folder contains the library folder.

I then saved as a sketch that compiled/uploaded/ran, to the folder, Anemometer  
Jim 5, that was under the previous Aucrino folder. This sketch required no #include command.

This sketch failed to recognize the commands/function that are non-C++, arduino functions/commands as shown below:

* * *

Serial.begin(9600);// Open serial communications  
^ ~~~~~  
pinMode(AnmCnt,INPUT); // Set Anemometer contact to AnmCnt  
^ ~~~~  
pinMode(AnmCnt,INPUT); // Set Anemometer contact to AnmCnt  
^ ~~~~~~  
delay  
Serial.println(AnmPls)

* * *

I think these commands need the Arduino library access because they are not standard C++ functions. This is conjecture only. Is this right?

2 in order to use the folders to organize sketches in arduino/anenometer and arduino/raingauge, I need to first create these folders (file explorer), close the ide, then move the folder under arduino to these folders.

Is this correct?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [April 14, 2022, 8:54am UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/12 "2022-04-14T08:54:29Z")

</div>

> [@jgmoroz](#):
>
> Set the sketchbook location to the folder that contains the library folder

Wrong. It should be "Set the sketchbook location to the folder that contains the `libraries` folder".

The `libraries` folder is where your libraries are stored. Each library is in a separate folder under the `libraries` folder.

For example:

```plaintext
<sketchbook location>/
└── libraries/
    └── arduino-timer/
        ├── CONTRIBUTING.md
        ├── LICENSE
        ├── Makefile
        ├── README.md
        ├── examples/
        ├── extras/
        ├── keywords.txt
        ├── library.properties
        └── src/

```

> [@jgmoroz](#):
>
> I then saved as a sketch that compiled/uploaded/ran, to the folder, Anemometer  
> Jim 5, that was under the previous Aucrino folder.

I don't have enough information to be able to determine the cause. Please put the entire "Anemometer Jim 5" (or whatever it is) folder in a ZIP file and attach it in a reply here.

> [@jgmoroz](#):
>
> 2 in order to use the folders to organize sketches in arduino/anenometer and arduino/raingauge, I need to first create these folders (file explorer), close the ide, then move the folder under arduino to these folders.

It is not really clear to me what you are asking, but you certainly are not required to use Windows File Explorer. You can create folders and save sketches anywhere you like via " **File \> Save as...**" in the Arduino IDE. In fact, I would recommend you to use that rather than messing with the sketch folders directly because it will make it more likely that the sketch is saved in the correct format (the sketch is a folder, not a file, and the folder must contain a `.ino` file matching the folder name).

---

<div class="post-metadata">

**Author:** ![jgmoroz](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jgmoroz](https://forum.arduino.cc/u/jgmoroz)\
**Post date:** [April 16, 2022, 11:01pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/13 "2022-04-16T23:01:03Z")

</div>

Thank you very much for your patience.

Where did you get the symbols:  
└──  
└──  
├──

They are very helpful in describing the file structure necessary for Arduino. They would be very useful to me since I am struggling with communicating my proposed file structure in my narritive.

Thanks  
Jim

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [April 17, 2022, 5:31am UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/14 "2022-04-17T05:31:59Z")

</div>

You are welcome.

Effectively describing file system structures in text is the sort of subject I find very interesting. I spent some time considering various approaches and have settled on the format you see in my previous reply.

This is the output from the `tree` tool:

> **[tree (command)](https://en.wikipedia.org/wiki/Tree_(command))**
>
> In computing, tree is a recursive directory listing command or program that produces a depth-indented listing of files. Originating in PC- and MS-DOS, it is found in Digital Research FlexOS, IBM/Toshiba 4690 OS, PTS-DOS, FreeDOS, IBM OS/2, Microsoft Windows, and ReactOS. A version for Unix and Unix-like systems is also available.
> The tree command is frequently used as part of a technical support scam, where the command is used to occupy the command prompt screen, while the scammer, pretending to...

## Installation

### Windows

There is [a native Windows version (tree.com)](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/tree) but I don't like the way it lists files as much as the Linux version. Fortunately, you can get that version for Windows as well. I sourced it here:

> **[GnuWin - Browse /tree at SourceForge.net](https://sourceforge.net/projects/gnuwin32/files/tree/)**
>
> Provides native Win32 open source ports and utilities

### Linux

You should be able to get it from any package manager. I use " **APT**" after finding that the security sandboxing imposed by " **SnapCraft**" on that package interfered with my ability to use `tree` as I needed.

```plaintext
apt install tree

```

### macOS

I haven't tried it, but I see there is a " **Homebrew**" formulae, which would likely be the preferred installation approach if it is not pre-installed:

```plaintext
brew install tree

```

## Usage

I use it like this:

```plaintext
tree -AF <path>/

```

### `-A` flag

The reason I use the `-A` flag is to ensure the nicer folder structure indicator characters. Without it, the output looks like this:

```plaintext
> tree foo

foo
|-- bar
| `-- bar-file.txt
|-- baz
| |-- baz-file.txt
| `-- baz-sub
| `-- baz-sub-file.txt
`-- foo-file.txt

```

Unfortunately, you might find that the command shell (" **cmd**" or " **PowerShell**") can not properly output the ANSI lines produced by `-A`. I recommend using " **Git Bash**", which is part of the " **Git For Windows**" installation:

> **[Git - Install for Windows](https://git-scm.com/download/win)**

### `-F` flag

The reason I use the `-F` flag is to differentiate empty folders from files:

```plaintext
$ tree -A foo

foo
├── bar
│ └── bar-file.txt
├── empty
└── foo-file.txt

```

😕 is `empty` a folder or a file?

```plaintext
$ tree -A -F foo

foo
├── bar/
│ └── bar-file.txt
├── empty/
└── foo-file.txt

```

🙂 all is clear!

### Trailing `/`

The reason I use the trailing `/` on the path argument is for consistency with the trailing `/` added to the subfolders by the `-F` flag:

```plaintext
$ tree -A -F foo/

foo/
├── bar/
│ └── bar-file.txt
├── empty/
└── foo-file.txt

```

---

<div class="post-metadata">

**Author:** ![jgmoroz](https://avatars.discourse-cdn.com/v4/letter/j/2acd7d/32.png) [@jgmoroz](https://forum.arduino.cc/u/jgmoroz)\
**Post date:** [April 20, 2022, 7:37pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/15 "2022-04-20T19:37:15Z")

</div>

Using your recommendation and explanation of the "TREE" command. I took relevant sections from my directory that include 6 more projects that are not shown.

```cpp
c:\Users\jgmor\OneDrive\Documents\Microcontroller Hardware and Software\Arduino>TREE
├───libraries
│ ├───Adafruit_AHT10
│ │ ├───assets
│ │ └───examples
│ │ ├───adafruit_aht10_test
│ │ └───adafruit_aht10_unifiedsensors
│ ├───Adafruit_BusIO
│ │ └───examples
│ │ ├───i2corspi_register
│ │ ├───i2c_address_detect
│ │ ├───i2c_readwrite
│ │ ├───i2c_registers
│ │ ├───spi_modetest
│ │ ├───spi_readwrite
│ │ ├───spi_registers
│ │ └───spi_register_bits
│ ├───Adafruit_Unified_Sensor
│ │ └───examples
│ │ └───sensortest
│ ├───ADSWeather-0.1.1
│ │ ├───examples
│ │ ├───Extras
│ │ └───src
│ ├───arduino-timer
│ │ ├───examples
│ │ │ ├───blink
│ │ │ ├───blink_micros
│ │ │ ├───blink_print
│ │ │ └───full

└───Weather Station
    ├───Aduino Timer Tests
    │ └───1 min task scheduler
    ├───Anemometer
    │ ├───Anemometer Jim 1
    │ │ └───Anemometer Jim 1
    │ ├───Anemometer Jim 2
    │ ├───anemometer_rev1
    │ ├───anemometer_rev1_Hans
    │ ├───Anenometer Jim 3
    │ └───arduino-timer test
    └───Raingauge
        └───Raingauge Jim 3

```

* * *

I organized the entire project: Weather Station  
into its component sketches: Anemometer, Raingauge, and Audrino Timer test (working on currenntly).

Everything compiles, everything uploads, and I learned some commands for the command line window that allowed me to make these drawings.

Thank you very much for your help.  
Jim Moroz

---

<div class="post-metadata">

**Author:** ![in0](https://avatars.discourse-cdn.com/v4/letter/i/77aa72/32.png) [@in0](https://forum.arduino.cc/u/in0)\
**Post date:** [April 20, 2022, 10:11pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/16 "2022-04-20T22:11:30Z")

</div>

Very nice! I'm glad everything is working for you.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [October 17, 2022, 10:11pm UTC](https://forum.arduino.cc/t/no-cpp-or-h-files-in-arduino-timer-library/979577/17 "2022-10-17T22:11:50Z")

</div>

Closed on October 17, 2022, 10:11pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
