not another undefined reference to main !!

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

Hi everybody,
This is my new installation of avrstudio 5,
after that, added the plugin of C++, and created a new project:

#include 
int main(void)
{
    while(1)
    {
        //TODO:: Please write your application code 
    }
}

That code, is throwing the "undefined reference to main"
I'm using the default makefile that generate avrstudio.
Any idea what other thing I must configure?

thanks!

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

How sure are you that it's that code that's actually being built? What does avr-nm say the .o contains?

Expect to see something like this:

E:\avr[i386_vc]>avr-nm test.o
00000034 a __CCP__
0000003e a __SP_H__
0000003d a __SP_L__
0000003f a __SREG__
00000000 a __tmp_reg__
00000001 a __zero_reg__
00000014 T main

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

Didn't you get a compilation error with that main? It has a return type of int, but does not return anything.

EDIT: Apparently not - I did what you describe and got exactly that code from the project wizard. But in my case it builds correctly..

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

I had this once as well, but never figured out why. I just gave up on AS5 at that point.

Regards,
Steve A.

The Board helps those that help themselves.

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

clawson wrote:
How sure are you that it's that code that's actually being built? What does avr-nm say the .o contains?

I cannot buid, that is the problem, so there is no .o

regarding to JohanEkdahl comment, I added a return 0 but the same problem.
I just realise about the output console, this is the message:

Quote:
[ERROR] Could not read the toolchain settings from the project file. Data at the root level is invalid. Line 2, position 7.

I'm sure that Line 2 position 7 does not refer to my code, because it corresponds to a comment added by AS5.

And..Koshchi..."keep walking"!

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

Oh, forgot to add: My AS5 installation is just the IDE as such. I am using WinAVR-20100110 as the tool chain in AS5.

Do we have any other volunteers that are willing to confirm the problem in AS5 with Atmels AVR Toolchain, and can confirm that the problem is not there with the WinAVR toolchain? If so, please report results here and I will add it to my PM on known deficiencies in AS5.

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

Quote:

I'm sure that Line 2 position 7 does not refer to my code

It's pretty clear that it refers to the project file (i.e. the .avrgccproj file). It is somehow broken. If so this has nothing to do with the tool chain, and everything to do with the AS5 IDE and/or the C++ addin.

You did restart AS5 after downloading the addon, yes? (IIRC I had a forced auto restart after d/l of the addin).

Also: If the source file never gets compiled, then it follows that there is no main in any .o for the linker to find.

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

Quote:
[ERROR] Could not read the toolchain settings from the project file. Data at the root level is invalid. Line 2, position 7.

Yeah that's from the project file. Can you attach the project file?

Regards

Senthil

 

blog | website

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

Quote:

I cannot buid, that is the problem, so there is no .o

Of course there is - the error is a link error not a compilation error so of course you have a bunch of .o's built - the problem is that when the linker comes to join them it cannot find "main" in any of the .o's presented to it. So, like I say, check what those .o's are exporting with avr-nm.

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

Hi all,
Reading around the forum, I'll follow an advice, and translate the libraries to C, so there is no longer needed the C++ add-on.
Thanks a lot anyway.

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

is there any way to know the flow taken by the compiler when it's building the aplication?
The problem comes up with a repetitive warning. (three times)

#warning "This file has been moved to ."

The first time, when I call a delay, the warning was removed after added:

#include 

, but after that warning, I have another two ones, and they are coming from any nested library, that's the reason why I want to see/know the flow,or at least to know "who is calling another delay"

Thanks!

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

For AVR Studio there is no such function that I know of.

What you could do is to simply hide the file delay.h (not util\delay.h). You should then get an error and from that you should be able to deduce what files does the deprecated include.

But then again, you should be able to locate the deprecated includes with a "Find in files" search (unless you have source files that are not in the project folder sub-tree).

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]