OpenWRT Mac OSX SDK & Toolchain

OpenWRT (trunk version for x86) and Carambola2 (v2.8) SDK and Toolchain development binaries can be found at for Mac OSX (El Capitan). Binaries contain main developments packages  as preinstalled (gcc & gdb) and others packed under packages subdir.

My OpenWRT Development Environment on OSX with Vagrant

You can find how to build OpenWRT on Mac OSX from my previous posts, here I’ll share my development environment for wireless devices.

IDE:  After XCode, Clion is the best IDE for C/C++ development on OS X.  Only disadvantage is, it doesn’t support remote debugging.

Toolchain: Cross compiled toolchain for openWRT

Vagrant: There are boxes for openwrt I use qqshfox/openwrt-barrier_breaker and I added a shutdown script to get it working correctly. Auto sync doesn’t work instead installed both Mac and OpenWRT rsync to handle configuration.

I use Clion for development, and vagran rsync-auto sync’s binaries with vagrant box. Also, I  use USB Wifi adapter on vagrant box ( TP-Link WN727N works perfect).

My CMakeList.txt files is as follows;

cmake_minimum_required(VERSION 3.5)

#set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++11”)

set(SOURCE_FILES main.c CNetLib.c CNetLib.h)
add_executable(CNetLink ${SOURCE_FILES})


SET(CMAKE_STAGING_PREFIX /Volumes/OpenWRT/openwrt/staging_dir)
SET(STAGING_DIR /Volumes/OpenWRT/openwrt/staging_dir)

set(TOOLCHAIN_DIR ${STAGING_DIR}/toolchain-i386_i486_gcc-4.8-linaro_uClibc-

SET(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/i486-openwrt-linux-uclibc-gcc)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/i486-openwrt-linux-uclibc-g++)
SET(CMAKE_STRIP ${TOOLCHAIN_DIR}/bin/i486-openwrt-linux-uclibc-strip)

set(CMAKE_C_FLAGS “${CMAKE_C_FLAGS} -Wall -Werror -L ${STAGING_DIR}/target-i386_i486_uClibc- -lnl-genl-3 -lnl-3”)


OpenWRT 15.05 Chaos Calmer on Mac OS X El Capitan 10.11

When I try to build new OpenWRT release 15.05 Chaos Calmer on OSX 10.11 mkimage build fails with following error:
Undefined symbols for architecture x86_64:
“_ERR_remove_thread_state”, referenced from:
_rsa_sign in rsa-sign.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[5]: *** [tools/dumpimage] Error 1
make[4]: *** [tools-only] Error 2
make[3]: *** [/Volumes/OpenWRT/openwrt/build_dir/host/u-boot-2014.10/.built] Error 2
make[3]: Leaving directory `/Volumes/OpenWRT/openwrt/tools/mkimage’
make[2]: *** [tools/mkimage/compile] Error 2
make[2]: Leaving directory `/Volumes/OpenWRT/openwrt’
make[1]: *** [/Volumes/OpenWRT/openwrt/staging_dir/target-mips_34kc_uClibc-] Error 2
make[1]: Leaving directory `/Volumes/OpenWRT/openwrt’
make: *** [world] Error 2

So, I replaced openssl with the one comes with homebrew build. Replaced Host/Compile section in tools/mkimage/Makefile, solves the issue.

define Host/Compile

$(MAKE) -C $(HOST_BUILD_DIR) defconfig

HOSTCFLAGS=”$(HOST_CFLAGS) -I/usr/local/Cellar/openssl/1.0.2d_1/include” \
HOSTLDFLAGS=”$(HOST_STATIC_LINKING) $(HOST_LDFLAGS) -L/usr/local/Cellar/openssl/1.0.2d_1/lib” \
$(MAKE) -C $(HOST_BUILD_DIR) tools-only

Building OpenWRT with Homebrew on Yosemite Mac OS X 10.10

Recently homebrew is more popular than macports and has support  most of the packages you may need on Mac OS X. To get OpenWRT complied on OS X prepare a disk image with  Disk Utiliy->New Image-> Case sensitive, sparse disk Image. Second, install XCode from App Store, and Command Line Tools:

xcode-select –install

Install Homebrew:

ruby -e "$(curl -fsSL"

Install required packages by brew install …

gcc47 coreutils asciidoc bzip2 fastjar flex gnu-getopt gtk2 intltool zlib openssl rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget ncurses e2fsprogs ossp-uuid gawk findutils gnu-tar

You may need to move existing getopt and tar and make symbolic link new gnu-getopt and gnu-tar. Switch to the new disk image and follow:

git clone git://
cd openwrt
make menuconfig
make -j 8


Building OpenWRT on Mac OS X 10.10 Yosemite

After upgrading to Yosemite, I have to rebuild OpenWRT for new os. Here is the complete steps to build OpenWRT on Mac OS X 10.10 Yosemite. I tested it both Carambola 2 native and OpenWRT x86 architectures.

First, you need a disk image on your mac. Go to Disk Utiliy->New Image-> Case sensitive, sparse disk Image. I allocate 15GB to work on 2 different builds.

Second, install XCode from App Store, and Command Line Tools:

xcode-select --install

Then, install macports (clean install is needed) and update:

sudo port selfupdate

Install required ports:

sudo port install gcc47 coreutils asciidoc bzip2 fastjar flex getopt gtk2 intltool jikes zlib openssl p5-extutils-makemaker rsync ruby sdcc unzip gettext libxslt bison gawk autoconf wget gmake ncurses e2fsprogs ossp-uuid gawk findutils gnutar

Everything is ready to get the source code and build. Mount the disk we setup in the first step and cd into and get OpenWRT.

git clone git://

clang can build everything from scratch.

gcc -v

Configured with: –prefix=/Applications/ –with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix

export PATH=/opt/local/libexec/gnubin:/opt/local/bin:${PATH}

Setup your firmware options:

make menuconfig

and build:

make -j 8

make[1] world
make[2] tools/install
make[2] package/cleanup
make[3] -C tools/sed compile
make[3] -C tools/patch compile
make[3] -C tools/sstrip compile
make[3] -C tools/xz compile
make[3] -C tools/patch-image compile
make[3] -C tools/firmware-utils compile
make[3] -C tools/flock compile
make[3] -C tools/flock install
make[3] -C tools/patch-image install
make[3] -C tools/sstrip install
make[3] -C tools/firmware-utils install
make[3] -C tools/xz install
make[3] -C tools/sed install
make[3] -C tools/patch install
make[3] -C tools/ipkg-utils compile
make[3] -C tools/pkg-config compile
make[3] -C tools/m4 compile
make[3] -C tools/genext2fs compile
make[3] -C tools/mkimage compile
make[3] -C tools/yaffs2 compile
make[3] -C tools/cmake compile
make[3] -C tools/scons compile
make[3] -C tools/lzma compile
make[3] -C tools/squashfs4 compile
make[3] -C tools/ipkg-utils install
make[3] -C tools/yaffs2 install
make[3] -C tools/scons install
make[3] -C tools/squashfs4 install
make[3] -C tools/genext2fs install
make[3] -C tools/lzma install
make[3] -C tools/m4 install
make[3] -C tools/libtool compile
make[3] -C tools/mkimage install
make[3] -C tools/libtool install
make[3] -C tools/autoconf compile
make[3] -C tools/pkg-config install
make[3] -C tools/autoconf install
make[3] -C tools/automake compile
make[3] -C tools/automake install
make[3] -C tools/gmp compile
make[3] -C tools/e2fsprogs compile
make[3] -C tools/mklibs compile
make[3] -C tools/flex compile
make[3] -C tools/libelf compile
make[3] -C tools/mm-macros compile
make[3] -C tools/xorg-macros compile
make[3] -C tools/xfce-macros compile
make[3] -C tools/missing-macros compile
make[3] -C tools/mm-macros install
make[3] -C tools/xorg-macros install
make[3] -C tools/missing-macros install
make[3] -C tools/xfce-macros install
make[3] -C tools/libelf install
make[3] -C tools/mklibs install
make[3] -C tools/flex install
make[3] -C tools/bison compile
make[3] -C tools/e2fsprogs install
make[3] -C tools/qemu compile
make[3] -C tools/mtd-utils compile
make[3] -C tools/mtd-utils install
make[3] -C tools/qemu install
make[3] -C tools/gmp install
make[3] -C tools/mpfr compile
make[3] -C tools/bison install
make[3] -C tools/findutils compile
make[3] -C tools/bc compile
make[3] -C tools/bc install
make[3] -C tools/cmake install
make[3] -C tools/mpfr install
make[3] -C tools/mpc compile
make[3] -C tools/mpc install
make[3] -C tools/findutils install
make[3] -C tools/padjffs2 compile
make[3] -C tools/quilt compile
make[3] -C tools/padjffs2 install
make[3] -C tools/quilt install
make[2] toolchain/install
make[3] -C toolchain/gdb prepare
make[3] -C toolchain/gcc/minimal prepare
make[3] -C toolchain/kernel-headers prepare
make[3] -C toolchain/uClibc/headers prepare
make[3] -C toolchain/binutils prepare
make[3] -C toolchain/binutils compile
make[3] -C toolchain/uClibc/utils prepare
make[3] -C toolchain/uClibc prepare
make[3] -C toolchain/binutils install
make[3] -C toolchain/gdb compile
make[3] -C toolchain/gdb install
make[3] -C toolchain/kernel-headers compile
make[3] -C toolchain/gcc/initial prepare
make[3] -C toolchain/gcc/minimal compile
make[3] -C toolchain/gcc/final prepare
make[3] -C toolchain/gcc/minimal install
make[3] -C toolchain/kernel-headers install
make[3] -C toolchain/uClibc/headers compile
make[3] -C toolchain/uClibc/headers install
make[3] -C toolchain/gcc/initial compile
make[3] -C toolchain/gcc/initial install
make[3] -C toolchain/uClibc compile
make[3] -C toolchain/uClibc install
make[3] -C toolchain/gcc/final compile
make[3] -C toolchain/gcc/final install
make[3] -C toolchain/uClibc/utils compile
make[3] -C toolchain/uClibc/utils install
make[2] target/compile
make[3] -C target/linux compile
make[2] package/compile
make[3] -C package/boot/grub2 host-compile
make[3] -C package/libs/toolchain compile
make[3] -C package/system/opkg host-compile
make[3] -C package/libs/libjson-c compile
make[3] -C package/libs/libnl-tiny compile
make[3] -C package/libs/zlib compile
make[3] -C package/libs/ncurses compile
make[3] -C package/utils/lua compile
make[3] -C package/libs/lzo compile
make[3] -C package/libs/libreadline compile
make[3] -C package/firmware/linux-firmware compile
make[3] -C package/libs/gettext compile
make[3] -C package/libs/libiconv compile
make[3] -C package/libs/libtool compile
make[3] -C package/libs/libpcap compile
make[3] -C package/libs/ocf-crypto-headers compile
make[3] -C package/libs/polarssl compile
make[3] -C package/libs/gmp compile
make[3] -C package/network/services/dropbear compile
make[3] -C package/network/utils/linux-atm compile
make[3] -C package/network/utils/resolveip compile
make[3] -C package/network/utils/curl compile
make[3] -C package/network/utils/wireless-tools compile
make[3] -C package/utils/busybox compile
make[3] -C package/utils/mkelfimage compile
make[3] -C package/libs/ncurses compile
make[3] -C package/libs/libubox compile
make[3] -C package/utils/util-linux compile
make[3] -C package/devel/gdb compile
make[3] -C package/kernel/linux compile
make[3] -C package/libs/cyassl compile
make[3] -C package/libs/openssl compile
make[3] -C package/network/utils/iptables compile
make[3] -C package/network/ipv6/odhcp6c compile
make[3] -C package/network/services/ppp compile
make[3] -C package/network/utils/tcpdump compile
make[3] -C package/system/mtd compile
make[3] -C package/system/ubus compile
make[3] -C package/system/uci compile
make[3] -C package/utils/jsonfilter compile
make[3] -C package/network/config/netifd compile
make[3] -C package/system/ubox compile
make[3] -C package/network/config/firewall compile
make[3] -C package/network/services/hostapd compile
make[3] -C package/network/services/odhcpd compile
make[3] -C package/system/fstools compile
make[3] -C package/libs/nettle compile
make[3] -C package/network/utils/tcpdump compile
make[3] -C package/utils/ubi-utils compile
make[3] -C package/system/procd compile
make[3] -C package/base-files compile
make[3] -C package/network/services/hostapd compile
make[3] -C package/system/opkg compile
make[3] -C package/boot/grub2 compile
make[3] -C package/network/services/dnsmasq compile
make[2] package/install
make[3] package/preconfig
make[2] target/install
make[3] -C target/toolchain install
make[3] -C target/linux install
make[3] -C target/sdk install
make[2] package/index