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) Undefined reference query (Read 12008 times)
Gary11
Newbies
*
Offline


Posts: 5
Joined: Jul 22nd, 2013
Undefined reference query
Jul 22nd, 2013 at 2:00pm
Print Post  
Hi everyone,

I'm newbie on this forum and am looking forward to assistance and offering input where possible regarding the Visual Micro plug-in.

I hope this query is relevant to this forum. Please let me know if it's not!

I've recently purchased an Arduino Due and WiFi shield and have installed AtmelStudio and VM.  I managed to compile and download the WebServer example to the boards using the Arduino IDE.

I'm now attempting to get the same software to compile on AtmelStudio along with the VM plugin.

I've hit a problem which I'm not too sure how to solve.  The compiler posts an error message 'undefined reference to WiFi'.

Attached is a screen shot of my code (it's only a couple of lines long to try and debug the issue before adding the rest of it).

Any assistance to solve this problem would be appreciated!

http://www.flickr.com/photos/52941098@N00/9344065690/

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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Undefined reference query
Reply #1 - Jul 22nd, 2013 at 2:13pm
Print Post  
Hi Gary,

Well first thing to do is to import your arduino libraries in the correct manner. 

You will find that both arduino and visual micro should only accept library names without paths.

The best thing to do it to remove the #includes and use the "Project>Add Arduino Library" to import the libs. You should then see #includes "SPI.h" instead of fully qualified lib paths.

Thanks
  
Back to top
IP Logged
 
Gary11
Newbies
*
Offline


Posts: 5
Joined: Jul 22nd, 2013
Re: Undefined reference query
Reply #2 - Jul 22nd, 2013 at 3:03pm
Print Post  
Many thanks for the reply!  I'll try it this evening and report back.

Smiley
  
Back to top
 
IP Logged
 
Gary11
Newbies
*
Offline


Posts: 5
Joined: Jul 22nd, 2013
Re: Undefined reference query
Reply #3 - Jul 22nd, 2013 at 9:29pm
Print Post  
Hi,

I tried as you suggested, but the programme still doesn't compile!  I'm rather frustrated by this as there doesn't seem to be anyway to debug this issue.  It also seems to me that Arduino is rather pedantic about where files are during compilation.

Is there a document posted somewhere that describes how the whole system (AtmelStudio, Arduino and VM) hangs together?  I've looked at several of the links posted on the VM home page but clearly I must be missing something fundamental to be having these issues.

Attached is a screenshot of the new problem:

http://www.flickr.com/photos/52941098@N00/9344209177/lightbox/

I did the following:

This is where I keep the Arduino system - 
C:\Installation Files\Arduino\arduino-1.5.2-windows\arduino-1.5.2\libraries

The two "libraries" that I'm interested in were originally supplied with Arduino in -
C:\Installation 

I copied the folders WiFi and SPI from in the ..\sam\libraries folder into the ..\1.5.2\libraries folder.

I then went to AtmelStudio -> Project -> Add Arduino Library -> Core -> SPI then WiFi.

This resulted in the #includes<  > as shown in the picture.

I tried building the project. Compilation terminated.

Is there anything else that I have missed?

Non-happiness abounds...  Cry
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Undefined reference query
Reply #4 - Jul 22nd, 2013 at 10:32pm
Print Post  
Hi,

Sorry you are having problems. 

You might have read that Arduino 1.5 system is beta and unfortunately you are hitting the bugs. There is a fix and new release due over the next few days but for now you have two choices.

1. You can use Atmel to write code and Arduino to upload.

In the Arduino Ide there is a checkbox in "File>Preferences" called "External Editor". Clicking the checkbox will set the Arduino Ide into read-only mode. In read-only mode, the arduino ide will reload the sketch from disk each time you click upload. This allows the same sketch to be open in both Atmel Studio and the Arduino Ide. Thus you can edit and save in Atmel Studio and then upload with the Arduino Ide.

2. Make some changes to the Arduino Ide as a temp workaround

First thing that fails is that the 1.5 beta of Visual Micro doesn't cater for the new hardware specific libraries. 

You can remedy this problem by MOVING the folders from "ArduinoIde\Hardware\Arduino\Sam\Libraries" to "ArduinoIde\Hardware\Arduino\Libraries".

This lack of support for hardware lib locations in the beta was documented  at time of release however another bug that surfaced only recently is a pain and relates to libraries that have a "\utility" sub folder. I have just checked and unfortunately the Wifi library has a utility folder! 

The bug is that when using Arduino 1.5 with Visual Micro the compiler -I include for a libraries utility folder is incorrectly omitted from the "c" and the "cpp" compiler script.

To remedy this problem with your specific project you can edit the platforms.txt file that is included with Arduino 1.5 (won't work if other libs that have utility files with the same name).

Use a text editor to edit "arduinoide\hardware\arduino\sam\platform.txt"

Please notice below I have added [-I"D:\Arduino\arduino-1.5.2\libraries\WiFi\utility"] to both recipe.c.o.pattern and recipe.cpp.o.pattern. You need to make this change to your platforms.txt and to ensure the path to the wifi utility folder is correct.

The following script is from platforms.txt in the sam hardware folder (above)

Code
Select All
# SAM3 compile patterns
# ---------------------

## Compile c files
recipe.c.o.pattern="{compiler.path}{compiler.c.cmd}" {compiler.c.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -D{software}={runtime.ide.version} {build.extra_flags} {compiler.libsam.c.flags} {includes} -I"D:\Arduino\arduino-1.5.2\libraries\WiFi\utility"  "{source_file}" -o "{object_file}"

## Compile c++ files
recipe.cpp.o.pattern="{compiler.path}{compiler.cpp.cmd}" {compiler.cpp.flags} -mcpu={build.mcu} -DF_CPU={build.f_cpu} -D{software}={runtime.ide.version} {build.extra_flags} {compiler.libsam.c.flags} {includes} -I"D:\Arduino\arduino-1.5.2\libraries\WiFi\utility" "{source_file}" -o "{object_file}"
 



After making changes to lib locations or platform.txt, if Atmel Studio is open, click "Tools>Arduino>Reload Toolchain"

Documentation

Under normal (non-beta) circumstances Visual Micro works the same way as Arduino so any documents concerning this area would normally be exactly the same as the ones for Arduino. 

This is why I said the first thing to do was to make the sketch was created as a standard arduino sketch by correcting the #includes. 

If you were to open the arduino ide and use the Import>Library feature you it would add the libs without the path names which is important in the arduino build process.

Obviously this bug is a big confusion so I can see why you ended up trying to add full path #includes.

Sorry for the hacking, the next release in a few days caters for all types of arduino libraries including yet another new format soon to be released by Arduino.
  
Back to top
IP Logged
 
Gary11
Newbies
*
Offline


Posts: 5
Joined: Jul 22nd, 2013
Re: Undefined reference query
Reply #5 - Jul 23rd, 2013 at 2:20pm
Print Post  
Hi there,

Thanks so much for the reply!

There's a lot to it, so I'll take some time to work through each point. I hope that the Arduino system relaxes a bit, or at least becomes more configurable in future releases. It's a great system, but it frustrates a bit too!

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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Undefined reference query
Reply #6 - Jul 23rd, 2013 at 4:35pm
Print Post  
Yes there are a lot of Arduino changes at the moment, it will settle over the next few months and we have some tools coming that will make things more flexible.

I tried moving the wifi lib and then editing the platform.txt with the path as shown earlier in this post. It only took a few minutes and then the compile worked fine in VM.

I hope this helps, thanks for the feed back.
  
Back to top
IP Logged
 
Gary11
Newbies
*
Offline


Posts: 5
Joined: Jul 22nd, 2013
Re: Undefined reference query
Reply #7 - Jul 24th, 2013 at 8:41pm
Print Post  
Hi!

Success!  Thank you for the instuctions given.  They worked and I'm now able to compile and upload (using bossac through Atmel Studio) to my Due.

One last question for you: I wish to use the SD library which also has a utility folder within it.  Is there anyway in which I could add this file to the recipe lines which you showed me in your example so that both WiFi and SD libraries can be compiled in the same sketch?

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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Undefined reference query
Reply #8 - Jul 25th, 2013 at 12:00am
Print Post  
Hi,

Good news.

You can add as many -I path references as you like. 

ps: This will only work if the utility folder contains files that do not clash with any other arduino source file names.

« Last Edit: Aug 18th, 2013 at 10:43pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Undefined reference query
Reply #9 - Aug 18th, 2013 at 10:43pm
Print Post  
This issue should be resolved by 1308.18

When you have a spare moment please give it a try
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint