Marlin not compiling to Mega 2560

I can't get past this error message, please help.

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\Shane\AppData\Local\Temp\ccC8NNve.ltrans0.ltrans.o: In function `main':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `setup'

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/main.cpp:46: undefined reference to `loop'

collect2.exe: error: ld returned 1 exit status

exit status 1

Error compiling for board Arduino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


Thank you in advance for you help.

Please show your code - it looks like you are missing void loop() & void setup().

Marlin firmware is organized in order to be compiled with PlatformIO

I suggest you to use VSCode + PlatformIO to compile and upload to Arduino Mega board instead Arduino IDE

Why talk such nonsense!

Sketch uses 48118 bytes (18%) of program storage space. Maximum is 253952 bytes.
Global variables use 6602 bytes (80%) of dynamic memory, leaving 1590 bytes for local variables. Maximum is 8192 bytes.

compiled in Arduino IDE V1.8.15

It's just a suggestion, i didn't write that it doesn't work.

Do not panic youself..

I'm not panicing, been doing this for over 10 years so know what to do.

The point is you said that it is organised to be compiled with PlatformIO, It is NOT.

This could confuse the OP, as well as possibly getting them to install PlatformIO, and failing due to a couple of changes that they need to make. If you can't provide correct information, better to not provide any.

This field can be confusing enough for beginners, and providing unfounded help can often confuse!

The recent versions of Marlin have an improved structure. They have placed all the lower level code under the src subfolder of the Marlin sketch, so that only the files of interest to the average user will be exposed in the Arduino IDE (Marlin.ino, Configuration.h, Configuration_adv.h).

The missing function definitions mentioned in the error message are in the files under src. This makes me suspect that the entire src subfolder is missing.

This could happen in one of two ways:

You never downloaded the full Marlin sketch.

Sometimes people just grab the few obvious files from GitHub without realizing there are hundreds more.

If you downloaded Marlin from your 3D printer manufacturer's website or from the "Download" page of the Marlin website, then you'll be sure to get the whole thing.

A bug in the Arduino IDE caused the loss of the src subfolder

Unfortunately, the classic Arduino IDE has a bug where "Save as..." only saves the files in the root of the sketch folder to the new sketch location. So the new sketch is missing this src subfolder.

You might have chosen to do a "Save as..." after making your customizations to Marlin, rather than saving in place over the stock download.

You can check for this problem by selecting Sketch > Show Sketch Folder from the Arduino IDE menus. This will open the sketch folder in your file browser.
You should see a file structure like this:

Marlin
|-- Configuration.h
|-- Configuration_adv.h
|-- Makefile
|-- Marlin.ino
|-- Version.h
|-- lib
|   `-- readme.txt
`-- src
    |-- MarlinCore.cpp
    |-- MarlinCore.h
    |-- ...

If the src subfolder is missing, just copy it over from the original download of Marlin to your sketch.

After that, try compiling Marlin again. These error messages should now be gone.

1 Like

In the readme.md of repo, there are instructions for installing Marlin firmware both for VSCode+PlatformIO and Arduino IDE.

With PlatformIO, the configuration is done for each distinct project (as ALL "pro" IDE do), libraries dependencies and extra configurations included!
And in fact there is the platformio.ini configuration file in source root for this!

So you don't need to reconfigure your board options, reinstall library if missing due to whatever reason etc etc every time you want upload the firmware (and with Marlin, while you are looking for the right configuration of your machine, this can happen very often)
From my point of view, this is better for a beginner! That the reason for my suggestion.

If you prefer the prehistoric Arduino IDE, it's your choice and no one want convince you leaving your 10 years old habits.

I use PlatformIO for all my professional dev.

Your move . . .

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.