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 Strange compilation error: crtm2560.o*: undefined reference to 'main' (Read 8571 times)
Thijs
Newbies
*
Offline


Posts: 4
Joined: Nov 16th, 2014
Strange compilation error: crtm2560.o*: undefined reference to 'main'
Nov 16th, 2014 at 3:53pm
Print Post  
Hi there, 

I'm relatively new to Arduino and Visual Micro. Now I have this weird situation and I can't really find anything on it.

I downloaded the TIME library from the Arduino playground and updated it through the corresponding location to the latest version.

I also installed Arduino 1.5.x editor.

Everything seems to work in the environment, except for the example TIMESERIAL.

In the arduino editor I can compile it, send it to the Arduino Mega 2560 I have and it runs. I can see this through the Serial monitor. 

In Visual Studio 2013 the plugin compiles without problem, but when I try to run it (and thus upload it to arduino), I get the following error:

Compiling 'Timetest' for 'Arduino Mega w/ ATmega2560 (Mega 2560)'
crtm2560.o*Sad.init9+0x0): undefined reference to `main'
collect2*:error: ld returned 1 exit status
Error creating .elf

With my limited knowledge it does seem an issue in the precompiled lib.. but I really don't understand why it runs from the arduino editor and all my other examples and projects run.

What am I missing here?

Is source code necessary?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Strange compilation error: crtm2560.o*: undefined reference to 'main'
Reply #1 - Nov 16th, 2014 at 4:38pm
Print Post  
Hi,

Please untick "tools>visual micro>automatic debugging" then try again

Thanks
  
Back to top
IP Logged
 
Thijs
Newbies
*
Offline


Posts: 4
Joined: Nov 16th, 2014
Re: Strange compilation error: crtm2560.o*: undefined reference to 'main'
Reply #2 - Nov 16th, 2014 at 5:52pm
Print Post  
Hi,

thanks for your reply.

I tried this, but it didn't matter. To be honest, I got some new error messages now about String  Sad but I think those are my own mistakes. 

However, i do think it's strange the Arduino editor compiles and uploads without problem..

Other suggestions?
  
Back to top
 
IP Logged
 
Thijs
Newbies
*
Offline


Posts: 4
Joined: Nov 16th, 2014
Re: Strange compilation error: crtm2560.o*: undefined reference to 'main'
Reply #3 - Nov 16th, 2014 at 6:03pm
Print Post  
As extra info, this is the complete compiler result in VS2013, with verbose messages on:
Compiling 'Timetest' for 'Arduino Mega w/ ATmega2560 (Mega 2560)'
Build folder: mega2560
Summary: Header=1 Prototypes=7 Imports=2
Additional Defines: VISUALMICRO_COMPILER_VER=1;
Architecture Tools: c:\Program Files (x86)\Arduino/hardware/tools/avr/bin/
GCC: 4.8.1
Sketchbook: file:///C:/Users/thijs..000/Documents/Arduino
Core Include Paths
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 (2)
Include Path 'C:\Users\thijs..000\Documents\Arduino\libraries\Time'
Include Path 'c:\Program Files (x86)\Arduino\libraries\Keypad'
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:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\default\debuggers'
Include Path 'C:\Users\thijs..000\Documents\Arduino\libraries'
"c:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avr-g++" -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=158 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"c:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"c:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" -I"C:\Users\thijs..000\Documents\Arduino\libraries\Time" -I"c:\Program Files (x86)\Arduino\libraries\Keypad" -I"c:\Program Files (x86)\Arduino\libraries" -I"c:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries" -I"C:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\default\debuggers" -I"C:\Users\thijs..000\Documents\Arduino\libraries" 0\Timetest.cpp" -o 0\Timetest.cpp.o" -DVISUALMICRO_COMPILER_VER=1
"c:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avr-gcc" -w -Os -Wl,--gc-sections -mmcu=atmega2560 -o 0/Timetest.elf" 0\Timetest.cpp.o" 0\Time\DateStrings.cpp.o" 0\Time\Time.cpp.o" 0\Keypad\Keypad.cpp.o" 0\Keypad\utility\Key.cpp.o" 0/core.a" 560" -lm
crtm2560.o*Sad.init9+0x0): undefined reference to `main'
Timetest.cpp.o:In function `__static_initialization_and_destruction_0'
Timetest.ino:String(char const*)'
Timetest.ino:~String()'
collect2*:error: ld returned 1 exit status
Error creating .elf


maybe this shines some light?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Strange compilation error: crtm2560.o*: undefined reference to 'main'
Reply #4 - Nov 16th, 2014 at 6:25pm
Print Post  
Hi,

Thanks for the info.

Questions

Can I see the verbose output from the arduino build? (file>preferences>verbose compile)

Are you using the latest release of visual micro? tools>visual micro>version>version and minor version?

Please click build>clean solution then compile and email the results to info [at] visualmicro.com

Thanks
« Last Edit: Nov 16th, 2014 at 6:26pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Thijs
Newbies
*
Offline


Posts: 4
Joined: Nov 16th, 2014
Re: Strange compilation error: crtm2560.o*: undefined reference to 'main'
Reply #5 - Nov 16th, 2014 at 6:55pm
Print Post  
Hi Tim,

I was busy getting your information and proceeded on your last action: Clean project and then rebuild.

That did the trick, it's all working again..

Thanks a lot!!! Smiley
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Strange compilation error: crtm2560.o*: undefined reference to 'main'
Reply #6 - Nov 16th, 2014 at 7:10pm
Print Post  
Thanks good to hear that, I will look into the compiler cache.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint