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) Adding new arduino .c and header ends with linker not finding symbols. (Read 9093 times)
Link
Junior Member
**
Offline


Posts: 21
Location: Saint Paul, MN, USA
Joined: Dec 26th, 2015
Adding new arduino .c and header ends with linker not finding symbols.
Feb 13th, 2016 at 8:56pm
Print Post  
I have added a .c/.h file pair via the Visual Micro -> Add code -> Add Empty Arduino C and header menu item.

The files show up in source and header subdirectories in Project Explorer.

Errors in the .c or .h files will generate errors.  Hence, I know they are compiling.

I find the files in my ..\AppData\Local\V.Micro\Arduino\Builds\project path.  Deleting and rebuilding shows they are rebuilt.

But when it comes to linking, the linker cannot find the symbols.  I believe the linker is not finding/include the .o files.  The build command line in the output window does not show any reference to the new file, even when the build throws an error placed into the new file.

What do I need to do to get the linker to find the .o files?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #1 - Feb 13th, 2016 at 9:36pm
Print Post  
Hi,

c files are linking okay for me. To save asking the usual questions please post or email a verbose build output. Also please switch on "tools>options>visual micro>compiler>show build properties" so I can see arduino version, board, hardware config and paths.

Finally please confirm your visual micro version from "tools>extensions and updates"

Thanks
  
Back to top
WWW  
IP Logged
 
Link
Junior Member
**
Offline


Posts: 21
Location: Saint Paul, MN, USA
Joined: Dec 26th, 2015
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #2 - Feb 13th, 2016 at 9:48pm
Print Post  
I tried to get the linker to find the modules by including the .c file rather than the .h file in the .ino file.  Now the linker finds two symbols of the same name.  So I am not sure how the linker is working.
  
Back to top
 
IP Logged
 
Link
Junior Member
**
Offline


Posts: 21
Location: Saint Paul, MN, USA
Joined: Dec 26th, 2015
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #3 - Feb 13th, 2016 at 10:10pm
Print Post  
See attached file for build output.
  

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #4 - Feb 13th, 2016 at 11:12pm
Print Post  
Thanks

I see this in your output for the link:-

Code
Select All
h.cpp.o"   



Is TACH.c the file you are talking about?
  
Back to top
WWW  
IP Logged
 
Link
Junior Member
**
Offline


Posts: 21
Location: Saint Paul, MN, USA
Joined: Dec 26th, 2015
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #5 - Feb 14th, 2016 at 1:53am
Print Post  
Yes, TACH.c is.  I am frustrated that when I looked for 'TACH' in the out put I looked at before capturing the one I sent to you, I did not find the lines you identified.

Is TACH.c.o the name of the obj file?  I first added TACH.c, but ended up with TACH.c.c and TACH.c.h, so I removed the via VS2015 then added TACH.
  
Back to top
 
IP Logged
 
Link
Junior Member
**
Offline


Posts: 21
Location: Saint Paul, MN, USA
Joined: Dec 26th, 2015
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #6 - Feb 14th, 2016 at 2:02am
Print Post  
I tried adding a arduino c and header to another project and get the same result.
  
Back to top
 
IP Logged
 
Link
Junior Member
**
Offline


Posts: 21
Location: Saint Paul, MN, USA
Joined: Dec 26th, 2015
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #7 - Feb 14th, 2016 at 3:56am
Print Post  
I see in the map file that I have:

.text.TACH_ISR
                0x00000000       0x98 C:\Users\John\AppData\Local\V.Micro\Arduino\Builds\PseudoTach\RFduino\TACH.c.o
.text.TACH_Init
                0x00000000       0x60 C:\Users\John\AppData\Local\V.Micro\Arduino\Builds\PseudoTach\RFduino\TACH.c.o
.text.TACH_RPM
                0x00000000        0xc C:\Users\John\AppData\Local\V.Micro\Arduino\Builds\PseudoTach\RFduino\TACH.c.o
.text.TACH_Task
                0x00000000       0x64 C:\Users\John\AppData\Local\V.Micro\Arduino\Builds\PseudoTach\RFduino\TACH.c.o

The size of each function looks right.

The timestamp is correct on the .map file.  So the latest build found the functions that are being complained about.

The functions have global visibility, as they are in the .map file.  So the linker found them, but cannot find them???  Huh
« Last Edit: Feb 14th, 2016 at 4:37am by Link »  
Back to top
 
IP Logged
 
Link
Junior Member
**
Offline


Posts: 21
Location: Saint Paul, MN, USA
Joined: Dec 26th, 2015
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #8 - Feb 14th, 2016 at 4:02am
Print Post  
Here is a project with the issue targetting the Uno.  It simply calls myFunction in the loop() and myFunction is declared/defined in myFunction.c/h.  Attached is the zip of the project files.

I installed all VisualMicro, and Arduino all in default locations.

So I am getting the same errors with an RFduino (ARM0) in both VisualMicro and Arduino IDEs and in VM targeting a UNO which is AVR based.
« Last Edit: Feb 14th, 2016 at 4:34am by Link »  

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


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #9 - Feb 14th, 2016 at 1:11pm
Print Post  
Thanks for the info.

I think I had the same problem when I tried, like you, to use extern on the prototype in the .h

If I recall it works if you put extern on the method in the .c and not the prototype in the .h
« Last Edit: Feb 14th, 2016 at 1:12pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Link
Junior Member
**
Offline


Posts: 21
Location: Saint Paul, MN, USA
Joined: Dec 26th, 2015
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #10 - Feb 14th, 2016 at 7:39pm
Print Post  
Thanks for your responses and time.  It is not a VisualMicro issue.  I found the issue on the Arduino site.  It is not VM, it is not RFduino, it is not Arduino and it is not toolchain.  It is a C++ issue.  The linker calls a mangled name.  So if you do not add the lines below, the linker is looking for myFunction in a list of mangled names.  It probably has the name myFunction_c_myFunction or something like that.

You have to surround your c function declarations in the header file with:

#ifdef __cplusplus
extern "C" {
#endif


void myFunction(void);

#ifdef __cplusplus
}
#endif

« Last Edit: Feb 14th, 2016 at 8:07pm by Link »  
Back to top
 
IP Logged
 
Link
Junior Member
**
Offline


Posts: 21
Location: Saint Paul, MN, USA
Joined: Dec 26th, 2015
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #11 - Feb 15th, 2016 at 2:49am
Print Post  
In the end this thread does suggest one improvement for VisualMicro.  When a user adds a .c and .h file, in the .h file there is code already added to include arduino.h.  Perhaps you could add additional code.  That would be the code above with a comment to "put your function declarations here".  Judging from the number of hits on the Arduino.cc forum on this subject, I am not the only one that stumbles on this issue.

Thanks again for your time.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Adding new arduino .c and header ends with linker not finding symbols.
Reply #12 - Feb 15th, 2016 at 1:34pm
Print Post  
Great idea, will do thanks
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint