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)
project(CNetLink)

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

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

set(CMAKE_SYSTEM_NAME Linux)

SET(CMAKE_STAGING_PREFIX /Volumes/OpenWRT/openwrt/staging_dir)
SET(STAGING_DIR /Volumes/OpenWRT/openwrt/staging_dir)
INCLUDE_DIRECTORIES(${STAGING_DIR}/target-i386_i486_uClibc-0.9.33.2/usr/include/libnl3/)
LINK_DIRECTORIES(${STAGING_DIR}/target-i386_i486_uClibc-0.9.33.2/usr/lib/)

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

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_FIND_ROOT_PATH ${STAGING_DIR})

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

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)