2

I have been trying to compile a robot simulation.

I created an empty file called test.c and tried to compile a test using:

avr-gcc -mmcu=atmega328p test.c

AVR-GCC it's installed

copt@copt:~$ avr-gcc --version
avr-gcc (GCC) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
Este é um software livre; veja as fontes para as condições de cópia. NÃO HÁ
garantias; nem mesmo de COMERCIALIZAÇÃO ou ADEQUAÇÃO A UMA FINALIDADE
ESPECÍFICA.

and returned this:

/usr/lib/gcc/avr/5.4.0/../../../avr/lib/avr5/crtatmega328p.o:      
(.init9+0x0): reference not defined to "main"
collect2: erro: ld returned 1 exit status

Very similar to the principal one that I've been trying to make work. I think if solve this very basic problem, the biggest one will be solved.

FLAGS = -mmcu=atmega328p -Wall -gdwarf-2 -O3 -funsigned-char -funsigned-   bitfields -fpack-struct -fshort-enums 

It should be compiling normally.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

2 Answers2

2

For me it turned out that I had saved the code as the default FILE type. I found after I saved it as a .c file it was able to compile.

0

Happened to me too with the new version of Eclipse 2023.

On Debian 11, I installed the plugin from the "Market place" and it didn't work properly. I had to go to sourceforge get the last version of the plugin (2.4.2) and install it in Eclipse manually. Note that the installation by the "new location" method does not work either. It is absolutely necessary to install it with the "archive" method

There everything seems correct.

I created a new C project for AVR, created a src directory and a new source file which I named main.c I then copy-paste a test code in the main.c file and tried a "build project"

I got the error too: ...(.init9+0x0): reference not defined to "main"

It was while trying to compile it in command line mode, at the console, and having had the same compilation error that I realized the main.c file is in fact empty on the hard disk. I save the main.c file inside Eclipse and everything is ok.