Go Down

Topic: multiple definition of vector problem GSM.h (Read 599 times) previous topic - next topic

patpin

I have a multiple definition of vector problem with my software with GSM.H.
I am not using SoftwareSerial in my code since it is a Mega 2650.
The error:
Code: [Select]
n file included from C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM.h:46:0,

                 from D:\DATA-MEDION\Arduino\testVectorprobleem\testVectorprobleem.ino:1:

C:\Program Files (x86)\Arduino\libraries\GSM\src/GSM3ShieldV1BandManagement.h:49:125: warning: 'typedef' was ignored in this declaration

 typedef enum GSM3GSMBand {UNDEFINED, EGSM_MODE, DCS_MODE, PCS_MODE, EGSM_DCS_MODE, GSM850_PCS_MODE, GSM850_EGSM_DCS_PCS_MODE};

                                                                                                                             ^

libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_9'

libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions

libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_11'

libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_10'

libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.



The code (cleaned)
Code: [Select]
#include <GSM.h>

// initialize the library instance
GSM gsmAccess; // include a 'true' parameter for debug enabled
GSM_SMS sms;
// voor SMS recieven en parsen
// Array to hold the number a SMS is retreived from
char SMSsenderNumber[20]; 
char inchar;


#include <Adafruit_GPS.h>

Adafruit_GPS GPS(&Serial2);



void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

pert

Which GSM hardware (shield, module, etc.) are you using?

patpin

Which GSM hardware (shield, module, etc.) are you using?
Adafruit Ultimate GPS; GSM: GSM SHIELD (ANTENOVA) from Telefonica


patpin

Very similar Shield but the 2 of your "Shield 2" is not present on mine.

pert

OK, that's fine. The reason I asked is because these shields are very rare now, since Arduino stopped making them a long time ago. It's fairly common for people to make the mistake of trying to use the GSM library with other GSM hardware, which it doesn't support. So I wanted to confirm that you are using an Arduino GSM Shield, which the GSM library was written for, before we spend any time trying to help you to troubleshoot the error with that library.


patpin


patpin


Deva_Rishi

nobody an idea?
Well the answer must lie within the gsm.h library in combination with the GPS library, the latter in particular probably does include softwareSerial.h though it is never used, the vectors are still defined. GSM.h uses it's own private version of it which is probably derived from softwareSerial.h (though maybe with a different buffer size) Since you don't use softwareSerial i suggest you modify 1 of the 2 libaries (copy it give it a different name and modify that) to not have a reference to softwareSerial (for the GPS library) or do an #ifdef for the MEGA board (for both) something like that, i haven't successfully installed the GPS library myself so i can't really help you (I should really fix my installation of the IDE some time, sorry about that)
To 'Correct' you have to be Correct. (and not be condescending..)

patpin


patpin

What's the procedure to avoid the conflicts caused by the two softserials. Do I have to change the CPP of the .h and what to remove on one of them. Can I put them in .ini map and change <> to ""?

Deva_Rishi

Quote
What's the procedure to avoid the conflicts caused by the two softserials.
well the issue is mainly that gsm.h has it's own version, if they would both just use softwareSerial.h the issue would not occur (though another one might.)
The best procedure is to decide which library you want to modify, copy that library it to a version with a new name (both .cpp and .h files) and change the headers in the .h and the include in the .cpp, and then include that version in your project instead. Looking at both libraries, i suggest modifying the 'Adafruit_GPS' rather than 'GSM' the latter is very complex and contains quite a lot of different files.
from Adafruit_GPS.h
Code: [Select]
#ifndef _ADAFRUIT_GPS_H
#define _ADAFRUIT_GPS_H

#define USE_SW_SERIAL ///< comment this out if you don't want to include software serial in the library
#define GPS_DEFAULT_I2C_ADDR 0x10  ///< The default address for I2C transport of GPS data
#define GPS_MAX_I2C_TRANSFER 32  ///< The max number of bytes we'll try to read at once
#define GPS_MAX_SPI_TRANSFER 100  ///< The max number of bytes we'll try to read at once

#include "Arduino.h"
#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL)
  #include <SoftwareSerial.h>
#endif
#include <Wire.h>
#include <SPI.h>
and you see there has already been an option created to not include SoftwareSerial.h.
Quote
Can I put them in .ini map and change <> to ""
That is of course an option but actually i suggest you add the condition to exclude SoftwareSerial.h if the board is a MEGA as in this topic,
Code: [Select]
#if (defined(__AVR__) || defined(ESP8266)) && defined(USE_SW_SERIAL) && !(defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)) (i hope i got that right !, the inverted defined .. Actually i think it should have been right from the start, who wants to use swSerial on a MEGA ?
But this does bring me to another matter i have been wondering about, how do you refer which Serial port you use for the GSM ? since it does not happen within the constructor as it does with the GPS, is it possible that the GSM just uses it's own swSerial ? that would not be good, such a waste of processor time and disabling interrupts for extended period of times, this will increase the errors, really we want to use hwSerial for both devices.
To 'Correct' you have to be Correct. (and not be condescending..)

patpin

Thanks. I remember having seen GSM.H or .CPP 'or one of the included libs) including softwSerial.
I 'll report after testing...

patpin

#13
Dec 09, 2019, 01:05 pm Last Edit: Dec 09, 2019, 01:09 pm by patpin
In Adafruit.h I see more than one condition concerning Softserial:

Code: [Select]
#if ARDUINO >= 100
 #include <SoftwareSerial.h>
#else
 #include <NewSoftSerial.h>
#endif

 and furtheron:
Code: [Select]
#if ARDUINO >= 100
 #include "Arduino.h"
#if !defined(__AVR_ATmega32U4__)
 #include "SoftwareSerial.h"
#endif
#else
 #include "WProgram.h"
 #include "NewSoftSerial.h"
#endif

and then:
Code: [Select]
#if ARDUINO >= 100
  Adafruit_GPS(SoftwareSerial *ser); // Constructor when using SoftwareSerial
#else
  Adafruit_GPS(NewSoftSerial  *ser); // Constructor when using NewSoftSerial
#endif
  Adafruit_GPS(HardwareSerial *ser); // Constructor when using HardwareSerial
 

In fact  I do only need the hardwareSerial, not NewSoftSerial. And how do I modify the condition, in all 3?

Deva_Rishi

i thought you were using
Code: [Select]
Adafruit_GPS.h
anyway, the first condition checks if you are using the IDE version 1.0.0 and later, where the newSoftSerial.h became in-built and renamed to SoftwareSerial.h, but you can cover that like this
Code: [Select]
#if !defined(__AVR_ATmega2560__)
  #if ARDUINO >= 100
   #include <SoftwareSerial.h>
  #else
   #include <NewSoftSerial.h>
  #endif
#endif
, the second snippet you could do like this
Code: [Select]
#if ARDUINO >= 100
 #include "Arduino.h"
#if !(defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega2560__))
 #include "SoftwareSerial.h"
#endif
#else
 #include "WProgram.h"
 #if !(defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega2560__))
   #include "NewSoftSerial.h"
  #endif
#endif
note that here the ATmega32U4 (micro) has been excluded since that also has 2 UART ports, but somehow in the original, they do include it for IDE version 00xx,
and for the 3rd
Code: [Select]
#if !defined(__AVR_ATmega2560__)
  #if ARDUINO >= 100
    Adafruit_GPS(SoftwareSerial *ser); // Constructor when using SoftwareSerial
  #else
    Adafruit_GPS(NewSoftSerial  *ser); // Constructor when using NewSoftSerial
  #endif
#endif
  Adafruit_GPS(HardwareSerial *ser); // Constructor when using HardwareSerial
 
Though that final part must have a counterpart within the .cpp file, these are just the prototypes. Again i was looking at a different library, please post the link to github.
To 'Correct' you have to be Correct. (and not be condescending..)

Go Up