pcb2gcode is a command-line software for the isolation, routing and drilling of PCBs. It takes Gerber files as input and it outputs gcode files, suitable for the milling of PCBs. It also includes an Autoleveller, useful for the automatic dynamic calibration of the milling depth.
pcb2gcodeGUI, the official GUI for pcb2gcode, is available here.
If you find this project useful, consider donating money to charity.
This development version of pcb2gcode does not get into repositories of distros. If you want to test this version, you will have to go to the section below (installation from GIT).
- pcb2gcode stable ->
https://aur.archlinux.org/packages/pcb2gcode/ - pcb2gcode git ->
https://aur.archlinux.org/packages/pcb2gcode-git/
-
Download the latest tarball from https://github.com/pcb2gcode/pcb2gcode/releases
-
Open a terminal and cd to the extracted tarball
-
type the following:
su <the root password> yum groupinstall "Development Tools" yum install cmake boost-devel gtkmm24-devel gerbv-devel exit cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build -j$(nproc) su -c 'cmake --install build' -
done.
There are pcb2gcode packages in the official repositories. You can install the with
sudo apt-get install pcb2gcode
Unfortunately, these packages are seriously outdated. If you want to download the latest development version, go to "Installation from GIT".
Windows prebuilt binaries (with all the required DLLs) may be available in the release page. Due to difficulties with the CI pipeline, these are not reliably built and may be missing for certain releases. See below for instructions how to build pcb2gcode yourself.
pcb2gcode is available in Homebrew. To install it open the "Terminal" app and run the following commands; pcb2gcode and the required dependencies will be automatically downloaded and installed:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install pcb2gcode
If you want to install the latest version from git you'll need CMake, Boost with the program_options library (dev, >= 1.56), gtkmm2.4 (dev) and libgerbv (dev).
Unfortunately pcb2gcode requires a rather new version of Boost (1.56), often not included in the oldest distros (like Ubuntu < 15.10 or Debian Stable). Moreover Boost 1.56 sometimes freezes pcb2gcode, while Boost 1.59, 1.60 and 1.61 are affected by a program options bug. You can download a working version of Boost (1.57 and 1.58 work well) and build it manually with:
$ ./bootstrap.sh --with-libraries=program_options --prefix=<somewhere>
$ ./b2 variant=release link=static
$ ./b2 install
Then configure CMake with -DBOOST_ROOT=<boost install directory> -DPCB2GCODE_ENABLE_STATIC_BOOST=ON.
To build with coverage outputs, configure with -DPCB2GCODE_ENABLE_CODE_COVERAGE=ON and run ctest --test-dir build --output-on-failure.
Ubuntu 12.04 does not include gcc 4.8 (needed for the C++11 support); you can install it with:
$ sudo apt-get update
$ sudo apt-get install software-properties-common python-software-properties
$ sudo add-apt-repository "ppa:ubuntu-toolchain-r/test"
$ sudo apt-get update
$ sudo apt-get install g++-4.8
$ export CXX=g++-4.8
$ sudo apt-get update
$ sudo apt-get install build-essential cmake libboost-program-options-dev libgtkmm-2.4-dev gerbv git librsvg2-dev
$ git clone https://github.com/pcb2gcode/pcb2gcode.git
$ cd pcb2gcode
Then follow the common build steps
su
<the root password>
yum groupinstall "Development Tools"
yum install cmake boost-devel gtkmm24-devel gerbv-devel git
exit
Then follow the common build steps
$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
$ cmake --build build -j$(nproc)
$ ctest --test-dir build --output-on-failure
$ sudo cmake --install build
You can build pcb2gcode for Windows with MSYS2 (https://www.msys2.org/). Download MSYS2 and install it somewhere, then run "MSYS MINGW64" (if you want a 64-bit x86_64 binary) or "MSYS MINGW32" (if you want a 32-bit i686 binary).
The following commands are for the x86_64 binary, if you want the i686 binary replace all the "/mingw64" with "/mingw32" and all the mingw-w64-x86_64-* packages with mingw-w64-i686-*
$ pacman -Sy
$ pacman --needed -S bash pacman pacman-mirrors msys2-runtime
Close and reopen the shell
$ pacman -Su # This may also close the shell; if so, reopen it.
$ pacman --needed -S base-devel git mingw-w64-x86_64-gcc mingw-w64-x86_64-boost mingw-w64-x86_64-gtkmm mingw-w64-x86_64-cmake
Now let's download, build and install gerbv:
$ git clone https://github.com/gerbv/gerbv.git
$ cd gerbv
$ git checkout v2.9.6 # Optional step. This version is known to work with pcb2gcode 2.5.0.
$ ./autogen.sh
$ ./configure --disable-update-desktop-database
$ make
$ make install
Finally, download and build pcb2gcode
$ cd ..
$ git clone https://github.com/pcb2gcode/pcb2gcode.git
$ cd pcb2gcode/
$ cmake -S . -B build -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXE_LINKER_FLAGS='-s'
$ cmake --build build -j$(nproc)
The dynamically linked binary is <msys2 installation folder>/home/<user>/pcb2gcode/build/pcb2gcode.exe. You can find all the DLLs in <msys2 installation folder>/mingw32/bin; copy them in the same folder of pcb2gcode. These steps can be automated with:
$ mkdir my-pcb2gcode-build
$ cp .libs/pcb2gcode.exe my-pcb2gcode-build
$ cd my-pcb2gcode-build
$ cp $(ldd pcb2gcode.exe | cut -d'>' -f2 | cut -d'(' -f1 | grep mingw64 | sort -u) .
The required DLLs are:
- libatk-1.0-0.dll
- libboost_program_options-mt.dll
- libbz2-1.dll
- libcairo-2.dll
- libcairomm-1.0-1.dll
- libexpat-1.dll
- libffi-6.dll
- libfontconfig-1.dll
- libfreetype-6.dll
- libgcc_s_dw2-1.dll (for the i686 binary)
- libgcc_s_seh-1.dll (for the x86_64 binary)
- libgdkmm-2.4-1.dll
- libgdk_pixbuf-2.0-0.dll
- libgdk-win32-2.0-0.dll
- libgerbv-1.dll
- libgio-2.0-0.dll
- libglib-2.0-0.dll
- libglibmm-2.4-1.dll
- libgmodule-2.0-0.dll
- libgobject-2.0-0.dll
- libgtk-win32-2.0-0.dll
- libharfbuzz-0.dll
- libiconv-2.dll
- libintl-8.dll
- libpango-1.0-0.dll
- libpangocairo-1.0-0.dll
- libpangoft2-1.0-0.dll
- libpangomm-1.4-1.dll
- libpangowin32-1.0-0.dll
- libpixman-1-0.dll
- libpng16-16.dll
- libsigc-2.0-0.dll
- libstdc++-6.dll
- libwinpthread-1.dll
- zlib1.dll
You can build the latest pcb2gcode version with Homebrew. If Homebrew is not installed yet, install it with the following command:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
You might need some build tools that typically are not present:
$ brew install autoconf automake libtool
Then you can download and build the git version with
$ brew install --HEAD pcb2gcode
or (if pcb2gcode is already installed)
$ brew upgrade --HEAD pcb2gcode
For further details, see INSTALL.
You can use the insolante docker image to use this tool throught a web interface. This project is under active development and need your feedback but give it a try and let us know.
You can find it in dockerhub for arm and x64 architecture. The current embedded version of pcb2gcode is 2.1.0.
This fork introduces the following changes on top of the upstream 3.0.3 release.
The original --drill option accepted a single Excellon file and produced a
single set of drill/milldrill outputs. Modern EDA tools (KiCad, Eagle, etc.)
export two separate drill files:
- PTH – Plated Through-Holes (copper-plated, connected to nets)
- NPTH – Non-Plated Through-Holes (mechanical holes, mounting holes, etc.)
The --drill option has been replaced with two dedicated options so both files
can be processed in one run:
| Old option | New option | Output files |
|---|---|---|
--drill <file> |
--drill-pth <file> |
drill_pth.ngc, milldrill_pth.ngc |
| (not available) | --drill-npth <file> |
drill_npth.ngc, milldrill_npth.ngc |
Example millproject / config.ini:
drill-pth=my_board-PTH.drl
drill-npth=my_board-NPTH.drlExample command line:
pcb2gcode --front=my_board-F_Cu.gbr \
--drill-pth=my_board-PTH.drl \
--drill-npth=my_board-NPTH.drl \
--zdrill=-1.7mm --zchange=2mm
Both options are independent — you can supply only one if the other is not
needed. When --basename is used, output filenames are automatically derived:
<basename>_drill_pth.ngc, <basename>_drill_npth.ngc, etc.
SVG previews are also generated per file: drill_pth.svg, drill_npth.svg,
milldrill_pth.svg, milldrill_npth.svg.
When no --config flag is given, pcb2gcode now also looks for a config file at:
~/pcb2gcode/config.ini
This file is loaded at the lowest priority — a local millproject file in
the working directory still overrides it. It is useful for storing machine-wide
defaults (feed rates, tool geometry, output paths) that apply to every project
without copying settings into each project folder.
The path is resolved from the $HOME environment variable at runtime, so it
works generically for any user account.
An --inverted option has been added to specify a Gerber file that is always
processed with inverted polarity (copper clearing mode), independently of the
--invert-gerbers flag.
This is useful when you want to run both a normal trace isolation pass and a
copper-clearing pass in the same config without toggling --invert-gerbers and
--isolation-width each time.
New options:
Example config.ini:
front=Gerber_TopLayer.GTL
inverted=Gerber_TopLayer.GTL # same file, processed inverted for copper clearing
isolation-width=0.5mm # normal trace isolation
isolation-width-inverted=3mm # wide clearance for inverted passThis produces both front.ngc (normal isolation) and inverted.ngc (copper
clearing) in a single run. The --inverted layer uses the same milling
parameters (feed, speed, depth) as --front/--back.
When --basename is used, the output is automatically named
<basename>_inverted.ngc.
On macOS with a recent Xcode Command Line Tools SDK the system libffi
pkg-config file may reference a non-existent SDK path. Install the Homebrew
libffi and pass its pkg-config path to cmake:
brew install libffi
PKG_CONFIG_PATH="$(brew --prefix libffi)/lib/pkgconfig:$PKG_CONFIG_PATH" \
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local