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) LIBRARY EXAMPLE COMPILATION ERROR (Read 6907 times)
paolo48
Junior Member
**
Offline


Posts: 69
Joined: Dec 22nd, 2015
LIBRARY EXAMPLE COMPILATION ERROR
Jan 2nd, 2016 at 10:49pm
Print Post  
I try to compile a Class library example and I  get this  compilation error:
collect2.exe*:error: ld returned 1 exit status
Error creating .elf

Here is the code:
Code (C++)
Select All
#include "lcd_mio1.h"
Lcd_mioClass lcd;

void setup()
{
	lcd.init();
  /* add setup code here */

}

void loop()
{
	lcd.blink();
	delay(10);

  /* add main program code here */

}
 


and the library code
Code (C++)
Select All
// lcd_mio.h

#ifndef _LCD_MIO_h
#define _LCD_MIO_h

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

class Lcd_mioClass
{



 public:

	 Lcd_mioClass();
	void init();
	void createChar(uint8_t, uint8_t[]);
	void clear();
	void print(uint8_t);
	void setCursor(uint8_t,uint8_t);
	void blink();
	void noBlink();
	//virtual size_t write(uint8_t);


};

extern Lcd_mioClass Lcd_mio1;

#endif

#include "lcd_mio1.h"

Lcd_mioClass::Lcd_mioClass() { init(); }

void Lcd_mioClass::init(){	}
void Lcd_mioClass::createChar(uint8_t n, uint8_t t[]) {  }
void Lcd_mioClass::clear() {  }
void Lcd_mioClass::print(uint8_t c) { Serial.print(c); }
void Lcd_mioClass::setCursor(uint8_t x, uint8_t y) {  }
//size_t Lcd_mioClass::write(uint8_t(c)) { Serial.print(c); }
void Lcd_mioClass::blink() { }
void Lcd_mioClass::noBlink() {  }
Lcd_mioClass Lcd_mio;


 



Compilation on 1.6.5 IDE is fine ....with Visual Micro I get this:
Compiling debug version of 'prova_lib' for 'Arduino/Genuino Mega w/ ATmega2560 (Mega 2560)'
Build folder: a2560
Additional Defines: VM_DEBUG;VM_DEBUG_ENABLE 1;VM_DEBUG_BANDWIDTH_THROTTLE_MS 100;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;
Architecture Tools: d:\Program Files\Arduino\hardware\tools\avr/bin/
Sketchbook: file:\\\d:\users\pbecc\onedrive\Arduino
Core Include Paths
Include Path 'd:\Users\pbecc\OneDrive\Arduino\prova_lib'
Include Path 'd:\Program Files\Arduino\hardware\arduino\avr\cores\arduino'
Include Path 'd:\Program Files\Arduino\hardware\arduino\avr\variants\mega'
Library Include Paths (1)
Platform Libraries Root Include Paths
Include Path 'd:\Program Files\Arduino\libraries'
Include Path 'd:\Program Files\Arduino\hardware\arduino\avr\libraries'
Include Path 'd:\users\pbecc\onedrive\Arduino\libraries'
Build Core Paths: d:\Program Files\Arduino\hardware\arduino\avr\cores\arduino
"d:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc" -c -g -Os -w -ffunction-sections -fdata-sections -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"d:\Users\pbecc\OneDrive\Arduino\prova_lib" -I"d:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" -I"d:\Program Files\Arduino\hardware\arduino\avr\variants\mega" -I"D:\Program Files\VisualStudio\Common7\IDE\Extensions\o2rxztqq.ggk\Micro Platforms\default\debuggers\VM_DBG" -I"d:\Program Files\Arduino\libraries" -I"d:\Program Files\Arduino\hardware\arduino\avr\libraries" -I"D:\Program Files\VisualStudio\Common7\IDE\Extensions\o2rxztqq.ggk\Micro Platforms\default\debuggers" -I"d:\users\pbecc\onedrive\Arduino\libraries" "D:\Program Files\VisualStudio\Common7\IDE\Extensions\o2rxztqq.ggk\Micro Platforms\default\debuggers\VM_DBG\VM_mem_check.c" -o M_DBG\VM_mem_check.c.o" -DVM_DEBUG -DVM_DEBUG_ENABLE=1 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=100 -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
"d:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"d:\Users\pbecc\OneDrive\Arduino\prova_lib" -I"d:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" -I"d:\Program Files\Arduino\hardware\arduino\avr\variants\mega" -I"D:\Program Files\VisualStudio\Common7\IDE\Extensions\o2rxztqq.ggk\Micro Platforms\default\debuggers\VM_DBG" -I"d:\Program Files\Arduino\libraries" -I"d:\Program Files\Arduino\hardware\arduino\avr\libraries" -I"D:\Program Files\VisualStudio\Common7\IDE\Extensions\o2rxztqq.ggk\Micro Platforms\default\debuggers" -I"d:\users\pbecc\onedrive\Arduino\libraries" "D:\Program Files\VisualStudio\Common7\IDE\Extensions\o2rxztqq.ggk\Micro Platforms\default\debuggers\VM_DBG\VM_DBG.cpp" -o M_DBG\VM_DBG.cpp.o" -DVM_DEBUG -DVM_DEBUG_ENABLE=1 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=100 -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
"d:\Program Files\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10605 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"d:\Users\pbecc\OneDrive\Arduino\prova_lib" -I"d:\Program Files\Arduino\hardware\arduino\avr\cores\arduino" -I"d:\Program Files\Arduino\hardware\arduino\avr\variants\mega" -I"D:\Program Files\VisualStudio\Common7\IDE\Extensions\o2rxztqq.ggk\Micro Platforms\default\debuggers\VM_DBG" -I"d:\Program Files\Arduino\libraries" -I"d:\Program Files\Arduino\hardware\arduino\avr\libraries" -I"D:\Program Files\VisualStudio\Common7\IDE\Extensions\o2rxztqq.ggk\Micro Platforms\default\debuggers" -I"d:\users\pbecc\onedrive\Arduino\libraries" rova_lib.cpp" -o rova_lib.cpp.o" -DVM_DEBUG -DVM_DEBUG_ENABLE=1 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=100 -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
"d:\Program Files\Arduino\hardware\tools\avr/bin/avr-gcc" -w -Os -Wl,--gc-sections -mmcu=atmega2560 -o rova_lib.elf" M_DBG\VM_mem_check.c.o" M_DBG\VM_DBG.cpp.o" rova_lib.cpp.o" ore.a" " -lm
prova_lib.ino:In function `setup
prova_lib.ino:init()
prova_lib.ino:In function `loop
prova_lib.ino:blink()
prova_lib.ino:In function `__static_initialization_and_destruction_0
prova_lib.ino:Lcd_mioClass()
collect2.exe*:error: ld returned 1 exit status
Error creating .elf
:-
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: LIBRARY EXAMPLE COMPILATION ERROR
Reply #1 - Jan 2nd, 2016 at 11:07pm
Print Post  
When did you last update visual micro?
  
Back to top
WWW  
IP Logged
 
paolo48
Junior Member
**
Offline


Posts: 69
Joined: Dec 22nd, 2015
Re: LIBRARY EXAMPLE COMPILATION ERROR
Reply #2 - Jan 3rd, 2016 at 8:02am
Print Post  
Hello Tim
Happy New Year!

I updated VisualMicro as you suggested december 30th!
  
Back to top
 
IP Logged
 
paolo48
Junior Member
**
Offline


Posts: 69
Joined: Dec 22nd, 2015
Re: LIBRARY EXAMPLE COMPILATION ERROR
Reply #3 - Jan 3rd, 2016 at 9:16am
Print Post  
Update....

I have installed last Visual Micro release but the problem is still there! Sad
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: LIBRARY EXAMPLE COMPILATION ERROR
Reply #4 - Jan 3rd, 2016 at 3:51pm
Print Post  
Can you please zip and email your sketch to info[at]visualmicro.com

Also try compiling in release mode to ensure that a breakpoint location is not causing confusion.

When you say "library" do you mean local sketch/project code class or a real arduino library?
  
Back to top
WWW  
IP Logged
 
paolo48
Junior Member
**
Offline


Posts: 69
Joined: Dec 22nd, 2015
Re: LIBRARY EXAMPLE COMPILATION ERROR
Reply #5 - Jan 3rd, 2016 at 6:30pm
Print Post  
The library has been created following the IDE library tutorial and is located in the same folder of the .ino file!
The scope is to replace occurrences of call to a LCD library with a dummy library that will just print out to the serial port.

To tell you the truth I have found a work around.....
I have created a new folder where  I have copied the .ino .cpp .h files  The I have opened the new .ino with Visual Micro and...it compile OK.
The two folders files are identical one compile the other give the error !?!?   
In addition I think that The error must be related to breakpoints :
when compilation end with error a (not requested) breakpoint shows up. 

How can I compile in release mode?
This mean all without debug options?

I would like anyhow to understand what is causing this, to avoid this error in future and to be able to compile with debug options on!
  
Back to top
 
IP Logged
 
paolo48
Junior Member
**
Offline


Posts: 69
Joined: Dec 22nd, 2015
Re: LIBRARY EXAMPLE COMPILATION ERROR
Reply #6 - Jan 3rd, 2016 at 6:47pm
Print Post  
Sorry I believe that 
......I have created this mess!

I believe I have modified (using windows explorer) the name of the library , but since Visual Studio keep track of the changes it reverted automatically to the previous files:

this has created confusion to the compiler and the consequent error. 

Forcing Visual Studio to accept externally modified files will solve the issue!
The debug has nothing to do with it!

Thanks anyhow ....... Embarrassed Embarrassed
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: LIBRARY EXAMPLE COMPILATION ERROR
Reply #7 - Jan 3rd, 2016 at 7:36pm
Print Post  
Thanks for the info. 

It's an area that it reviewed all the time. If you haven't restarted the ide since making external folder/name changes then you can click "tools>visual micro>reload toolchains" or the Rescan button on the micro explorer.

If you have reloaded/restarted and still have a problem (I wouldn't expect that) then click "Build>Clean Solution" which cleans the compiler cache and does a full rebuilt next time. Or "Build>Rebuild" ignores project and library cache so rebuilds all but the arduino core.

You shouldn't have any issues with these commands in mind and I want to hear about it if you do thanks.

One thing to keep in mind for Arduino. The compiler will find libraries more easily when there is a matching folder and .h name. #Include "Lib1.h" will immediately be matched to a library folder called \Lib1. All easy matches are resolved first, library folders without matching .h files will be resolved in an adhoc manner. Visual Micro and Arduino might differ slightly in the ad-hoc area, both can fail after installing new libraries that alter the ad-hoc resolution process.
« Last Edit: Jan 3rd, 2016 at 7:40pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
paolo48
Junior Member
**
Offline


Posts: 69
Joined: Dec 22nd, 2015
Re: LIBRARY EXAMPLE COMPILATION ERROR
Reply #8 - Jan 21st, 2016 at 5:19pm
Print Post  
I have encountered a problem using Time.h library :

One example that compile end run with Ide 1.6.5 , compile but not run on Visual Micro

A doubt this may be due to a library name duplication that has been resolved for Arduino IDE in a way that can not be compatible  with Visual Micro, may be for the reason you stated above!

Should I start a new topic for this or give you the detail here?

 

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: LIBRARY EXAMPLE COMPILATION ERROR
Reply #9 - Jan 21st, 2016 at 5:23pm
Print Post  
Hi,

Best to start a new topic so that we can explore your settings such as if "VisualMicro>Deep search includes" is being used. We can also understand what version of visual micro you have installed and switch on verbose output to see exactly what is being found and from where.

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