8192cu is now supplied in default kernel, but it is not working when running as an access point. So I need to recompile the driver.
1.get the kernel’s headers
You have to get the kernel’s header files, the common way is
sudo apt-get install linux-headers-...
But in RPI, the easiest way is rpi-source.
sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update
The kernel is compiled by gcc-4.8.3+, so if you have the gcc below 4.8.3, you have to install it.
first add
deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi
in /etc/apt/sources.list, and then
sudo apt-get install -t jessie gcc-4.8 g++-4.8
maybe you want to manage multi gcc versions
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
also you need curses for make menuconfig
sudo apt-get install libncurses5-dev