I'm updating my 3D printer's firmware and I'm stuck. I Receive this error.
fork/exec C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc.exe: The filename or extension is too long. Error compiling for board Sanguino.
I'm not sure why I'm receiving this error and hoped someone might have an idea as to why. I've moved all of my Marlin files directly into my C:/ drive in an attempt to shorten it as recommended by one website as well as un-commenting some code that was unnecessary, also under the recommendation of a different forum. I'm very new to Arduino and the IDE software so if any of you tech gurus and wizards could share your knowledge I would appreciate it.
"" is the folder delimiter in Dos/Windows. "/" is the folder delimiter in Linux. You can't mix them. Since I assume this is coming from a Linux program, the "" is seen as an "escape" character.
"\P" becomes the Device Control String.
"\A" moves the Cursor Up.
"\h" becomes, I dunno.
"\t" is a tab character.
"\a" is also unknown.
In other words, you can't mix "/" and "" on a command line.
Look for instruction on compiling Marlin in Visual Studio, the problem seems to be specific to the Arduino IDE. Comments in the source code are irrelevant, that will do nothing to solve the problem.
Try changing the build directory in the IDE to a directory at the root of the C: drive. Create an empty directory at the root of the C: drive, using as short of a name as possible. Be careful, you DO NOT want to overwrite any pre-existing directory. In the IDE, go to Files > Preferences and look near the bottom of the window to see where the preferences.txt file is stored. You will need to edit that file to add build.path=C:\directory-name where directory-name is the name of the directory that you have created. Note that you must close the Arduino IDE before editing the preferences.txt file, then relaunch it afterwards, for the changes to take effect.
The error message is caused by the IDE generating a command for the linker that exceeds the maximum of 32767 characters allowed by Windows. If you have a computer running any variety of linux it will compile without error.
"" is the folder delimiter in Dos/Windows. "/" is the folder delimiter in Linux. You can't mix them. Since I assume this is coming from a Linux program, the "" is seen as an "escape" character.
"\P" becomes the Device Control String.
"\A" moves the Cursor Up.
"\h" becomes, I dunno.
"\t" is a tab character.
"\a" is also unknown.
In other words, you can't mix "/" and "" on a command line.
It does look odd, but that is the normal format used by the IDE, and will not cause any problems. The error message is a bit misleading, the root cause has nothing to do with the file names.
"" is the folder delimiter in Dos/Windows. "/" is the folder delimiter in Linux. You can't mix them. Since I assume this is coming from a Linux program, the "" is seen as an "escape" character.
SteveMann, I mixed up my foreward and back slash in my original post. I'm using Windows not Linnux. I apologise, like I said I'm new to this stuff. That's good information to have.
david_2018:
In the IDE, go to Files > Preferences and look near the bottom of the window to see where the preferences.txt file is stored. You will need to edit that file to add build.path=C:\directory-name where directory-name is the name of the directory that you have created. Note that you must close the Arduino IDE before editing the preferences.txt file, then relaunch it afterwards, for the changes to take effect.
david_2018, I'm still receiving the same error so let me see if I did this correctly. I created a new directory in my C:\ drive and named it Marlin-2.0-IDE. I opened up the preferences text file, closed IDE, then and added this line build.path=C:\directory-Marlin-2.0-IDE then saved the document, closed it and restarted IDE. Where is my mistake?
tr33c3:
david_2018, I'm still receiving the same error so let me see if I did this correctly. I created a new directory in my C:\ drive and named it Marlin-2.0-IDE. I opened up the preferences text file, closed IDE, then and added this line build.path=C:\directory-Marlin-2.0-IDE then saved the document, closed it and restarted IDE. Where is my mistake?
built.path=C:\Marlin-2.0-IDE, not C:\directory-Marlin-2.0-IDE, but it would be better to use something shorter than Marlin-2.0-IDE, preferably just a single letter. The whole point is to make the file path as short as possible (in terms of how many characters are used in the directory name).
There are 4 threads with this exact "filename too long" error with no resolution.
The error seems to be a fatal flaw in Arduino when compiling Marlin 2.0 in a Windows environment, so no user can correct the error. Therefore all users of Windows cannot compile Marlin 2.0 with Arduino. After spending days of time learning to be comfortable with Arduino I will have to abandon it for an alternate compiler.
That seems to me to be an unacceptable condition for an IDE in use by my so many 3d printer owners using Marlin and wanting to update firmware to Marlin 2.0.
My questions, is how does one request a fix from the Gurus of Arduino?
There is no setup() or loop() function in marlin.ino or any of the tabs it loads, so it can't be compiled. (Unless someone knows how to compile an ino file without setup or loop).
SteveMann:
I downloaded Marlin-2.0 to try compiling it here.
There is no setup() or loop() function in marlin.ino or any of the tabs it loads, so it can't be compiled. (Unless someone knows how to compile an ino file without setup or loop).
The setup() and loop() functions are located in src/MarlinCore.cpp, which the compiler appears to be finding and compiling despite the complete lack of any #include statements in any of the files in the sketch directory. Regardless, the Arduino IDE will successfully compile Marlin 2.0, aside from the problem being discussed here. The compilation itself does not cause any problems, it is the linker command issued by the IDE that exceeds the maximum command length for Windows, generating the misleading "File extension too long" error message.
Important note, do not set the IDE to display all warnings during compilation, this will lead to hundreds of warnings about compiler directives being potentially non-portable, but will otherwise compile without error. There are also some spurious "Error while detecting libraries included by ....." messages, but from what I've been able to find this is a bit of a bug with the IDE and there are no actual problems with missing libraries.
Depending on how Marlin is configured it may be possible to compile on Windows, numerous discussions have mentioned the problem occurs when the u8g2 library is needed, but disabling the display is hardly a viable solution.
It may be possible to use the online Arduino Create compiler, although there might be issues with the limited amount of compilation time you are allotted for a free account.
Thank you David_2018. Yes the problem occurs with use of U8glib.h.
I see U8Glib has been superseded by U8glib2.
Can the new U8Glib2 be used instead? I can add the U8Glib2 library to Arduino - can I change every instance of U8glib.h with U9glib2.h ans expect it to function?
I don't really think changing the version of that one library would make any difference, unless it has been substantially altered specifically because of the problems with Marlin. There is nothing wrong with the library itself, the problem is with the Arduino IDE and how it generates the command for the linker. I don't know how much interest there is in updating the IDE to work properly for Marlin, my impression is that the Arduino IDE is designed more for easy of use by beginners than for compiling highly complex code such as Marlin, and there are other IDEs for Windows that will work properly.
There are a couple of solutions. The problem is that with the folder hierarchy you hit the max number of characters in the string to compile. My compile string is 35,667 characters long. I believe this is due to the local library method that marlin 2 has changed to. Folders are definitely neater but my compile time was horrible.
you can change the build path by adding something like build.path=c:\temp\arduino in the arduino ide preferences.txt
file. ..... this may help, mine were still too long perhaps something shorter like c:\t might have helped
it sounds like they changed max filename strings in arduino 1.8.9 so updating fixed my problem
well... at a filename of 38k, the build did not work. It did with some less. So I have the file in several folders down.... time to relocate it. Onedrive folder is not going to work. So updating adruino ide does not fix the issue all the way.
There is a fix for this problem in the works, but it has only been applied to the nightly build of the Arduino CLI (command-line version). Here is the post by pert from another discussion (sorry I can't link the entire discussion, the website keeps inserting an extra quote into the web address for some odd reason).
pert:
My understanding is that this problem comes from the huge number of files in Marlin causing the command to be over the 32k character limit imposed by Windows. So the filename is not too long. It's the arguments in the command that are too long. I don't know why the error message says that.
Arduino is very aware of this problem and has been working on a fix. This fix is already completed in the nightly build of Arduino CLI. Arduino CLI is replacing arduino-builder (actually a lot of the arduino-builder code base is already coming from Arduino CLI), so a fix made in Arduino CLI will eventually propagate into all the other official Arduino development software, including an Arduino IDE. I don't know how how long that will be though.
So my recommendation is for you to use the nightly build of Arduino CLI to comp[ile and upload Marlin to your 3D printer. You can download it from the link provided here: Redirecting
So it's 2 months later, and I too am struggling with this. When I try to compile Marlin 2.0.7.2 for my CR-10S it generates a line with over 43,000 characters. Paths seem to be relative, so it doesn't matter what build.path is set to, but I set it to C:\m to make this simpler. The main problem is the sheer number of objects. To reduce the length of the command, I copied the long avr-gcc command from the Arduino IDE and made a file C:\m\comp.bat. For as many directories as possible under C:\m\ I changed the directories to single letters and also made the change in the bat file. For example:
Thanks David, that works! I had previously tried the 1.9 build, but that failed as well. The 1.8.14 hourly uses absolute paths rather than relative, but was still well under the 32k character limit.