Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic multiple definition of (Read 5576 times)
Arnold
Junior Member
**
Offline


Posts: 17
Joined: Feb 6th, 2018
multiple definition of
Feb 6th, 2018 at 8:47pm
Print Post  
Hello, 

i don´t get rid of this stupid message. Angry Cry
It´s stupid because it makes no sense at all.  Of course i made a clean build.
Code (C++)
Select All
BasicObjClass.cpp.o*: In function BasicObjCLass::run(int)
BasicObjClass.h:29: multiple definition of i2c_buffer

Error linking for board Generic ESP8266 Module
sonoff.cpp.o*: \pgmspace.h:103: first defined here
global.cpp.o*: (.bss.i2c_buffer+0x0): multiple definition of i2c_buffer
sonoff.cpp.o*: pgmspace.h:103: first defined here
Build failed for project 'sonoff'

Def from global.h
#ifndef _GLOBAL_h
#define _GLOBAL_h
#include "Arduino.h"
#define I2C_RETRY_COUNTER 3

uint32_t i2c_buffer = 0;

const char classObjName[] PROGMEM = { "basicobj/pcf8574/pcf8591/tftsd1303/KEY12x4/CRON" };// List of all related objects to print name (Search Function => GetIndex(



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

int8 GetIndex(String param, String Search, const char seperator);
String GetEntry(uint8_t idx, String param);
bool I2cValidRead(uint8_t addr, uint8_t reg, uint8_t size);
uint8_t I2cRead8(uint8_t addr, uint8_t reg);

#endif

global.cpp

#include "global.h"

#include "Wire.h"


String GetFirstParam(String *param, const char seperator) // Extract the first param
{
	String cmd = "";
	int pos = param->indexOf(seperator);
	if (pos == 0)
	{
		param->remove(0, 1);
		pos = param->indexOf(seperator);
	}

	if (pos == -1)
	{
		pos = param->length();
	}


	if (pos > 0)
	{
		cmd = param->substring(0, pos);

		param->remove(0, pos + 1);
	}

	return cmd;
}
int8 GetIndex(String param, String Search, const char seperator)  // Start counting on 0; -1 = false
{
	int8 i = 0;

	bool found = false;
	param.toLowerCase();
	Search.toLowerCase();
	do
	{

		found = (Search == GetFirstParam(&param, seperator));
		if (!found)
		{
			i++;

		}


	} while ((!found) && (param.length() > 0));
	if (!found)
	{
		i = -1;
	}

	return i;

}
// const char classObjName[] PROGMEM = { "basicobj/pcf8574/pcf8591/tftsd1303/KEY12x4/CRON" };// List of all related objects to print name (Search Function => GetIndex(
String GetEntry(uint8_t idx, String param)
{
	uint8_t i = 0;
	String buf = param;
	String tmp;
	Serial.println("-------------GetEntry-----------------");
	Serial.print ("Search index: ");
	Serial.println(idx);

	do
	{

		tmp = GetFirstParam(&param, '/'); // Extract the first param
		i++;
		Serial.println(i);
		Serial.println(param);
		Serial.println(tmp);
	} while (i < idx + 1); // Verbesserung Eventuell auch noch prüfen ob tmp.length() > 0

	Serial.println(tmp);

	return tmp;
}
bool I2cValidRead(uint8_t addr, uint8_t reg, uint8_t size)
{
	byte x = I2C_RETRY_COUNTER;

	i2c_buffer = 0;
	do {
		Wire.beginTransmission(addr);                       // start transmission to device
		Wire.write(reg);                                    // sends register address to read from
		if (0 == Wire.endTransmission(false)) {             // Try to become I2C Master, send data and collect bytes, keep master status for next request...
			Wire.requestFrom((int)addr, (int)size);           // send data n-bytes read
			if (Wire.available() == size) {
				for (byte i = 0; i < size; i++) {
					i2c_buffer = i2c_buffer << 8 | Wire.read();   // receive DATA
				}
			}
		}
		x--;
	} while (Wire.endTransmission(true) != 0 && x != 0);  // end transmission
	return (x);
}

uint8_t I2cRead8(uint8_t addr, uint8_t reg)
{
	I2cValidRead(addr, reg, 1);
	return (uint8_t)i2c_buffer;
}

 

« Last Edit: Feb 6th, 2018 at 10:15pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Online


Posts: 12189
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of
Reply #1 - Feb 6th, 2018 at 10:16pm
Print Post  
sometimes this happens if uses have incorrectly included shortcuts to arduino sources in their projects.

Please zip your .vcxproj and attach it to a post here by clicking Reply or email to info[at]visualmicro.com
  
Back to top
IP Logged
 
Arnold
Junior Member
**
Offline


Posts: 17
Joined: Feb 6th, 2018
Re: multiple definition of
Reply #2 - Feb 6th, 2018 at 10:53pm
Print Post  
Hello Thanks for help. 

There is the vcxproj file
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Online


Posts: 12189
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of
Reply #3 - Feb 7th, 2018 at 12:02am
Print Post  
Thanks, the project looks okay.

It's a linker error. Possibly finding the wrong wire library at some point.

If you build the same code with the arduino ide does it build okay or so you see a better error?
  
Back to top
IP Logged
 
Arnold
Junior Member
**
Offline


Posts: 17
Joined: Feb 6th, 2018
Re: multiple definition of
Reply #4 - Feb 7th, 2018 at 12:16am
Print Post  
Hello, 
the problem is. what ever i change i get some kind of this error. I already installed a new system. 

And if i check the temporary folder i can´t see any error. 
I already try 5 days to find a solution. Cry

thats the error from Arduino in atttachment
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Arnold
Junior Member
**
Offline


Posts: 17
Joined: Feb 6th, 2018
Re: multiple definition of
Reply #5 - Feb 7th, 2018 at 12:48am
Print Post  
Hello, 

if i change from uint32_t i2c_buffer = 0; to static uint32_t i2c_buffer = 0; then it works. 

but then i have to change a lot variables to that. 

strange
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Online


Posts: 12189
Location: United Kingdom
Joined: Apr 10th, 2010
Re: multiple definition of
Reply #6 - May 10th, 2018 at 11:17pm
Print Post  
+

This is a common error due to an updated arduino toolchain. The code would have worked if you had installed the arduino ide version that the code was designed for. I think it was around arduino 1.6.6 that arduino.cc made the decision to update with this breaking change.

  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint