Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By Arnold
#73752 Hello Together,

i think the compiler / linker is still buggy.

I just moved one variable from the main file to one header file an i get various errors which are strange.

Moved: I2cbuffer from main app to global.h

then compiled again and got this error´s

BasicObjClass.cpp.o*: In function BasicObjCLass::run(int)
BasicObjClass.h:36: multiple definition of i2c_buffer
sonoff.cpp.o*: ..arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266\pgmspace.h:103: first defined here
global.cpp.o*: (.bss.i2c_buffer+0x0): multiple definition of i2c_buffer
sonoff.cpp.o*: ..l\arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266\pgmspace.h:103: first defined here
PCF8574.cpp.o*: (.bss.i2c_buffer+0x0): multiple definition of i2c_buffer

Error linking for board Generic ESP8266 Module
sonoff.cpp.o*: C:\Users\Braun\AppData\Local\arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266\pgmspace.h:103: first defined here

PCF8591.cpp.o*: In function PCF8591::getid()
PCF8591.h:29: multiple definition of i2c_buffer
sonoff.cpp.o*: ..l\arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266\pgmspace.h:103: first defined here
TFTSD1303.cpp.o*: (.bss.i2c_buffer+0x0): multiple definition of i2c_buffer
sonoff.cpp.o*: ..l\arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266\pgmspace.h:103: first defined here
Build failed for project 'sonoff'


The global.h ist not big and looks like this:


// global.h

#ifndef _GLOBAL_h
#define _GLOBAL_h

#if defined(ARDUINO) && ARDUINO >= 100
#include "arduino.h"
#else
#include "WProgram.h"
#endif

#define I2C_RETRY_COUNTER 3

uint32_t i2c_buffer = 0;

String GetFirstParam(String * param, const char seperator);

int8 GetIndex(String param, String Search, const char seperator);
String GetEntry(uint8_t idx, String param);

uint8_t I2cRead8(uint8_t addr, uint8_t reg);
bool I2cValidRead(uint8_t addr, uint8_t reg, uint8_t size);


#endif

global.cpp

#include "global.h"

#include "Wire.h"




String GetFirstParam(String *param, const char seperator) // Extract the first param
{
and so on