Makefile Error in Atmel Studio 7

Go To Last Post
27 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm getting a "recipe for target 'main.o' failed in Makefile in line 79 when I try to compile.  I'm running Atmel Studio 7 with Windows 7.  When I double-click on the error, it brings me to the second line in the code attached.  I've tried putting the file in different locations like the default directory, the desktop, and another location on the C drive but I keep getting this error.  It was working just fine and then all of a sudden I started getting this error.  I don't think that I changed any settings but it's possible.  Any help would be greatly appreciated.  Thanks

./%.o: .././%.cpp
	@echo Building file: $<
	@echo Invoking: AVR8/GNU C Compiler : 4.9.2
	$(QUOTE)C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe$(QUOTE) -funsigned-char -funsigned-bitfields -DDEBUG  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\include"  -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g2 -Wall -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega128" -c -MD -MP -MF "$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -MT"$(@:%.o=%.o)"   -o "$@" "$<" 
	@echo Finished building: $<

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ggudino wrote:
it brings me to the second line in the code attached.

Nothing attached...

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looks to me like the wrong version of make may be invoked and it's not expanding parameters like "$<" and "$@". They should operate as explained here:

 

http://stackoverflow.com/questio...

and

https://www.gnu.org/software/mak...

 

Have you installed software recently (perhaps a language compiler?) that might have added a PATH to a different make program before the one that should be used here?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the reply.  No new software has been added.  I was looking at the manual and I don't really understand it.  I'm pretty new to this and I can't wrap my head around this.  Is there an easy way of invoking the correct version of make or modifying this one to look for the correct path?  

 

I think that this is unrelated but we did recently have an issue with the Device Pack Manager not showing up so we had to do a work around that involved resetting the cache and modifying 'atpack.properties' to look in a different folder.  'atpack.properties' was the only file that we modified.  I was able to work on my project just fine after that.  I compiled and loaded the program to STK600 several times after that and even read the program.  Now I can't compile anything.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry.  I did not mean that there was a file attached.  I meant the snippet of code that I added.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd start by reinstalling AS7. As I say there is something very fundamentally wrong going on there as the auto-generated Makefile that AS7 creates uses $< to represent the input filenames to be compiled and $@ to represent the output. If you have a main.cpp and file.cpp in the project then $< should expand out first to be main.cpp and on the second time to be file.cpp and so on. The output ($@) should be main.o and then file.o. But this meta expansion is not occuring so something is utterly FUBAR there.

 

Hopefully a reinstall will fix things.

 

If you want to try something a little less severe as a first step then junk the current project and create a new project and just add the existing files to it. If it's just something corrupt in that one particular project this should clear things. But if this doesn't work I fear a reinstall is inevitable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

file.cpp should be in the same directory as main.cpp?  I don't see file.cpp anywhere.  I tried loading and compiling one of the example projects that AS7 came with and I have the same issue.  A clean reinstall it is.  

Do I need to clear out any cache or anything else after I uninstall AS7?  Thanks.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was talking conceptually/metaphorically

 

I mean if you have a project that consists of foo.cpp, bar.cpp, baz.cpp then a Makefile that has the rule:

%.o:%.cpp
     something -input $< -ouptut $@

*should* lead to the commands:

something -input foo.cpp -ouptut foo.o
something -input bar.cpp -ouptut bar.o
something -input baz.cpp -ouptut baz.o

being executed in turn. But in your case what appears to have been attempted is the literal command:

something -input $< -ouptut $@

where the $< and $@ have not been replaced by the file names in turn. That is F'd Up Beyond All Recognition = FUBAR

 

As I say your remedy might start with

 

1) recreate project - perhaps the fault was "local" - a new project will clear it

 

2) if not uninstall/reinstall AS7 as something about the whole build/make system is FUBAR

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

IT went ahead and did both of what you recommended.  Unfortunately, we are left with the same problem.  Creating a new project created the same Makefile error.  Re-installing AS7 also created the same error.  

 

We also had the same issue with the Device Pack Manager again where none of the Device Packs were installed.  Had to go in Device Pack Manager and Download and install all of the Device Packs.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Could it be that it was a setting that I checked/unchecked somewhere.  For example, in Options and Configurations I can choose to use an external Makefile.  Are there other areas where I can screw up the Makefile?

 

Thanks again for all of your help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Silly question but the project/solution you are trying to build - there is at least one source file listed in it isn't there? I could maybe envisage a situation where, if no files were listed the $< expansion may go a bit screwy. Unless it's proprietary are you able to zip up the entire project and source files and post here? I'd also be interested to see exactly what is in the Makefile (likely in the "Debug" subdirectory of the project directory).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've attached a project that I've been trying to compile.  I am having problems with all projects, even the example projects.  I also attached a picture of the Solution Explorer after I tried to build the solution and also tried to compile the solution.  Looks pretty bare.

Attachment(s): 

Last Edited: Fri. Sep 30, 2016 - 03:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, when I'm next near a laptop with AS7 I'll download that and see how it works for me.

 

I did try building it in a Linux system but it's full of "Windows-isms" which make that close to impossible. However it did get as far as:

~/Test/Test/Test/Debug$ make
Building file: .././main.cpp
Invoking: AVR8/GNU C Compiler : 4.9.2
avr-g++ -funsigned-char -funsigned-bitfields -DDEBUG  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.0.98\include"  -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g2 -Wall -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.0.98\gcc\dev\atmega128" -c -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.cpp" 
Finished building: .././main.cpp
Building target: Test.elf
Invoking: AVR8/GNU Linker : 4.9.2
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe" -o Test.elf  main.o   -Wl,-Map="Test.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mrelax -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\Atmel\ATmega_DFP\1.0.98\gcc\dev\atmega128"  
/bin/sh: C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe: command not found

which is further than you got. But part of what got me to there was adding a comment to the line:

################################################################################
# Automatically-generated file. Do not edit!
################################################################################

#SHELL := cmd.exe

I over-rode the setting of SHELL= so it would simply use the system default in my case (/bin/sh). As you can see that worked for me and the $< and $@ were expanded correctly by the shell and make that I use.

 

This does suggest it may be something "environmental" on your PC. Do you perhaps have a replacement, non-standard cmd.exe on your machine though, like I said above, this looks a lot like the wrong make.exe is being used. I wonder if you are running a Microsoft or Borland make.exe instead of the GNU one? From AS7 Tools menu use Command Prompt then just type "make -v". On my Windows system (though not one with AS7 installed) I see something like:

C:\foo>make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i686-pc-msys

The key thing there is that it is the GNU version of make that I am running.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
C:\Users\foo\Documents>make -v
GNU Make 4.1
Built for Windows32
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

The code snippet above is what this computer outputs.  Going to Tools->Command Prompt opened Windows 7 Command Prompt.  I typed in "make -v" and got the above output.  How do I know what version of make I am running?  I also searched the C drive for make.exe and only found it under the installation directory of AS7.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also, I tried changing Makefile.txt in that folder to reflect what you mentioned above.  I then tried to compile and it gave me the same Makefile error and it overrode the change that I made on the txt file back to what it was before.

#SHELL := cmd.exe

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hey,

I am having the same error lately. Have you found a solution someone with not too deep knowledge about makefiles can use?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'll dig out an AS7 laptop and see how that builds for me. (I have a feeling it's simply going to work though) 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

(boy I love how Windows makes yous sit for minutes with a non helpful % complete showing while it applies updates!)

 

Anyway laptop finally updated and I was able to load the project attached to #12 above into AS 7.0.943 (yeah, I know, well out of date!) and it said:

------ Build started: Project: Test, Configuration: Debug AVR ------
Build started.
Project "Test.cppproj" (default targets):
Target "PreBuildEvent" skipped, due to false condition; ('$(PreBuildEvent)'!='') was evaluated as (''!='').
Target "CoreBuild" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Compiler.targets" from project "C:\Users\Cliff\Downloads\Test_1\Test\Test\Test.cppproj" (target "Build" depends on it):
	Using "RunCompilerTask" task from assembly "C:\Program Files (x86)\Atmel\Studio\7.0\Extensions\Application\AvrGCC.dll".
	Task "RunCompilerTask"
		Shell Utils Path C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils
		C:\Program Files (x86)\Atmel\Studio\7.0\shellUtils\make.exe all --jobs 4 --output-sync 
		Building file: .././main.cpp
		Invoking: AVR8/GNU C Compiler : 4.9.2
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe" -funsigned-char -funsigned-bitfields -DDEBUG  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\include"  -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g2 -Wall -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega128" -c -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.cpp" 
		Finished building: .././main.cpp
		Building target: Test.elf
		Invoking: AVR8/GNU Linker : 4.9.2
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe" -o Test.elf  main.o   -Wl,-Map="Test.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mrelax -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega128"  
		Finished building target: Test.elf
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures  "Test.elf" "Test.hex"
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom  --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0  --no-change-warnings -O ihex "Test.elf" "Test.eep" || exit 0
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "Test.elf" > "Test.lss"
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "Test.elf" "Test.srec"
		"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "Test.elf"
		   text	   data	    bss	    dec	    hex	filename
		    208	      0	      0	    208	     d0	Test.elf
	Done executing task "RunCompilerTask".
	Using "RunOutputFileVerifyTask" task from assembly "C:\Program Files (x86)\Atmel\Studio\7.0\Extensions\Application\AvrGCC.dll".
	Task "RunOutputFileVerifyTask"
				Program Memory Usage 	:	208 bytes   0.2 % Full
				Data Memory Usage 		:	0 bytes   0.0 % Full
	Done executing task "RunOutputFileVerifyTask".
Done building target "CoreBuild" in project "Test.cppproj".
Target "PostBuildEvent" skipped, due to false condition; ('$(PostBuildEvent)' != '') was evaluated as ('' != '').
Target "Build" in file "C:\Program Files (x86)\Atmel\Studio\7.0\Vs\Avr.common.targets" from project "C:\Users\Cliff\Downloads\Test_1\Test\Test\Test.cppproj" (entry point):
Done building target "Build" in project "Test.cppproj".
Done building project "Test.cppproj".

Build succeeded.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

Absolutley no error there and it expanded $< and $@ just as I expected. If I start an AS7 Command prompt and run make I get:

C:\Users\wrigh\Downloads\Test_1>make -v
GNU Make 4.1
Built for Windows32
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

and if I switch to the build directory I can do this:

C:\Users\wrigh\Downloads\Test_1\Test\Test\Debug>make clean
rm -rf  main.o
rm -rf  main.d
rm -rf "Test.elf" "Test.a" "Test.hex" "Test.lss" "Test.eep" "Test.map" "Test.srec" "Test.usersignatures"

C:\Users\wrigh\Downloads\Test_1\Test\Test\Debug>make
Building file: .././main.cpp
Invoking: AVR8/GNU C Compiler : 4.9.2
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe" -funsigned-char -funsigned-bitfields -DDEBUG  -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\include"  -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g2 -Wall -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega128" -c -MD -MP -MF "main.d" -MT"main.d" -MT"main.o"   -o "main.o" ".././main.cpp"
Finished building: .././main.cpp
Building target: Test.elf
Invoking: AVR8/GNU Linker : 4.9.2
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-g++.exe" -o Test.elf  main.o   -Wl,-Map="Test.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mrelax -mmcu=atmega128 -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.106\gcc\dev\atmega128"
Finished building target: Test.elf
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures  "Test.elf" "Test.hex"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom  --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0  --no-change-warnings -O ihex "Test.elf" "Test.eep" || exit 0
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "Test.elf" > "Test.lss"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature -R .user_signatures "Test.elf" "Test.srec"
"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-size.exe" "Test.elf"
   text    data     bss     dec     hex filename
    208       0       0     208      d0 Test.elf

C:\Users\wrigh\Downloads\Test_1\Test\Test\Debug>

So again, everything there is working as expected for me. So I don't really have a clue why the $</$@ is not working for y'all.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for all of your time and help.  Is there a way of "resetting" the Makefile to "factory default"  settings?  Sorry, I don't know the terms here.  Also, does anybody know how to completely remove AS7 and all traces of it so I can start fresh, registry files and all installation files?  The last time that we reinstalled, all of my settings remained and i'm wondering if make.exe was from the previous install.  Thanks again.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Makefile is created from scratch every time you click "Build". At that moment AS7 collects together all the details of the Project options you have set and the list of source files you have in the project and it puts them all together to create a Makefile that represents what you have asked to build. It then create a temporary .bat file that itself creates a temporary command environment and within that it runs the commands to execute "make" with the Makefile it has just created.

 

So it effectively starts "clean" each time it builds anyway.

 

I don't think there's anything wrong with the contents of the Makefile itself. As you can see I used a  Command prompt above and did "make clean" then "make" and it built your code using the Makefile that Studio had previously created. I thin the fault in your machine is the way the command shell and the make themselves are being executed. Something on your PC is leading to either wrong versions being used or the ones that are there not working in the "normal" way.

 

The expansion of "$<" to the list of source files is something make.exe itself does. The fact that it's apparently not happening on your machine leads me to think that it is not the right make that is being executed or the way in which it IS being executed differs from normal. No idea why though.

 

It's quite difficult to google things like "$<" and "$@" because Google just "eats punctuation" but there is a search engine that does not here:

 

http://symbolhound.com/

 

If I use to that to search for things like "$< is not being expanded" I get hits such as this:

 

http://stackoverflow.com/questio...

 

(though that particular thread is something a bit different). It may, however, be worth trying a few searches at SymbolHound and trawling the results in case anything similar to this has been seen previously that may give a clue (don't limit yourself to the AVR world either!).

 

Unfortunately most Makefiles have $< and $@ in them so you will get a lot of spurious hits simply because people are quoting "normal" makefiles.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Understood.  Thanks again.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just found out that one of our other computers has AS7 as well.  Turns out that it has the exact same issue.  Maybe something having to do with Antivirus or firewall.  Is it possible that AS7 is trying to access something else in Windows 7 that it does not have permission to access.  I wonder if running as administrator would help?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Running in Administrator fixed my issue.  Thank you for all of your help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow that is weird beyond belief. Wonder how a permissions issue could affect $< ? 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Maybe it's not that simple.  In order for me to always run in Admin, IT had to add a special shortcut with Admin rights.  It appears that all of my settings go back to factory default with the special shortcut.  Whereas, if I click on the actual AS7 shortcut, I still get the same error.  Even now, I have both open and with the same code and one just works and the other I get the error.  Weird!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,ggudino:

recently i have met the same question as you too;

 .

     At first , i take the problem as make file mistake , but my friends solve this problem by simply check   head file "SoftwareSerial.h" ,and find that "#endif" is missing from the  head file .

just add a "#end if"  ,all the error is gone.

    SO i think the "recipe for target main.o" failed is not caused by  make file , maybe the problem exist in your head file , if your head file is wrong , it will cause compiling error . and that my result an "recipe for target main.o failed" .

you can have a try in finding mistake in your headfile ,or just comment your code in headfile. 

   i think this may help.

 

 

 

Meaning less

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want to see what really caused the errors forget that very limited "Error List" and switch to the "Output" tab instead where you can see everything that happened during the build. Always concentrate on the first error that was output. Often when you fix one you then fix the next 50..100 errors too!