Basic C program failed to build

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

I'm very new to Atmel Studio and don't understand why my build fails. All I am trying to do is write a basic program to blink an LED on an Atmega328p. I've tried a few different blink programs I found online and all have failed to build. Here is the error that I get. Please help!

 

------ Build started: Project: blinkled, Configuration: Debug AVR ------

Build started.

Project "blinkled.cproj" (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 "\\Mac\Home\Documents\Atmel Studio\7.0\blinkled\blinkled\blinkled.cproj" (target "Build" depends on it):

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

Building file: .././main.c

Invoking: AVR/GNU C Compiler : 4.9.2

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -x c -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.90\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.90\gcc\dev\atmega328p" -c -std=gnu99 -MD -MP -MF "main.d" -MT"main.d" -MT"main.o" -o "main.o" ".././main.c"

/usr/bin/sh: C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe: command not found

make: *** [main.o] Error 127

Done executing task "RunCompilerTask" -- FAILED.

Done building target "CoreBuild" in project "blinkled.cproj" -- FAILED.

Done building project "blinkled.cproj" -- FAILED.

Build FAILED.

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

 

 

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

Looks like AS is unable to find avr-gcc exe. Are you sure it is present in the compiler path listed above?

/Kannadiga

/* Always speak politely to an enraged Dragon */

Last Edited: Tue. Nov 10, 2015 - 04:34 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not sure how to check? Can I just download avr-gcc.exe and tell AS where it is?

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

jared81883 wrote:
I'm not sure how to check?

Is this file present: "C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe"

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Yes, that file does exist in that location.

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

Hi, I'm new to Atmel Studio 7 and am having the same problem. When I try to build a basic c program I get the exact same error as above. I've not got anything plugged into the USB ports of my computer, I am just wanting to see if the code will compile. Also, I have checked the location of avr-gcc.exe and it is in the path C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe.

 

Any ideas on how to get this working would be much appreciated.

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

I still haven't been able to figure it out. It's very frustrating because there isn't much information on fixing this problem. If you figure it out I would love to know how. Sorry I wasn't able to help.

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

Try to issue the compiling command on a command prompt. Success/failure?

Use the Make documentation to see if there is an error code 127 described.

IIRC one can save the makefile from studio. Do that and run the Make command on a command prompt. Success/failure?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Thanks for your help Johan. I put a simple C program on my desktop called test.c. Once I navigate to the file in the command prompt what is the command to build the file? I'm assuming the first word is atprogram? 

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

jared81883 wrote:
I'm assuming the first word is atprogram?

No, it's not. ("atprogram" is a command to write an already compiled application into the flash memory of an AVR.

I put a simple C program on my desktop called test.c.

What I suggested was to use exactly the project you posted about in your first post. If you change to another program placed in another place then we can not compare the different attempts we make with the failing Atmel Studio project.

 

First we want to test if the compiling command works at all. You copy the exact compiling command from when Atmel Studio tried to build the app, and issue it on a command prompt. If we use the project in your first post it would be

"C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\bin\avr-gcc.exe" -x c -funsigned-char -funsigned-bitfields -DDEBUG -I"C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.90\include" -O1 -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -g2 -Wall -mmcu=atmega328p -B "C:\Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.0.90\gcc\dev\atmega328p" -c -std=gnu99 -MD -MP -MF "main.d" -MT"main.d" -MT"main.o" -o "main.o" ".././main.c"

Before issuing that command, be sure to move to the debug folder under the project. The command needs to be issued from there since it references the source file relative to that folder.

 

What we want to investigate is if the command fails in the same way when issued "manually" like this as when the Studio / Make build system tries to build the application.

 

 

[EDIT] We start by doing this on a Windows CMD command prompt. If that works then we'll try the same but on a sh shell. If that also works we will eventually move on to save the make file from Studio and try to run the complete build on a sh shell.

 

If the complete build works when run "manually" but fails in Studio then we'll need to call in the Atmel guys.

 

Else, when we find the failing step, we'll know a lot more than now - and can hopefully understand and solve the problem. Structured step-by-step fault seeking - just as any fault seeking should be.[/EDIT]

 


 

Also, just to have as much facts on hand as possible:

What Studio version?

What Windows version?

 

I see in the command that the project folder is: \\Mac\Home\Documents\Atmel Studio\7.0\blinkled\blinkled\blinkled.cproj

The project seems to be placed on a network disk (since Studio refers to it by a UNC path). Have you tried to place the project on a local drive (rather than on the network resource named "\\Mac")?

 

And given that name, is all this actually done on a Macintosh?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Mon. Nov 23, 2015 - 11:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the great help. I think I have an idea of what the problem is after trying what you suggested. I'm running Windows 10 but on my Mac using Parallels. The project is not being saved on the virtual machine but on my mac. Where do you usually save your projects, like what folder?

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

I got it working! That was the issue.

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

jared81883 wrote:
I got it working!

That's good to hear.

 

Closeout of this involves paying back for the help, and giving future readers a quick(er) way to solving the same problem. What you need to do now:

 

1) Feed back to this thread a good as possible description of the problem and it's solution.

2) Mark a post in the thread as the solution. (Probably the post 1) with your own final description.

3) Edit the thread to include the word(s) Macintosh, Parallels and maybe something more.

 

My personal observation is that Studio and/or Make and/or sh likely does not support UNC path names. It would be nice to know exactly which. I have no equipment (a Windows or Samba server) available ATM to test this. The test procedure would be something like what I posted in #10.

 

If someone is willing to donate a Mac Mini (preferably with 16 GB RAM but 8 will do) to me I promise I'll do some tests.. ;-)

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Tue. Nov 24, 2015 - 08:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After upgrading to Atmel Studio 7, I am faced with the same error as above.  The error was not there when I used AS 6.2.  Even after a re-install of AS 7, I am unable to compile.

Try to issue the compiling command on a command prompt. Success/failure?

Use the Make documentation to see if there is an error code 127 described.

IIRC one can save the makefile from studio. Do that and run the Make command on a command prompt. Success/failure?

Is it possible to provide links on how to send these commands in Windows 7?  I know that it will require Command Prompt and AVR-GCC.exe, but the added designations, make files, location of make files, location of c file, etc is an area that I am lacking.

 

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

Is it possible to provide links on how to send these commands in Windows 7?  I know that it will require Command Prompt and AVR-GCC.exe, but the added designations, make files, location of make files, location of c file, etc is an area that I am lacking.

As you don't appear anywhere previous in this thread I have no idea what commands it is you are trying to issue or why but I'll point out a couple of general items:

 

1) If in Windows you just start a Command Prompt and type "make" or "avr-gcc" you will probably find it won't work because the default PATH for commands won't include the place where Studio 7 is holding its copy. If, however you run Studio then visit the Tools menu (think it is) and use the option to "start Command Prompt" there then in that command prompt you *will* find that make and avr-gcc work and it is the version that comes with AS7 that is being used. So always start your command prompt that way.

 

2) The way a build "inside" the AS7 IDE usually works when you "Build" is that first AS7 looks at whether you are building "Debug" or "Release". Based on this it creates a sub-directory from the project directory called "debug" or "release" and then, within it, it creates a Makefile that lists the source files for the project and some rules of how it should be built. Because it is in a sub-directory all the references to things like main.c and uart.c and so on are relative to the location of the Makefile so typically "../main.c", "../uart.c" and so on.

 

So if you start AS7 then visit Tools and start a command prompt from there then CD to the directory where the project files are located you should find you can then "CD debug" or "CD release" to switch into the sub-directory where AS7 has already created a Makefile. If, while that is the current directory, you then just give the command "make" the code should be built (or attempt to be built) in the same way that it would "inside" AS7. However you are now in a position to edit Makfile and also to give command line parameters when you invoke "make" that well tell it to behave in ways (like printing debug info) that will assist you in determining why build "inside" AS7 is not working.

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

Had the exact same issue but with a samba network drive and other network files on win10 and AS 7.0.

Works perfectly fine with a local copy.

 

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

I had the same problem, if you have Atmel studio 6.1

The file (and the folder path that you need to copy is here)

 

\Atmel 6.1 Studio\Atmel Toolchain\AVR8 GCC\Native\3.4.2.1002