Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Multiple Defintions error #3

Closed
Szum123321 opened this issue Apr 22, 2021 · 2 comments
Closed

Multiple Defintions error #3

Szum123321 opened this issue Apr 22, 2021 · 2 comments
Labels
Support Library support

Comments

@Szum123321
Copy link

Hi!

I'm trying to compile some code for Teensy 3.5 with PlatformIO 2.3.2, and I'm getting multiple definitions error.

I followed the procedure described in README, which sadly didn't work even though I cleaned the build environment and restarted VScode all the time.

Error message looks like this: link

I'm using Arch based linux distro:
Linux sz-81nh 5.11.14-arch1-1 #1 SMP PREEMPT Wed, 14 Apr 2021 12:06:34 +0000 x86_64 GNU/Linux

Also, the same code (the only difference being instead of TeensyTimer, I used STM32Timer) compiles and works perfectly on ST Nulceo F303RE

Steps to Reproduce

Minimal example: Teensy_minimal.zip

Expected behavior

Code compiles for Teensy

Actual behavior

Linker spews out a bunch of Multiple definitions error

@khoih-prog khoih-prog added invalid This doesn't seem right Support Library support labels Apr 22, 2021
@Szum123321
Copy link
Author

The library is included in include/I2CEEPROM.h file

@khoih-prog khoih-prog removed the invalid This doesn't seem right label Apr 23, 2021
@khoih-prog
Copy link
Owner

khoih-prog commented Apr 23, 2021

You have to modify like this to use new C++ style hpp

  1. main.cpp or Teensy_minimal.ino
#include <Arduino.h>
#include "I2CEEPROM.h"

I2CEEPROM mem;

void setup() 
{
}

void loop() 
{
}

  1. I2CEEPROM.h
#ifndef I2CEEPROM_H
#define I2CEEPROM_H

#include <Arduino.h>
#include <Wire.h>
#include <math.h>
#include "TimerInterrupt_Generic.h"

class I2CEEPROM {};

#include "I2CEEPROM_Impl.hpp"

#endif

  1. I2CEEPROM_Impl.hpp
#ifndef I2CEEPROM_IMPL_HPP
#define I2CEEPROM_IMPL_HPP

#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3)  ||defined(STM32F4) || defined(STM32F7) || \
       defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7)  ||defined(STM32G0) || defined(STM32G4) || \
       defined(STM32WB) || defined(STM32MP1) )
  STM32Timer DEVICE_TICK_TIMER(TIM2);
#elif ( defined(CORE_TEENSY) || defined(TEENSYDUINO) )
  TeensyTimer DEVICE_TICK_TIMER(TEENSY_TIMER_3);
#endif

/*library code here*/

#endif    // I2CEEPROM_IMPL_HPP

Compile is OK on Arduino IDE, and should be OK on PIO, unless you have wrong settings / configurations

Selection_746

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Support Library support
Projects
None yet
Development

No branches or pull requests

2 participants