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 Compile error when sketch contains .cpp file with same name (Read 1843 times)
Julian Sanin
Junior Member
**
Offline


Posts: 10
Joined: Dec 2nd, 2018
Compile error when sketch contains .cpp file with same name
Dec 21st, 2018 at 9:55am
Print Post  
Hello,
I think I found an edge case when using the vMicro plugin. When an Arduino sketch contains a empty .ino file and instead a .cpp file with the same name as the sketch gets used but from within a "src" folder, I can trigger an compiler error:

Code
Select All
Building project code ...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -I"C:\Files\Work\arduino\vmicro-project-structure-compiler-error\VMProject" -I"C:\Program Files (x86)\Arduino\libraries" -I"c:\program files (x86)\microsoft visual studio\2017\community\common7\ide\extensions\zczdsw33.wxq\Micro Platforms\default\debuggers" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries" -I"C:\Files\Work\arduino\vmicro-project-structure-compiler-error\libraries" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" -I"C:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega" MProject.cpp" -o MProject.cpp.o"

Error compiling project sources
error*: Project.cpp: No such file or directory
Build failed for project 'VMProject'

fatal error*: no input files
   compilation terminated 



Arduino seems to have no problem with it:

Code
Select All
Compiling sketch...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" t.ino.cpp" -o t.ino.cpp.o"
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=10807 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\mega" roject.cpp" -o roject.cpp.o"
...
Linking everything together...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections,--relax -mmcu=atmega2560 -o " t.ino.cpp.o" roject.cpp.o" "C:\\Users\\Julian\\AppData\\Local\\Temp\\arduino_build_516851/core\\core.a" "-LC:\\Users\\Julian\\AppData\\Local\\Temp\\arduino_build_516851" -lm
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 " "
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-objcopy" -O ihex -R .eeprom " "
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-size" -A "
Sketch uses 656 bytes (0%) of program storage space. Maximum is 253952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8183 bytes for local variables. Maximum is 8192 bytes. 



The project is using a folder structure similar to this one:
  • Sketch
    • Sketch.ino
      • src
        • Sketch.cpp
        • Sketch.h


Which happens to be also a similar structure as it gets used now the Marlin 2.0.x firmware from where I found also this error.
See also: https://www.visualmicro.com/forums/YaBB.pl?num=1543777515/0

I have created an empty sketch with such a folder structure which produces this error on github: https://github.com/j54n1n/vmicro-project-structure-compiler-error

If I understood the issue correctly the plugin is trying to link the compilation unit from the .ino file but can not find that file because it was not compiled for some reason. Could it be that it is some name clash issue?

Arduino uses for compiling:
  • Sketch.ino -> Sketch.ino.cpp.o
  • Sketch.cpp -> Sketch.cpp.o
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compile error when sketch contains .cpp file with same name
Reply #1 - Dec 21st, 2018 at 1:34pm
Print Post  
In arduino a sketchname.ino.cpp will ignore the .ino files and compile the .cpp where you need to be advanced user

In Visual Micro a sketchname.cpp will ignore the .ino files and compile the .cpp where you need to be advanced user

There might be an option in future releases that enables users to decide the name of the "special" override file but with this information you should be able to workaround easily enough.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint