multiple definition of vector problem GSM.h

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:

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)

 #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:

}

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

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

Adafruit Ultimate GPS; GSM: GSM SHIELD (ANTENOVA) from Telefonica

Are you talking about this one?

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

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.

thanks in advance!

nobody an idea?

patpin:
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)

Thanks for info Deva

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 ""?

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

#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.

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, #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.

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

In Adafruit.h I see more than one condition concerning Softserial:

 #if ARDUINO >= 100
 #include <SoftwareSerial.h>
#else
 #include <NewSoftSerial.h>
#endif

and furtheron:

 #if ARDUINO >= 100
 #include "Arduino.h"
#if !defined(__AVR_ATmega32U4__)
 #include "SoftwareSerial.h"
#endif
#else
 #include "WProgram.h"
 #include "NewSoftSerial.h"
#endif

and then:

 #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?

i thought you were usingAdafruit_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

#if !defined(__AVR_ATmega2560__)
  #if ARDUINO >= 100
   #include <SoftwareSerial.h>
  #else
   #include <NewSoftSerial.h>
  #endif
#endif

, the second snippet you could do like this

#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

#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.

Sorry, my first line of post #13 should have been "In Adafruit_GPS.h" …..
Thanks for correcting the code!!! But how can the program know on which Serialx I connected the GSM and the GPS when I don't use SoftwareSerial? Is there a specific command?

patpin:
Thanks for correcting the code!!! But how can the program know on which Serialx I connected the GSM and the GPS when I don't use SoftwareSerial? Is there a specific command?

with the gps it is done in the constructor Adafruit_GPS GPS(&Serial2); and you can either put the reference there to a swSerial object you've created or a reference to a hwSerial (which is what you've done)
as for the GSM.h i am wondering myself (i actually asked already) the GSM.h is a complex library, and of course there must be a way changing what it uses, but in principal i think it made for a specific shield that fits onto an UNO, pff now we will have to sift through the GSM.h, I had a brief look, but it wasn't apparent straight away, it must be possible otherwise maybe by using a different library. (please post a link to the library you are using or we will not be looking in the same spot) did you get the GSM to work already ? (without the gps)

I have not tested yet on MEGA. In the mean time I think I found the source of my GSM lib.GitHub - BlueVia/Official-Arduino: Arduino GPRS/GSM Shield Sample Code
There I found a GSM3Softserial.cpp where the MEGA pins are mentioned ! Room for adaption overthere I guess...

Ah yes that is the same library i had been looking at.

There I found a GSM3Softserial.cpp where the MEGA pins are mentioned ! Room for adaption overthere I guess...

well, those pins are for using the softSerial method, hwSerial is on pins 14-19 (or 0 & 1) And with the size of that library, just finding a way to make it use hwSerial instead is not going to be easy. (actually a bit beyond me, the library is just so extensive.)

I did some more digging, but so far no clear cut answers, there is this thread on stack-exchange, but it is already 5 years old, it does suggest what you could do, re-writing the functions that deal with the reading and writing, but somehow i don't think it is as easy as that, ideally you would want to find where those functions are being referenced, and also where data is being written into the buffer. tbh i think looking for an alternate library might be quite a good idea, since really fiddling with this code is a tad tricky, though we could experiment. The author states :

So, after replacing the code inside the functions (finalWrite, the ISRs, and the begin/clear seem like the ones you should touch), compile the code and see if it works!

Though i would prefer to see in which file GSM3SoftSerial.h is actually included, and modify the function that are calling those functions for their hwSerial variant.