MLX90614 compile error

I have traced an error in the example code I down loaded to the second line here (I rem-ed it out so it will compile). I stripped down the code in setup and loop to isolate the root cause error. setup and loop are empty. I am just trying to get a basic compile.

#include <Wire.h>
#include <Adafruit_MLX90614.h>

// EVERYTHING OK SO FAR!

// THIS LINE PREVENTS COMPILER FROM FINISHING
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

so there is something wrong with "Adafruit_MLX90614 mlx = Adafruit_MLX90614();"

This is a demo .ino and .h files I downloaded from github. So what is wrong here / what do I have to change to make this one line of code work?

Thank you.

PS: I am a newbie and not much familiar with h files and all that.

With the "Adafruit_MLX90614 mlx = Adafruit_MLX90614();" remmed out I compile. If I take out the rem then the compiler crashes.

You "stripped it down"? You had better post your entire sketch! In code tags.

Also please provide a link to the Github page.

This is the ".h" file I downloaded, the file (Adafruit_MLX90614.h) . I am just trying to at least get the .ino to compile.

#include "Arduino.h"
#include "Wire.h"

#define MLX90614_I2CADDR 0x5A

// RAM
#define MLX90614_RAWIR1 0x04
#define MLX90614_RAWIR2 0x05
#define MLX90614_TA 0x06
#define MLX90614_TOBJ1 0x07
#define MLX90614_TOBJ2 0x08
// EEPROM
#define MLX90614_TOMAX 0x20
#define MLX90614_TOMIN 0x21
#define MLX90614_PWMCTRL 0x22
#define MLX90614_TARANGE 0x23
#define MLX90614_EMISS 0x24
#define MLX90614_CONFIG 0x25
#define MLX90614_ADDR 0x0E
#define MLX90614_ID1 0x3C
#define MLX90614_ID2 0x3D
#define MLX90614_ID3 0x3E
#define MLX90614_ID4 0x3F

class Adafruit_MLX90614 {
public:
Adafruit_MLX90614(uint8_t addr = MLX90614_I2CADDR);
boolean begin();
uint32_t readID(void);

double readObjectTempC(void);
double readAmbientTempC(void);
double readObjectTempF(void);
double readAmbientTempF(void);

private:
float readTemp(uint8_t reg);

uint8_t _addr;
uint16_t read16(uint8_t addr);
void write16(uint8_t addr, uint16_t data);
};

After 275+ posts and being specifically asked to do so, you should really use code tags! You also did not provide the link I asked for. It is not clear whether the code you posted is your "stripped down", or the as-is library code. You need to be much more forthcoming with details.

I don't see any kind of button in my reply box here to insert tags.

Here is the link: Adafruit-MLX90614-Library/Adafruit_MLX90614.h at master · adafruit/Adafruit-MLX90614-Library · GitHub

SamBrownADK:
I don't see any kind of button in my reply box here to insert tags.

Here is the link: Adafruit-MLX90614-Library/Adafruit_MLX90614.h at master · adafruit/Adafruit-MLX90614-Library · GitHub

That is because you have not opened the previously posted reply in "edit" mode. In a new post, you can see all the buttons if you click on "preview".

You still haven't answered my question, "It is not clear whether the code you posted is your "stripped down", or the as-is library code". Please clarify and/or post the actual code that is producing the error.

here is the actual source code

aarg:
#include <Wire.h>
#include <Adafruit_MLX90614.h>

// EVERYTHING OK SO FAR!

// THIS LINE PREVENTS COMPILER FROM FINISHING
Adafruit_MLX90614 mlx = Adafruit_MLX90614();

void setup()
{
}

void loop()
{
}

Do you see any kind of error message?

Hello "AWOL"!

Here is the salient part of the compile message (the thrown error message). I am showing you just the bottom, where the errors in red pop up.

TheMemberFormerlyKnownAsAWOL:
Linking everything together...
"C:\Arduino_ready_to_prg\hardware\tools\avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\Users\ALEJAN~1\AppData\Local\Temp\arduino_build_31870/MLX90614_TEST.ino.elf" "C:\Users\ALEJAN~1\AppData\Local\Temp\arduino_build_31870\sketch\MLX90614_TEST.ino.cpp.o" "C:\Users\ALEJAN~1\AppData\Local\Temp\arduino_build_31870\libraries\Wire\Wire.cpp.o" "C:\Users\ALEJAN~1\AppData\Local\Temp\arduino_build_31870\libraries\Wire\utility\twi.c.o" "C:\Users\ALEJAN~1\AppData\Local\Temp\arduino_build_31870/core\core.a" "-LC:\Users\ALEJAN~1\AppData\Local\Temp\arduino_build_31870" -lm
C:\Users\ALEJAN~1\AppData\Local\Temp\ccQod4Mw.ltrans0.ltrans.o: In function `__static_initialization_and_destruction_0':

E:\MLX90614_TEST/MLX90614_TEST.ino:20: undefined reference to `Adafruit_MLX90614::Adafruit_MLX90614(unsigned char)'

collect2.exe: error: ld returned 1 exit status

Using library Wire at version 1.0 in folder: C:\Arduino_ready_to_prg\hardware\arduino\avr\libraries\Wire
exit status 1
Error compiling for board Arduino Nano.

Did you install the Adafruit library?

aarg:
Did you install the Adafruit library?

If you mean in the IDE, then I have adafruit circuit playground, GFX and SSD1306 installed.

So when you wrote that "the compiler crashes", you were being misleading.

Why?

Why did you use me as the source of the quote of the linker error message, when clearly, I wasn't?
You've been a member here for three years.

I took your code from your reply #7, compiled it for a Uno, and got this error message

/home/.../libraries/Adafruit_MLX90614_Library/Adafruit_MLX90614.cpp: In member function 'uint16_t Adafruit_MLX90614::read16(uint8_t)':
/home/.../libraries/Adafruit_MLX90614_Library/Adafruit_MLX90614.cpp:81:11: warning: unused variable 'pec' [-Wunused-variable]
   uint8_t pec = Wire.read();
           ^
Sketch uses 1446 bytes (4%) of program storage space. Maximum is 32256 bytes.
Global variables use 147 bytes (7%) of dynamic memory, leaving 1901 bytes for local variables. Maximum is 2048 bytes.

aarg wants code and stuff in quotes.

SamBrownADK:
aarg wants code and stuff in quotes.

Wrong.

AWOL and aarg: I use this service sporadically. Thank you for pointing out to me how long I have been a member, how I don't know to use quotes and other things about my personality. Please focus on helping me solve my technical problem and not on your opinions about me personally. Thank you.

SamBrownADK:
AWOL and aarg: I use this service sporadically. Thank you for pointing out to me how long I have been a member, how I don't know to use quotes and other things about my personality. Please focus on helping me solve my technical problem and not on your opinions about me personally. Thank you.

It is not directed at you personally, but simply as a forum user. All forum users should be able to follow the guidelines, they are not really very stringent. All of them are based on practical requirements of solving technical problems in the most efficient way.

In this case, things have dragged on quite a bit because you haven't answered crucial questions completely or at all.

I am at an impasse. I think I gave the source code to the program and the .h file and the error. I do not have the depth of knowledge to understand why i can not compile the simple program

SamBrownADK:
I am at an impasse. I think I gave the source code to the program and the .h file and the error. I do not have the depth of knowledge to understand why i can not compile the simple program

The source code compiled without errors for @Awol.

In my opinion, you do not have the right library installed, or else you have the right library incorrectly installed. You should have a second look in your library folder.

There is a library manager in the IDE now. I usually don't have to use it, as the libraries I use are often not packaged for the manager. Manual library installation has some "gotchas". You have to read the instructions carefully.

Just to be clear, I simply used the library manager in the IDE to install the Adafruit library, and then cut and pasted the OP's code into a fresh IDE window.