Archive for April, 2016

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