# Problem compiling for PWM library

**URL:** <https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943>\
**Category:** General Guidance\
**Created:** [July 19, 2022, 2:58pm UTC](https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943 "2022-07-19T14:58:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![KevinJones](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kevinjones/32/749667_2.png) [@KevinJones](https://forum.arduino.cc/u/KevinJones)\
**Post date:** [July 19, 2022, 2:58pm UTC](https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943/1 "2022-07-19T14:58:45Z")

</div>

I just installed PWM library, but I get errors when trying to compile PWM\_lib\_example.ino:

```arduino
/Users/kevin/Documents/Arduino/libraries/PWM/examples/PWM_lib_example/PWM_lib_example.ino:24: undefined reference to `InitTimersSafe()'
/Users/kevin/Documents/Arduino/libraries/PWM/examples/PWM_lib_example/PWM_lib_example.ino:27: undefined reference to `SetPinFrequencySafe(signed char, unsigned long)'
/var/folders/xg/k651jnd11fsc5hljfrqcpfrc0000gn/T//cckpCPI7.ltrans0.ltrans.o: In function `loop':
/Users/kevin/Documents/Arduino/libraries/PWM/examples/PWM_lib_example/PWM_lib_example.ino:39: undefined reference to `pwmWrite(unsigned char, unsigned char)'

```

According to post #2 in this thread:

> [@Unable to add PWM frequency Library successfully](https://forum.arduino.cc/t/unable-to-add-pwm-frequency-library-successfully/279932):
>
> Hello All, I want to use the PWM frequency library. I have downloaded the zip file from [Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/arduino-pwm-frequency-library/downloads/list). The library details can be found at [PWM frequency library - Libraries - Arduino Forum](http://forum.arduino.cc/index.php?topic=117425.0) I followed the instructions to install the library ([http://arduino.cc/en/Guide/Libraries](http://arduino.cc/en/Guide/Libraries)) however, when i am trying to verify the example present with the library file, below errors are encountered: PWM\_lib\_example.ino: In function 'void setup()': …

I have the file structure set up correctly.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [July 19, 2022, 3:10pm UTC](https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943/2 "2022-07-19T15:10:49Z")

</div>

Do not compile examples in place, in the libraries directory. First copy the example folder (i.e PWM\_lib\_example) to your sketchbook dir and than build it.

---

<div class="post-metadata">

**Author:** ![KevinJones](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kevinjones/32/749667_2.png) [@KevinJones](https://forum.arduino.cc/u/KevinJones)\
**Post date:** [July 19, 2022, 3:15pm UTC](https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943/4 "2022-07-19T15:15:18Z")

</div>

> [@b707](#):
>
> Do not compile examples in place, in the libraries directory. First copy the example folder (i.e PWM\_lib\_example) to your sketchbook dir and than build it.

That did not work. It kinda doesn't make sense anyway as I have been able to run all of my other examples from their respective folders.

---

<div class="post-metadata">

**Author:** ![anon94801460](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@anon94801460](https://forum.arduino.cc/u/anon94801460)\
**Post date:** [July 19, 2022, 3:38pm UTC](https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943/5 "2022-07-19T15:38:29Z")

</div>

> [@KevinJones](#):
>
> I have the file structure set up correctly.

Not if the Arduino IDE can't find the files.

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [July 19, 2022, 3:50pm UTC](https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943/6 "2022-07-19T15:50:52Z")

</div>

> [@KevinJones](#):
>
> Any suggestions?

What arduino board are you using?

And Just a suggestion...the last version of the library dated 2012, the Arduino IDE has changed a lot since then.  
Can you show the path to the dir where the file PWM.h is located?

---

<div class="post-metadata">

**Author:** ![KevinJones](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kevinjones/32/749667_2.png) [@KevinJones](https://forum.arduino.cc/u/KevinJones)\
**Post date:** [July 19, 2022, 3:52pm UTC](https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943/7 "2022-07-19T15:52:07Z")

</div>

> [@b707](#):
>
> What arduino board are you using?

nano every

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [July 19, 2022, 3:54pm UTC](https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943/8 "2022-07-19T15:54:16Z")

</div>

> [@KevinJones](#):
>
> nano every

from the source of the library:

```arduino
/*
This library is built to support two of the AVR Architecture 'groups' that Arduino uses
a) ATmega48/88/168/328,
b) ATmega640/1280/1281/2560/2561
*/

```

If you do not know, nano every is not included to this list

---

<div class="post-metadata">

**Author:** ![KevinJones](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/kevinjones/32/749667_2.png) [@KevinJones](https://forum.arduino.cc/u/KevinJones)\
**Post date:** [July 19, 2022, 4:03pm UTC](https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943/9 "2022-07-19T16:03:39Z")

</div>

> [@b707](#):
>
> from the source of the library:
> 
> ```arduino
> /*
> This library is built to support two of the AVR Architecture 'groups' that Arduino uses
> a) ATmega48/88/168/328,
> b) ATmega640/1280/1281/2560/2561
> */
> 
> ```

Aaaahhh, thank you. Problem solved.

---

<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:** [January 15, 2023, 4:04pm UTC](https://forum.arduino.cc/t/problem-compiling-for-pwm-library/1013943/10 "2023-01-15T16:04:37Z")

</div>

Closed on January 15, 2023, 4:04pm UTC

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