Skip to content

Build Asio (non-boost) On FreeBSD

Asio Fossil Mirror From Github

Build Asio (non-boost) On FreeBSD

1. Install Required tools/libs

$ doas pkg install bmake boost-libs autoconf automake

 

2. Create xjail filesystem (Suggest)

If use zfs (suppose your root zfs pool is tank):
$ doas zfs create tank/xjail
$ doas zfs set mountpoint=/xjail tank/xjail

If use ufs:

$ doas mkdir /xjail

 

3. Clone asio code from this github

$ git clone --depth=1 https://github.com/chriskohlhoff/asio asio
$ cd asio

 

4. Build asio c++ network library

$ ./autogen.sh
$ ./configure --prefix=/xjail/local --with-boost=/usr/local/include --enable-boost-coroutine
$ bmake LDFLAGS="${LDFLAGS} -L/usr/local/lib"
$ doas bmake install

Build asio without boost!

* Define ASIO_STANDALONE on the compiler option.

* Set -std=c++17 on the compiler option. Suggest set them in /etc/make.conf:

# /etc/make.conf
CPPFLAGS += -DASIO_STANDALONE
CXXFLAGS += -stdlib=libc++ -std=c++17

Define ASIO_STANDALONE in /etc/make.conf will let all the Makefiles in the system use this macro, but you still need to define it if you use clang++ command line:

method 1: clang++ -DASIO_STANDALONE

method 2: Write #define ASIO_STAND_ALONE in your c++ source code.

Build Asio Now:

$ ./autogen.sh
$ ./configure --prefix=/xjail/local --without-boost
$ bmake
$ doas bmake install
  • asio has been installed to /xjail/local/include now. Asio is header-only library.
  • Q: Why not use ports or pkg asio?
    A: It lacks some critical features.

 

 

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.