Jump to content
Ultimaker Community of 3D Printing Experts
gr5

How to build Marlin the way tinkerghome and Ultimaker do it if you have windows

Recommended Posts

TinkerGnome helped me set up the Marlin build environment. How to do it is out there and published but I wrote down extra details. I don't know if my notes make sense but I thought I would post them here. If you try to repeat this and have any trouble let me know below and I will clarify the instructions as necessary.

Get the source code from github and put somewhere on your hard drive. I'm not going to give you a tutorial on github - there's a lot to github features alone - you can simply download the zip but if you plan to edit it's best to install git and clone the project. If you want to submit bug fixes you absolutely have to create your own github account and create a fork, make changes, test changes, push changes to github and then send a pull request.

Ultimaker's source code is here:

https://github.com/Ultimaker/Ultimaker2Marlin

tinkermarlin - a variant which is better is here (although there may be a bug in version 16.12.1):

https://github.com/TinkerGnome/Ultimaker2Marlin

First know that the IDE is code::blocks. We need SDL 1.2 and arduino IDE and mingW compiler. Start with mingw compiler:

Install arduino compiler from here - version 1.6.10 works but newer versions should be fine - put it into a path with no spaces (not program files which has a space):

https://www.arduino.cc/en/main/software

mingw gcc get here:

https://sourceforge.net/projects/mingw/files/

Near the top is a setup.exe file. After it installs it launches the installation manager - at this point nothing useful is installed.

Next mark packages mingw32-base and mingw32-gcc-g++ (gnu c++ compiler) to be installed and then menu item "installation" "update catalogue". Wait for this to finish.

sdl get here:

https://www.libsdl.org/download-1.2.php then get the win32 version near the bottom mingw32 version of sdl - this gets us SDL.h and sdl.dll

from the gzip file copy the bin\sdl.dll file into c:\mingw\bin\

and lib\* to c:\mingw\lib\*

and \include\SDL folder to c:\mingw\include\ such that there are many .h files named SDL*.h in c:\mingw\include\SDL\

optionally copy SDL.dll to c:\windows so it can be found more easily. If there is already an SDL.dll there don't overwrite it - yikes.

codeblocks - you only need codeblocks if you want to create a simulation but you should definitely do this - it allows you to break on a line of code and test so many things! But if you write perfect code everytime then skip codeblocks.

http://codeblocks.org

I recommend installing this last or at least after mingw or restart it after installing mingw. After codeblocks is installed and started it somehow seems to find mingw.

After launching codeblocks I think it asked me for a project file that was in the source tree here:

.....\MarlinSimulator\UltiLCD2_Sim.cbp

In code::blocks menu click "build" "build". You should get no errors in bottom "build messages" window.

Click menu "debug" "start/continue" and it should pop up the simulator and boot. Simulator shows screen and position of x,y,z axis graphically and more. Before starting your program you can add a breakpoint in codeblocks on a particular line of code - right click on the number to the left of your

line of code and add a breakpoint. Then click the play button called "debug" (versus the play button titled "run"). When the simulator

gets to that line it will pause and you can examine variables (right click and add to watch and see values of variables).

building the hex files: you need to launch the mingw64 shell - it looks like a dos window but better. I don't know how to launch that but it came for free with my installation of git gui (from the git website).

You build like this - get to the marlin folder and do:

./package.sh

But it will fail the first time. You need to set a few things up. edit this package.sh file and add this line below the other arduino_path definitions:

 

ARDUINO_PATH=c:/Arduino

 

(or change to wherever you installed arduino ide - again - no spaces in path allowed!). You should probably double check that this file is in this exact path:

c:/arduino/hardware/tools/avr/bin/avr-gcc.exe

If not, then you probably need to modify AVR_TOOLS_PATH in marlin/Makefile. I didn't have to modify that.

You don't have to do anything with ARDUINO_VERSION unless you are using a version before 1.0.0 in which case you should probably get a newer arduino ide anyway.

Also I had to redefine MAKE by adding the following line in package.sh - this is where mingw32 installed for me (/c/ is the equivalent of c:\)

 

MAKE=/c/MinGW/bin/mingw32-make

 

This editing of package.sh may sound confusing but it's really quite simple - basically you are telling package.sh where a few folders are. Once you look at it then you will probably realize how simple it is. And if you screw up it's obvious - it will say "can't find mingw" or something like that.

  • Like 3

Share this post


Link to post
Share on other sites

Awesome. I just wrote a long response to this with lots of details about how I got on and it's all lost for some reason. The browser, our new operating system. faaaaaantastic. I will try to respond again sometime.

Thanks @gr5 and @tinkergnome for taking the time to do this. it helped a lot.

Edited by Guest

Share this post


Link to post
Share on other sites
building the hex files: you need to launch the mingw64 shell

I downloaded that from sourceforge and it looks like the shell (called "terminal window") that is put in the start menu is just a shortcut to a BAT file which has :

set PATH=C:\Program Files\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%

So I just put a path environment variable to c:/MinGW/bin/ and then launch the command prompt window as normal. So I am not sure that mingw64 is needed.

However in the end I got the same error as I got when trying to build in the IDE

c:/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/lib/avr6\libatmega2560.a(eerd_dword.o): In function `eeprom_read_dword':
(.text.avr-libc+0x0): multiple definition of `eeprom_read_float'
_Ultimaker2Dual/UltiLCD2_hi_lib.o:UltiLCD2_hi_lib.cpp:(.text.eeprom_read_float+0x0): first defined here
c:/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions
collect2.exe: error: ld returned 1 exit status
Makefile:405: recipe for target '_Ultimaker2Dual/Marlin.elf' failed
mingw32-make: *** [_Ultimaker2Dual/Marlin.elf] Error 1

So Next I will be trying to revert to an older version of the Arduino compiler- I installed via Arduino IDE 1.8.5.

Thanks,

Greg

Share this post


Link to post
Share on other sites

ust to follow up on this : I don't think I was running the right version from GitHub; so between the marlin code version and the arduino version I was running into different issues. I took a step back and

-got the latest version of @tinkergnome 's geek_mode branch (17.10.1)

-changed a couple of paths:

--makefile : ARDUINO_INSTALL_DIR ?= /c/Arduino

--package.sh : ARDUINO_PATH=C:/Arduino

and now with Arduino 1.8.5 restored to that location (and all the previous configuration as per @gr5 's post I got a successful build of the hex files

Thanks again

Greg

  • Like 1

Share this post


Link to post
Share on other sites

I am getting some errors stl_base-funcs.h while building through codeblocks  Is there any problem with version if so how to degrade?

 

 

 

||=== Build: Debug in UltiLCD2_Sim (compiler: GNU GCC Compiler) ===|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|78|error: expected nested-name-specifier before 'iterator_traits'|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|78|error: expected initializer before '<' token|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|93|error: expected nested-name-specifier before 'iterator_traits'|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|93|error: expected initializer before '<' token|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|109|error: 'input_iterator_tag' has not been declared|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|115|error: 'input_iterator_tag' has not been declared|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|132|error: expected nested-name-specifier before 'iterator_traits'|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|132|error: expected initializer before '<' token|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|142|error: 'input_iterator_tag' has not been declared|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|154|error: 'bidirectional_iterator_tag' has not been declared|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|153|error: redefinition of 'template<class _BidirectionalIterator, class _Distance> void std::__advance(_BidirectionalIterator&, _Distance, int)'|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|142|note: 'template<class _InputIterator, class _Distance> void std::__advance(_InputIterator&, _Distance, int)' previously declared here|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|170|error: 'random_access_iterator_tag' has not been declared|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|169|error: redefinition of 'template<class _RandomAccessIterator, class _Distance> void std::__advance(_RandomAccessIterator&, _Distance, int)'|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|142|note: 'template<class _InputIterator, class _Distance> void std::__advance(_InputIterator&, _Distance, int)' previously declared here|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h||In function 'void std::advance(_InputIterator&, _Distance)':|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|195|error: expected nested-name-specifier before 'iterator_traits'|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|195|error: expected '(' before 'iterator_traits'|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|196|error: '__d' was not declared in this scope|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|196|error: '__iterator_category' is not a member of 'std'|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|204|error: expected nested-name-specifier before 'iterator_traits'|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|204|error: expected ',' or '...' before '<' token|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h||In function '_ForwardIterator std::next(_ForwardIterator, int)':|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|209|error: '__n' was not declared in this scope|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|216|error: expected nested-name-specifier before 'iterator_traits'|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|216|error: expected ',' or '...' before '<' token|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h||In function '_BidirectionalIterator std::prev(_BidirectionalIterator, int)':|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_iterator_base_funcs.h|221|error: '__n' was not declared in this scope|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|233|error: '__normal_iterator' in namespace '__gnu_cxx' does not name a template type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|234|error: '__normal_iterator' in namespace '__gnu_cxx' does not name a template type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|236|error: 'reverse_iterator' in namespace 'std' does not name a template type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|237|error: 'reverse_iterator' in namespace 'std' does not name a template type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|402|error: '_RequireInputIter' in namespace 'std' does not name a template type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|402|error: expected '>' before '<' token|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|506|error: '_RequireInputIter' in namespace 'std' does not name a template type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|506|error: expected '>' before '<' token|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|547|error: 'iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|556|error: 'const_iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|565|error: 'iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|574|error: 'const_iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|583|error: 'reverse_iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|592|error: 'const_reverse_iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|601|error: 'reverse_iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|610|error: 'const_reverse_iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|620|error: 'const_iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|629|error: 'const_iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|638|error: 'const_reverse_iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|647|error: 'const_reverse_iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|970|error: 'iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|984|error: 'iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|1014|error: 'iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|1031|error: 'iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|1051|error: 'iterator' does not name a type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|1094|error: '_RequireInputIter' in namespace 'std' does not name a template type|
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h|1094|error: expected '>' before '<' token|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build failed: 50 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|
 

 

 

 

Share this post


Link to post
Share on other sites

Hard to say... all error messages are related to mingw include files, but it does not list the file that it actually tries to compile.

I use the mingw compiler that comes bundled together with Code::Blocks 16.01 (have not tried the newer version yet). I recommend to try this first.

And take sure that the include path for SDL 1.2 is correct (Project -> Build Options -> GNU GCC Compiler -> Search Directories - for "Compiler" and "Linker").

Share this post


Link to post
Share on other sites

I configured mingw and codeblocks again now i was getting 3 errors What is SDL main compiler looking for

 

||=== Build: Debug in UltiLCD2_Sim (compiler: Mingw64) ===|
ld.exe||cannot find -lSDLmain|
ld.exe||cannot find -lSDL|
||error: ld returned 1 exit status|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
 

Share this post


Link to post
Share on other sites

Okay so it's properly compiling all the files but failing at the link step (LD is the linker - it used to be called a loader).  The linker needs to collect all the compiled files (I think called object files?) and combine them together and also it needs to link them with the libraries including evidently these two link libraries: SDLmain and SDL.  I think the files will have the extension .s or .so maybe?  I don't do linux compiling often enough obviously so I forget extension names.  Or maybe they are ".lib"?  I think that might be windows only.  Anyway when you did the "project -> build options -> "etc it sounds like you got the right search directories for the compiler but didn't tell the linker where the link libraries are.

 

Share this post


Link to post
Share on other sites
7 hours ago, venkatesh said:

I configured mingw and codeblocks again now i was getting 3 errors What is SDL main compiler looking for

 

||=== Build: Debug in UltiLCD2_Sim (compiler: Mingw64) ===|
ld.exe||cannot find -lSDLmain|
ld.exe||cannot find -lSDL|
||error: ld returned 1 exit status|
||=== Build failed: 3 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
 

 

You're making progress. Double check, that the search directories for the linker are including the SDL-"lib" folder.:fingerscrossed:

 

codeblocks_searchdir.thumb.png.c2392e8111194e0cc7803273e4e1e393.png

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

Welcome to the Ultimaker Community of 3D printing experts. Visit the following links to read more about our Terms of Use or our Privacy Policy. Thank you!