Why am I getting this error?

I am trying to modify a library I created to be able to use with Arduino UNO R4 Wifi.

The code below compiles with no issue in IDE v2.3.2 if I select to compile for a Mega, but if I select UNO R4 Wifi as board I am getting this following error:

C:\Users\sherz\AppData\Local\Temp\arduino\sketches\800F4B443EAAA27A181C00ED62FB9F67\sketch\LIN_ReadWrite.ino.cpp.o: In function setup': C:\Users\sherz\OneDrive\Documents\Arduino\libraries\LIN-v.14\example\LIN_ReadWrite/LIN_ReadWrite.ino:26: undefined reference to LIN'
C:\Users\sherz\AppData\Local\Temp\arduino\sketches\800F4B443EAAA27A181C00ED62FB9F67\sketch\LIN_ReadWrite.ino.cpp.o: In function loop': C:\Users\sherz\OneDrive\Documents\Arduino\libraries\LIN-v.14\example\LIN_ReadWrite/LIN_ReadWrite.ino:68: undefined reference to LIN'
collect2.exe: error: ld returned 1 exit status

Using library LIN-v.14 in folder: C:\Users\sherz\OneDrive\Documents\Arduino\libraries\LIN-v.14 (legacy)
exit status 1

Compilation error: exit status 1

Any suggestions how to resolve this?

R4 Wifi INO code:

#include <LIN.h>

#define LIN_BAUD1 9600
#define LIN_BAUD2 19200UL

const uint8_t msg_pid = 0x0D;
const uint8_t msg_dlc = 4;
uint8_t msg_Data[msg_dlc] = {0x00,0x79,0x00,0x00};
uint8_t Checksum; 

void setup() {
  Serial.begin(115200); 
  Serial1.begin(LIN_BAUD1);
  Serial.println("READY");
  
  Checksum = LIN.GetChecksum(msg_pid, msg_Data, msg_dlc, ENHANCED); //assuming LIN Version Protocol 2.x

}

void loop() {
  Serial.print("\nSending LIN FRAME...");
  LIN.SendHeaderFrame(Serial1, msg_pid);
  LIN.SendDataFrame(Serial1, msg_Data , msg_dlc, Checksum);
  ++msg_Data[3];
  Checksum = LIN.GetChecksum(msg_pid, msg_Data, msg_dlc, ENHANCED); //refesh checksum value
  
  delay(1000); //arbitrary delay
  
  while (Serial1.available()) {
    LIN.RxData = Serial1.read();

    if (LIN.RxDataType() == BREAKFIELD) {
      Serial.println("");
    }
    else if (LIN.RxDataType() == NEW_FRAME) {
      Serial.println("");
      Serial.print("New Frame: ");
      Serial.print(LIN.RxDataValue(), HEX);
      Serial.print(", ");
    }
    else if (LIN.RxDataType() == SYNC) {
      Serial.print("Sync: ");
      Serial.print(LIN.RxDataValue(), HEX);
      Serial.print(", ");
    }
    else if (LIN.RxDataType() == PID) {
      Serial.print("PID: ");
      Serial.print(LIN.RxDataValue(), HEX);
      Serial.print(", ID: ");
      Serial.print((LIN.RxDataValue()) & 0x3F, HEX);
      Serial.print(", Data: ");
    }
    else if (LIN.RxDataType() == DATA) {
      Serial.print(LIN.RxDataValue(), HEX); //data/checksum bytes. 
                                     //Last received DATA byte of a given LIN frame would normally be the Checksum Byte
      Serial.print(", ");
    }
  }

}

header file:

#ifndef	LIN_H
#define	LIN_H
#include "Arduino.h"
#include "LIN_defs.h"

#ifndef ARDUINO_ARCH_RENESAS_UNO
#include "HardwareSerialLIN.h"
#include "HardwareSerialLIN_private.h"
#endif

class LINClass{
	public:
		LINClass() {};
		inline uint16_t RxDataType(){ return (RxData & 0xFF00); }; //return the LIN data type of element read from UART buffer
		inline uint8_t RxDataValue(){ return (RxData & 0xFF); }; //return the LIN data value of element read from UART buffer
		uint8_t GetPID(uint8_t id); //return PID for given LIN ID
		uint8_t VerifyPID(uint8_t pid); //returns if given PID is valid or not
		uint8_t GetChecksum(uint8_t pid, uint8_t *msg_data, uint8_t dlc, enum Chksum_T typ); //returns Checksum for given LIN frame. enum Chksum_T {CLASSIC, ENHANCED};
		#ifndef ARDUINO_ARCH_RENESAS_UNO
		void SendBreak(HardwareSerialLIN &s, uint8_t brkbits = BREAK_BITS); //send break field
		void SendHeaderFrame(HardwareSerialLIN &s, uint8_t pid, uint8_t brkbits = BREAK_BITS, uint8_t sync = 0x55); //send breakfield, sync field and LIN PID
		void SendDataFrame(HardwareSerialLIN &s, uint8_t *data, uint8_t dlc, uint8_t checksum); //Send LIN data frame + checksum
		#else
		void SendBreak(UART &s, uint8_t brkbits = BREAK_BITS); //send break field
		void SendHeaderFrame(UART &s, uint8_t pid, uint8_t brkbits = BREAK_BITS, uint8_t sync = 0x55); //send breakfield, sync field and LIN PID
		void SendDataFrame(UART &s, uint8_t *data, uint8_t dlc, uint8_t checksum); //Send LIN data frame + checksum		
		#endif
		static uint16_t RxData;
	private:
};
extern LINClass LIN;
#endif

If the MEGA and UNO R4 are from different board families then you will need to re-code some of the existing code and probably use different libraries.

which library is that ?

Reasonably sure it's sherzaad's own one :wink: Probably in the process of modifying it.

https://github.com/sherzaad/LIN

1 Like

right

so as they say in the readme, it's suitable for AVR only (dependency on the UART registers)

That is what he said.

And yet he wonders why it will not work with a totally different chip like the R4.

If you look at the header file in the opening post, @sherzaad started to cater for the Renesas; at least that is what I suspect.

what's weird is I don't find in the library where this extern is actually instantiated...

is that library actually any good ? May be they fixed it to get LIN0, LIN1, LIN2, LIN3 for mega and forgot that they had LIN and never tested it ?

2 Likes

That should be a linking error and not an undefined reference.

@sherzaad Please enable all compiler output in the preferences. Compile again and post the complete output. Maybe there is a warning that explains why there is no LIN.

as stated already I HAVE used this library successfully with a AVR (the mega specifically). LIN.h code is what I have posted in may initial post. LIN0, 1, 2 and 3, as not compatible with R4 and have been removed.

Correct and thank you for observing that as I AM actually attempting to update/modify it

Done that already… what I have already posted is all the information that was generated for the error. :neutral_face:

the issues does seem to be with the ‘extern’ function reading from the error. I could re-write the whole thing for R4, yes but preference would be to ‘update’ it rather so that it is still compatible to use with a mega

Can you zip the modified library and post it here. I think that you have made more changes than what you showed.
When compiling the original for the Uno R4 WiFi

In file included from c:\Users\bugge\OneDrive\Documents\Arduino\libraries\LIN-master/LIN.h:19:0,
                 from C:\Users\bugge\AppData\Local\Temp\.arduinoIDE-unsaved20251128-23784-rgqn9z.iwx4\LIN_Monitor\LIN_Monitor.ino:3:
c:\Users\bugge\OneDrive\Documents\Arduino\libraries\LIN-master/HardwareSerialLIN_private.h:1:10: fatal error: wiring_private.h: No such file or directory
 #include "wiring_private.h"
          ^~~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1

Compilation error: exit status 1

When compiling 4ffbbfd35bfbde4b5ac84d23ac96ff7b54baeaae against arduino:avr:mega I get multiple definition of __vector_25 and `__vector_26 at the linking stage.

After fixing the include of Arduino.h in LIN_defs.h

Compiler output
FQBN: arduino:avr:mega
Using board 'mega' from platform in folder: /home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6
Using core 'arduino' from platform in folder: /home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6

Detecting libraries used...
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/sketch/LIN_Monitor.ino.cpp -o /dev/null
Alternatives for LIN.h: [LIN]
ResolveLibrary(LIN.h)
  -> candidates: [LIN]
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/sketch/LIN_Monitor.ino.cpp -o /dev/null
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/HardwareSerialLIN.cpp -o /dev/null
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/HardwareSerialLIN0.cpp -o /dev/null
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/HardwareSerialLIN1.cpp -o /dev/null
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/HardwareSerialLIN2.cpp -o /dev/null
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/HardwareSerialLIN3.cpp -o /dev/null
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/LIN.cpp -o /dev/null
Generating function prototypes...
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/sketch/LIN_Monitor.ino.cpp -o /tmp/1073517595/sketch_merged.cpp
/home/sushi/.arduino15/packages/builtin/tools/ctags/5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives /tmp/1073517595/sketch_merged.cpp

Compiling sketch...
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/sketch/LIN_Monitor.ino.cpp -o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/sketch/LIN_Monitor.ino.cpp.o
Compiling libraries...
Compiling library "LIN"
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/HardwareSerialLIN.cpp -o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN.cpp.o
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/HardwareSerialLIN0.cpp -o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN0.cpp.o
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/HardwareSerialLIN1.cpp -o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN1.cpp.o
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/HardwareSerialLIN2.cpp -o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN2.cpp.o
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/HardwareSerialLIN3.cpp -o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN3.cpp.o
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/cores/arduino -I/home/sushi/.arduino15/packages/arduino/hardware/avr/1.8.6/variants/mega -I/home/sushi/.arduino15/libraries/LIN /home/sushi/.arduino15/libraries/LIN/LIN.cpp -o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/LIN.cpp.o
Compiling core...
Using precompiled core: /home/sushi/.cache/arduino/cores/arduino_avr_mega_cpu_atmega2560_d89eecc67025f3cbf12626e336157317/core.a
Linking everything together...
/home/sushi/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega2560 -o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/LIN_Monitor.ino.elf /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/sketch/LIN_Monitor.ino.cpp.o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN.cpp.o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN0.cpp.o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN1.cpp.o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN2.cpp.o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN3.cpp.o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/LIN.cpp.o /home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/../../cores/arduino_avr_mega_cpu_atmega2560_d89eecc67025f3cbf12626e336157317/core.a -L/home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A -lm
HardwareSerial0.cpp.o (symbol from plugin): In function `Serial':
(.text+0x0): multiple definition of `__vector_25'
/home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN0.cpp.o (symbol from plugin):(.text+0x0): first defined here
HardwareSerial0.cpp.o (symbol from plugin): In function `Serial':
(.text+0x0): multiple definition of `__vector_26'
/home/sushi/.cache/arduino/sketches/9384DA442C76D2C10037E7668B7CAF2A/libraries/LIN/HardwareSerialLIN0.cpp.o (symbol from plugin):(.text+0x0): first defined here
collect2: error: ld returned 1 exit status
Using library LIN in folder: /home/sushi/.arduino15/libraries/LIN (legacy)
exit status 1

Compilation error: exit status 1

extern is not a function. It tells the linker that there is something called LIN of type LINClass that will be defined somewhere.

then the code uses it

but it's nowhere to be found. so the compiler (linker actually) is unhappy and tells you

I had a quick glance through the library's files and I could find where then define the various LINx like for LIN0

but I could not find where the define LIN

So the promise the author made to the linker was a lie... (or may be I did not search well enough)


Is the link we have the right one ?

I guess that you did not read the instructions in the readme.txt in ....\Arduino\libraries\LIN-master\OtherThanLIN :slight_smile:

Ok… that ‘LIN’ is just in the LIN.h file. I just added it in so that I could directly call the class functions without having to explicitly instating the LINCLASS object in my sketch as you can see in the example sketch.

the thing that I dont understand is that for this undefined ‘LIN’ does NOT give me and error when I compile onto a MEGA. the error is only appearing when I try onto the R4…

I know i’m missing something here and I feel is more related to how the R4 files are structured/compiles but I dont know what… hence why I’m posting my problem here :wink:

@J-M-L

following you comment, I research abit more about how to correctly use ‘extern’ and yes I should have defined in the LIN.cpp file which I had never done.

added LINClass LIN; at the end of the cpp file and all compiles OK now :slight_smile:

Odd though that it worked just fine on previous versions of the IDE but at least mystery is solved now! Thanks for the pointer! (no pun intended! :rofl: )

I’m surprised it ever worked at all, if you used a non existing variable, the compiler or linker will bark… always…