Multiple Definition Error Code

I keep getting this error message when running this code:
Error Message:

C:\Users\Gavin(personal)\AppData\Local\arduino\sketches\9C999848CC5204E05830B48307B9C19F\libraries\Adafruit_APDS9960_Library\Adafruit_APDS9960.cpp.o (symbol from plugin): In function `pow(float, float)':
(.text+0x0): multiple definition of `pow(float, float)'
C:\Users\Gavin(personal)\AppData\Local\arduino\sketches\9C999848CC5204E05830B48307B9C19F\libraries\Adafruit_TCS34725\Adafruit_TCS34725.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1

Compilation error: exit status 1

The Code:

#include "Adafruit_TCS34725.h"
#include "Adafruit_APDS9960.h"
void setup() {
}
void loop() {
}

Welcome

This is not an upload problem but a compile (verify) problem :wink: Hence your topic has been moved to a more suitable category of the forum.

For what board and core?

Never mind. Adafruit defined the function powf in both libraries. And didn't bother to make it static.

Is there any way to use both libraries for one code?

Yup. Edit the .cpp files named and make powf a static function in both.

The problem was raised in the repository 6 months ago and... crickets.

Find the libraries in the libraries sub directory of the sketchbook directory.

Open the .cpp file with a normal editor and modify the line
float powf(const float x, const float y) {
to
static float powf(const float x, const float y) {

Note:
You will loose those changes if you update or downgrade the library !!

@van_der_decken
When you have time, what is the reason that the compiler complains about pow and not about powf?

Prepare yourself for a bit of a headache.

In math.h I found the following:

/**
    The function pow() returns the value of \a __x to the exponent \a __y.
 */
extern double pow(double __x, double __y) __ATTR_CONST__;
#define powf   pow      /**< The alias for pow().  */

So when Adafruit's libraries declared a function called powf the preprocessor renamed it pow.

Here comes the headache: here's Adafruit's powf function:

float powf(const float x, const float y) {
  return (float)(pow((double)x, (double)y));
}

which the processor redoes to:

float pow(const float x, const float y) {
  return (float)(pow((double)x, (double)y));
}

which is why the linker complains about pow rather than powf.

But... looking at the function pow calling the function pow, on the face of it, that looks like infinite recursion. I'm guessing, and it's only a WAG, that it's the function signatures being different that saves it.

Except that in the AVR core, double == float.

So it's the presence of const in Adafruit's function definition that dodges the infinite recursion?

But... given that powf is #defined in math.h... why is this here at all? Does some other tool chain not have powf?

Oww.

And now if you'll excuse me, I need some acetaminophen. Just one or two. Not a whole bottle...

It might be useful to see the OP’s code , there may be another way around this if say both libraries are not needed ?