orlow65
orlow65

Reputation: 23

Linking boost::asio using terminal

I am trying to link boost::asio using terminal (I'm also using a text editor).

What I tried

I did some researches on Internet (I didn't found nothing about my distro) - I found I must install that library by executing the following command on the terminal:

sudo pacman -S libboost-all-dev

This is the output I get:

error: the following package was not found: libboost-all-dev

Final question

How can I install and link correctly boost::asio with my .cpp file?

Notes:

Upvotes: 2

Views: 1486

Answers (2)

Poriferous
Poriferous

Reputation: 1582

To find a package in Arch Linux, do:

sudo pacman -Ss boost

This will list packages with the string boost. Or, you can look up on the package website: https://www.archlinux.org/packages/extra/x86_64/boost/

One thing you should understand about boost is that a majority of its modules are header-only; if the linker complains about undefined references then you would have to link the required files. To link boost-asio, you would do

g++ -lboost-system <source> <exe>

Upvotes: 1

brainstream
brainstream

Reputation: 461

How to install boost in Arch Linux

You cannot link libraries inside your *.cpp files. You should enumerate required libraries using the -l option in the g++ command line.

g++ -lboos-asio -lboost-system myfile.cpp -o myapp

Upvotes: 1

Related Questions