Building Kicad on Windows 10 With Eclipse/Msys2 (updated)

After some struggle and with the help of fellow Kicad developers I have managed to get a (mostly) integrated build of Kicad on Windows 10 using Eclipse. Similar instructions should work on any Eclipse platform.

Msys2 Installation

Install Msys2 (Download Msys2 http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20161025.exe )

Open a Mingw64 terminal ( msys64/mingw64.exe ) as this only seems to work if you open a mingw64 window.

pacman -Syuu
Answer yes to remove conflicts. Close the window via task manager when done.
pacman -Syuu
This takes a long time. Close the window via task manager when done.
pacman -Syuu
To make sure all is up to date

copy and paste these lines into Mingw64

pacman -S base-devel \
git \
mingw-w64-x86_64-cmake \
mingw-w64-x86_64-doxygen \
mingw-w64-x86_64-gcc \
mingw-w64-x86_64-python2 \
mingw-w64-x86_64-pkg-config \
mingw-w64-x86_64-swig \
mingw-w64-x86_64-boost \
mingw-w64-x86_64-cairo \
mingw-w64-x86_64-glew \
mingw-w64-x86_64-curl \
mingw-w64-x86_64-wxPython \
mingw-w64-x86_64-wxWidgets \
mingw-w64-x86_64-toolchain \
mingw-w64-x86_64-glm \
mingw-w64-x86_64-oce \
mingw-w64-x86_64-ngspice \
mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain

Install Eclipse

In Windows install Eclipse CDT for Windows 64 bit see https://www.eclipse.org/downloads/packages/release/2019-09/r/eclipse-ide-cc-developers

You need to edit the eclipse.ini file and change the line
-Xmx1024m
to
-Xmx2048m
Or
-Xmx4096m

This increases the heap for Java so you don’t get out of memory errors.

Save the eclipse.ini and load eclipse to see if it works.

Download and install Kicad Source Files

In the mingw64 terminal and sure you can run mingw32-make.exe. If not, update the dos/windows path until you can.

Note: this assumes you want the development build. If you want a release build, download that, for example kicad-5.1.4.tar.xz and use that name (kicad-5.1.4.tar.xz) insteead of kicad-source-mirror-master.

Download the Kicad source files from https://github.com/KiCad/kicad-source-mirror

Untar or unzip into /home/kicad-source-mirror-master

Alternatively,

git clone https://github.com/KiCad/kicad-source-mirror.git

This will create a local repository directory called kicad-source-mirror

At any time you can update the repository by

cd kicad-source-mirror
git pull origin master

Note that this will leave files which are in kicad-source-mirror but not in the kicad source repository unaffected. *** However *** they will over write your versions of those files! So if you edit cmakelists.txt or any other Kicad source file those edits will be lost.

Create a directory such as c:/home/eclipse-kicad. This will be your build directory.

cd /home/eclipse-kicad

Copy and paste these lines into Mingw64

cmake -DCMAKE_BUILD_TYPE=Debug \
-G “Eclipse CDT4 – Unix Makefiles” \
-DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE \
-DCMAKE_PREFIX_PATH=C:/msys64/mingw64 \
-DCMAKE_INSTALL_PREFIX=C:/msys64/mingw64 \
-DDEFAULT_INSTALL_PATH=C:/msys64/mingw64 \
-DMSYS=TRUE \
../kicad-source-mirror-master

This takes a few minutes but you only do it once.

(note: you may have to copy/paste into a text editor instead of from this web page)

Note that the -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE switch creates a link between the build and source directories for eclipse. This allows for error highlighting, etc..

You can test the build with
make -j install (Note: the -j means use as many cores as you can and reduces compile time on my system by 70%). This process may take hours: on my gaming laptop it takes about 30 minutes if I use the -j option.

In Eclipse

File->Import General->Existing Projects into Workspace Select Root Directory as
/home/kicad-source-mirror-master/eclipse-kicad

Wait for the indexing to complete (this will take some time)

select debug configuration (at the top near the red square)

Right click on project root select Build Targets go to the bottom and select Install.
First time, edit and set make to C:\msys64\usr\bin\make.exe -j then click build.

To rebuild select the project root and hit F9. Note that it you don’t select F9 or Build Targets Install it will not copy the project in the appropriate bin directory.

Note that you can access the source files in Eclipse by clicking [Source Directory] in the Eclipse project and you can rebuild by clicking the (*) Build Targets group.

I have not yet figured out how to integrate the source, build, and debug functions, however I can use the Eclise standalone debugger (see https://wiki.eclipse.org/CDT/StandaloneDebugger ) to debug pretty much any
executable which has been compile with debug info as long as I also have the source files.

I will update this with any corrections or if, as, and when, I figure out integrated debugging.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s