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
Hot Topic (More than 8 Replies) .h file errors (Read 23134 times)
DrDoggy1
Newbies
*
Offline


Posts: 6
Joined: Jun 15th, 2016
.h file errors
Jun 15th, 2016 at 5:10pm
Print Post  
Hi, 
0.5) i notice breakpoints dont get hit when in a .h file, although code in file is processing when running....

1)
I get error "duplicate definition" when i try to create global variable in a h file,  using #ifndef protection did not work to clear error...
building with Arduino ide i get no errors

2)
Also i get error when trying to use onewire.h , again works in arduino IDE

code & debug:

Code (C++)
Select All
#include <OneWire.h>
OneWire ds(4);  //DS18S20 Signal pin on digital

float getTemp(){
	//returns the temperature from one DS18S20 in DEG Celsius
	byte data[12];
	byte addr[8];
	if (!ds.search(addr)) {
		ds.reset_search();
		return -1000;
	}
	if (OneWire::crc8(addr, 7) != addr[7]) {
		Serial.println("CRC is not valid!");
		return -1000;
	}
	if (addr[0] != 0x10 && addr[0] != 0x28) {
		Serial.print("Device is not recognized");
		return -1000;
	}
	ds.reset();
	ds.select(addr);
	ds.write(0x44, 1);
	byte present = ds.reset();
	ds.select(addr);
	ds.write(0xBE); // Read Scratchpad
	for (int i = 0; i < 9; i++) { // we need 9 bytes
		data[i] = ds.read();
	}
	ds.reset_search();
	byte MSB = data[1];
	byte LSB = data[0];
	float tempRead = ((MSB << 8) | LSB); //using two's compliment
	float TemperatureSum = tempRead / 16;
	return TemperatureSum;
}

void loop() {
	float temperature = getTemp();
	Serial.println(temperature);
	delay(100);
}
 

« Last Edit: Jun 15th, 2016 at 5:25pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
DrDoggy1
Newbies
*
Offline


Posts: 6
Joined: Jun 15th, 2016
Re: .h file errors
Reply #1 - Jun 15th, 2016 at 5:10pm
Print Post  
#2 debug log)
Code
Select All
Compiling debug version of 'aqua1visual' for 'Arduino/Genuino Mega w/ ATmega2560 (Mega 2560)'
Build folder: _atmega2560
Additional Defines: VM_DEBUG;VM_DEBUG_ENABLE 1;VM_DEBUG_BANDWIDTH_THROTTLE_MS 33;VM_DEBUGGER_TYPE_HARDWARESERIAL 0;VM_DEBUGGER_TYPE_SOFTWARESERIAL 1;VM_DEBUGGER_TYPE_FASTSERIAL 2;VM_DEBUGGER_TYPE_USB 3;VM_DEBUGGER_TYPE_TEENSY 4;VM_DEBUGGER_TYPE_UART 5;VM_DEBUGGER_TYPE_USART 6;VM_DEBUGGER_TYPE_USBSERIAL 7;VM_DEBUGGER_TYPE_TTYUART 8;VM_DEBUGGER_TYPE_NET_CONSOLE 9;VM_DEBUGGER_TYPE_Uart 10;VM_DEBUGGER_TYPE_COSA 11;VM_DEBUGGER_TYPE VM_DEBUGGER_TYPE_HARDWARESERIAL;VM_DEBUG_BREAKPAUSE;
Architecture Tools: C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/
Sketchbook: file:\\\C:\Users\DOGGY-GIG\Documents\Arduino
Core Include Paths
Include Path 'C:\Users\DOGGY-GIG\Documents\Arduino\aqua1visual'
Include Path 'C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino'
Include Path 'C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega'
Library Include Paths (1)
Platform Libraries Root Include Paths
Include Path 'C:\Program Files (x86)\Arduino\libraries'
Include Path 'C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries'
Include Path 'C:\Users\DOGGY-GIG\Documents\Arduino\libraries'
Build Core Paths: C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc" -c -g -Os -w -std=gnu11 -ffunction-sections -fdata-sections -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"C:\Users\DOGGY-GIG\Documents\Arduino\aqua1visual" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" -I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\evqvbnsz.a10\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Arduino\libraries" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries" -I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\evqvbnsz.a10\Micro Platforms\default\debuggers" -I"C:\Users\DOGGY-GIG\Documents\Arduino\libraries" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\evqvbnsz.a10\Micro Platforms\default\debuggers\VM_DBG\VM_mem_check.c" -o 2560\VM_DBG\VM_mem_check.c.o" -DVM_DEBUG -DVM_DEBUG_ENABLE=1 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=33 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_HARDWARESERIAL -DVM_DEBUG_BREAKPAUSE
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"C:\Users\DOGGY-GIG\Documents\Arduino\aqua1visual" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" -I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\evqvbnsz.a10\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Arduino\libraries" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries" -I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\evqvbnsz.a10\Micro Platforms\default\debuggers" -I"C:\Users\DOGGY-GIG\Documents\Arduino\libraries" "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\evqvbnsz.a10\Micro Platforms\default\debuggers\VM_DBG\VM_DBG.cpp" -o 2560\VM_DBG\VM_DBG.cpp.o" -DVM_DEBUG -DVM_DEBUG_ENABLE=1 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=33 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_HARDWARESERIAL -DVM_DEBUG_BREAKPAUSE
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"C:\Users\DOGGY-GIG\Documents\Arduino\aqua1visual" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" -I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\evqvbnsz.a10\Micro Platforms\default\debuggers\VM_DBG" -I"C:\Program Files (x86)\Arduino\libraries" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries" -I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\evqvbnsz.a10\Micro Platforms\default\debuggers" -I"C:\Users\DOGGY-GIG\Documents\Arduino\libraries" 2560\aqua1visual.cpp" -o 2560\aqua1visual.cpp.o" -DVM_DEBUG -DVM_DEBUG_ENABLE=1 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=33 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_HARDWARESERIAL -DVM_DEBUG_BREAKPAUSE
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc" -w -Os -Wl,--gc-sections,--relax -mmcu=atmega2560 -o 2560/aqua1visual.elf" 2560\VM_DBG\VM_mem_check.c.o" 2560\VM_DBG\VM_DBG.cpp.o" 2560\aqua1visual.cpp.o" 2560/core.a" ga2560" -lm
aqua1visual.ino:In function `getTemp()
aqua1visual.ino:search(unsigned char*, bool)
aqua1visual.ino:reset_search()
aqua1visual.ino:crc8(unsigned char const*, unsigned char)
aqua1visual.ino:reset()
aqua1visual.ino:select(unsigned char const*)
aqua1visual.ino:write(unsigned char, unsigned char)
aqua1visual.ino:reset()
aqua1visual.ino:select(unsigned char const*)
aqua1visual.ino:write(unsigned char, unsigned char)
aqua1visual.ino:read()
aqua1visual.ino:reset_search()
aqua1visual.ino:In function `__static_initialization_and_destruction_0
aqua1visual.ino:OneWire(unsigned char)
collect2.exe*:error: ld returned 1 exit status
Error creating .elf 

« Last Edit: Jun 15th, 2016 at 5:30pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: .h file errors
Reply #2 - Jun 15th, 2016 at 5:42pm
Print Post  
Hi,

Yes some strange things you have going on. 

I just compiled your example without a problem so I need to check your software versions and settings.

1)
What is the version of Visual Micro. See "tools>extensions and updates>arduino ide for visual studio"

2)
Did you install OneWire using the Library Manager or did you download from git? If git then please give url.

3)
Please reproduce the header file issue and attach the verbose output as a .txt file to a post.

Thanks




  
Back to top
IP Logged
 
DrDoggy1
Newbies
*
Offline


Posts: 6
Joined: Jun 15th, 2016
Re: .h file errors
Reply #3 - Jun 18th, 2016 at 11:01pm
Print Post  

1)I am using ver 1512.20.2

2)....im not sure, but you are likely on the right path, pls what is good tutorial & location to download onewire.h  (its most likely i ripped it out from arduino library folder , how it got there i forget)

3) hmmm, i can no longer reproduce this, maybe error was legit!

  
Back to top
 
IP Logged
 
DrDoggy1
Newbies
*
Offline


Posts: 6
Joined: Jun 15th, 2016
Re: .h file errors
Reply #4 - Jun 25th, 2016 at 2:01am
Print Post  
got it , thanks!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: .h file errors
Reply #5 - Jun 26th, 2016 at 12:44am
Print Post  
Sorry I missed the question.

The library manager in the micro explorer is a good place to look.

Otherwise just search google for arduino onewire library. It should also be listed on the arduino.cc\playground
  
Back to top
IP Logged
 
DrDoggy1
Newbies
*
Offline


Posts: 6
Joined: Jun 15th, 2016
Re: .h file errors
Reply #6 - Jul 1st, 2016 at 10:40pm
Print Post  
Hi,
thanks!

Not sure how but the problem went away with the onewire.h,, however I have found another related problem:

I have downloaded and installed DallasTemperature.h from the arduino installer, I am able to build when I compile in studio if I declare & include dallastemperature in the main.ino file,

but when I transfer these declarations & include statements to myown sensors.h file i get error on build: 
No such file or directory::#include <DallasTemperature.h>

any ideas about this one.?
« Last Edit: Jul 1st, 2016 at 10:42pm by DrDoggy1 »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: .h file errors
Reply #7 - Jul 1st, 2016 at 10:49pm
Print Post  
The deep search system auto discovers so I guess it is off.

However, it can remain off because it is always a good idea to #include any required libraries in the project_name.ino so that intellisense can find them easily. The deep search is too slow for intellisense.

So even if not using the libraries code in the project_name.ino make sure they are #included in the project_name.ino

http://www.visualmicro.com/post/2016/01/14/How-to-improve-compile-times-dramatic...

« Last Edit: Jul 1st, 2016 at 10:50pm by Tim@Visual Micro »  
Back to top
IP Logged
 
DrDoggy1
Newbies
*
Offline


Posts: 6
Joined: Jun 15th, 2016
Re: .h file errors
Reply #8 - Jul 14th, 2016 at 9:24pm
Print Post  
thanks, that seemed to work,
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12187
Location: United Kingdom
Joined: Apr 10th, 2010
Re: .h file errors
Reply #9 - Jul 14th, 2016 at 9:31pm
Print Post  
Great. In the next release deep search also feeds intellisense. Useful if you have conditional #includes or libraries that reference many others.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint