Skip to content

Manual compilation Guide

rsocker_not_sucker edited this page Jun 12, 2018 · 8 revisions

Chinese version can be found here

Dependent libray list: libuv, libnet, libpcap/winpcap, libdnet

NOTE: On Ubuntu, libdnet is named libdumbnet. And you must modify some code of rosck. Simply replace dnet.h with dumbnet.h in rsock src code.

Linux and macOS

Take Ubuntu as an example:

sudo apt-get install g++ libuv1-dev libnet1-dev libpcap-dev libdumbnet-dev
git clone https://github.com/iceonsun/rsock.git rsock
cd rsock
mkdir build && cd build
cmake .. -DRSOCK_RELEASE=1 && make

To accelerate compilation, you can specify -jNumOfCpuCores. e.g make -j2

note: libuv must be libuv1-dev, not libuv-dev. The libuv1-dev is the newer version.

FreeBSD

  1. pkg install gcc cmake git libnet libuv libpcap libdnet
  2. git clone https://github.com/iceonsun/rsock.git
  3. cd rsock
  4. Edit CMakeLists.txt, After line include_directory(./src/os/include/), add following lines:
link_directories(/usr/local/lib/)
include_directories(/usr/local/include)
  1. mkdir build && cd build
  2. cmake -DRSOCK_RELEASE=1 .. && make

Windows

I suggest to use binary provided. If you want to compile yourself. If you insist on compiling your self, here are steps needed to be done:

  1. Install winpcap AND winpcap developer pack. In winpcap developer packet, we can find wpcap.lib and Packet.lib.
  2. Compile libuv or use one provided in repo. Compile it in shared mode. The default mode is static linking. You can resort to libuv REAMDE
  3. Compile libnet or use on provided in repo. You can resort to libnet page on here
  4. cd path/to/rsock
  5. mkdir build
  6. Manually compile libdnet. I didn't manage compile it. The dnet.dll in rsock is extraced from libdnet source code. Recompiled those code output the .dll.
  7. Copy libnet.lib, wpcap.lib, Packet.lib, dnet.dll and libuv.lib to build. And rename them to net.lib, uv.lib.
  8. Edit CMakeFileLists.txt to include net, uv, wpcap, packet.
  9. cd build && cmake ..
  10. Open visual studio and then generate target.
  11. copy libnet.dll and libuv.dll generated in previous steps to build directory. Don't rename dll files.
  12. And then you can execute binary now.
Clone this wiki locally