Anyone help with Code

I'm trying to compile and I keep getting this
Arduino: 1.8.13 (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)

C:\Users\Jesse\AppData\Local\Temp\ccGhuUDJ.ltrans0.ltrans.o: In function `global constructors keyed to 65535_0_note2.ino.cpp.o.3758':

:(.text.startup+0x7e): undefined reference to `Adafruit_LSM9DS1::Adafruit_LSM9DS1(long)'

:(.text.startup+0x8a): undefined reference to `TTS::TTS(int)'

C:\Users\Jesse\AppData\Local\Temp\ccGhuUDJ.ltrans0.ltrans.o: In function `setup':

C:\Users\Jesse\Desktop\New folder (2)\mainCode\note2/note2.ino:66: undefined reference to `Adafruit_LSM9DS1::begin()'

C:\Users\Jesse\Desktop\New folder (2)\mainCode\note2/note2.ino:72: undefined reference to `Adafruit_LSM9DS1::setupMag(Adafruit_LSM9DS1::lsm9ds1MagGain_t)'

C:\Users\Jesse\AppData\Local\Temp\ccGhuUDJ.ltrans0.ltrans.o: In function `loop':

C:\Users\Jesse\Desktop\New folder (2)\mainCode\note2/note2.ino:112: undefined reference to `Adafruit_LSM9DS1::read()'

C:\Users\Jesse\Desktop\New folder (2)\mainCode\note2/note2.ino:117: undefined reference to `Adafruit_LSM9DS1::getEvent(sensors_event_t*, sensors_event_t*, sensors_event_t*, sensors_event_t*)'

C:\Users\Jesse\Desktop\New folder (2)\mainCode\note2/note2.ino:152: undefined reference to `TTS::sayText(char const*)'

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "Adafruit_SSD1306.h"

Used: C:\Users\Jesse\Documents\Arduino\libraries\Adafruit_SSD1306

Not used: C:\Users\Jesse\Documents\Arduino\libraries\Adafruit_SSD1306_Wemos_Mini_OLED

exit status 1

Error compiling for board Arduino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Without posting your code the error message is not going to do much good.
Clearly you are not using a library correctly or you have not installed it.

It looks like you have the .h files for some of the necessary libraries but you don't have the rest of the library installed.

When the compiler complains that it can't find a .h file that means you have to install the entire library. Installing just the .h file will not get you a successful build.

I have downloaded every library I can think of for this and i'm still getting the error message

Did you use the library manager of the IDE, or did you you use some other method to download and install?

Then you haven’t thought if the right one.
So what about posting your code like I asked for In the first reply?

This is so we can try and compile the code ourselves, then we can find out what you are doing wrong with the library. Please also include a link to any library you have used.

Library manager

The only reason I havent is because there is the main code then 16 other various .h .mod or .cpp files that are attached as well. If you pm me I can send you the zip file?

Start with the examples that come with the library; do they compile? Base your coe on examples / libraries that work.

You can attach a zip file with your code to a post, no need to PM.

code.zip (80.6 KB)

A lot of your problems come from somehow including the original libraries and your local modified libraries. This causes multiple definitions of many library functions. I got the sketch to compile by deleting the local "Adafruit_" files and commenting out #define USE_INTERNAL. Then there was a bunch of warnings, like putting a ':' at the end of several #ifdef lines in sound.cpp and using NULL where you meant the null character: '\0'. There are still plety of warnings:

In file included from sketch/sound.cpp:2:0:
sketch/sound.cpp: In function 'void soundOn(int)':
sketch/sound.h:8:22: warning: large integer implicitly truncated to unsigned type [-Woverflow]
 #define PWM_TOP (1200/2)
                 ~~~~~^~~
sketch/sound.cpp:91:17: note: in expansion of macro 'PWM_TOP'
         OCR2B = PWM_TOP;
                 ^~~~~~~

You can't put 600 in a 1-byte register.

In file included from /Users/john/Library/Arduino15/packages/arduino/hardware/avr/1.8.3/cores/arduino/Arduino.h:28:0,
                 from sketch/TTS.cpp:15:
sketch/TTS.cpp: In function 'int copyToken(char, char*, int, const VOCAB*)':
sketch/TTS.cpp:43:54: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
  if (pgm_read_byte(txt) == token && pgm_read_byte(txt+1) == 0) {
                                                   ~~~^~
sketch/TTS.cpp: In function 'int textToPhonemes(const char*, const VOCAB*, char*)':
sketch/TTS.cpp:89:42: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   char nextVocabChar = pgm_read_byte(text+y);
                                      ~~~~^~
sketch/TTS.cpp:117:45: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
      if (y <= maxMatch || pgm_read_byte(text+y))
                                         ~~~~^~
sketch/TTS.cpp:127:30: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   char c = pgm_read_byte(phon+y);
                          ~~~~^~
sketch/TTS.cpp:131:29: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
       if (pgm_read_byte(phon+y+1) == 0) {
                         ~~~~^~
sketch/TTS.cpp:131:31: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
       if (pgm_read_byte(phon+y+1) == 0) {
                         ~~~~~~^~
sketch/TTS.cpp: In function 'int phonemesToData(const char*, const PHONEME*)':
sketch/TTS.cpp:207:40: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   if (nextChar != pgm_read_byte(ph_text+numChars))
                                 ~~~~~~~^~
sketch/TTS.cpp:216:31: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
      if (pgm_read_byte(ph_text+numChars))
                        ~~~~~~~^~
sketch/TTS.cpp:224:42: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
      for (numOut = 0; pgm_read_byte(ph_ph+numOut); numOut++)
                                     ~~~~~^~
sketch/TTS.cpp:225:54: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
   phonemes[phonemeOut + numOut] = pgm_read_byte(ph_ph+numOut);
                                                 ~~~~~^~

They should be using "byte *", not "void *" for arguments to pgm_read_byte().

Take only the "mainCode.ino" and put it in a new sketch.

Put these three lines at the top of the sketch:

#include <TTS.h> // https://github.com/jscrane/TTS
#include <Adafruit_LSM9DS1.h>
#include <Adafruit_SSD1306.h>

Install the three libraries. The two Adafruit libraries you can get from Library Manager and may require other libraries. The "TTS" (Text to Speech) you download as a TTS-master.zip file from the URL provided above.

Remove this part of "mainCode.ino"

#define USE_INTERNAL

#include <SPI.h>
#include <Wire.h>
#ifdef  USE_INTERNAL
#include "TTS.h"
#include "Adafruit_LSM9DS1_mod.h"
#include "Adafruit_Sensor_mod.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#else
#include <english.h>
#include <sound.h>
#include <TTS.h>
#include <Adafruit_LSM9DS1.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#endif

The sketch should then compile with some warnings. Then you can start to debug it if it isn't doing what you want.

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