user83076: the libbitcoin library seems to have been installed just fine. 
but the following code can't seem to include bitcoin/bitcoin.hpp
#include<bitcoin/bitcoin.hpp>
#include<iostream>
using namespace bc;
int main() {
    block_type blk = genesis_block();
    std::cout<<encode_hex(hash_block_header(blk.header))<<std::endl;
    return 0;
}

Error: 
g++ -o test test.cpp $(pkg-config --cflags --libs libbitcoin)
test.cpp: In function ‘int main()’:
test.cpp:5:5: error: ‘block_type’ was not declared in this scope
     block_type blk = genesis_block();
     ^~~~~~~~~~
test.cpp:5:5: note: suggested alternative: ‘clock_t’
     block_type blk = genesis_block();
     ^~~~~~~~~~
     clock_t
test.cpp:6:45: error: ‘blk’ was not declared in this scope
     std::cout<<encode_hex(hash_block_header(blk.header))<<std::endl;
                                             ^~~
test.cpp:6:45: note: suggested alternative: ‘brk’
     std::cout<<encode_hex(hash_block_header(blk.header))<<std::endl;
                                             ^~~
                                             brk
test.cpp:6:27: error: ‘hash_block_header’ was not declared in this scope
     std::cout<<encode_hex(hash_block_header(blk.header))<<std::endl;
                           ^~~~~~~~~~~~~~~~~
test.cpp:6:16: error: ‘encode_hex’ was not declared in this scope
     std::cout<<encode_hex(hash_block_header(blk.header))<<std::endl;
                ^~~~~~~~~~


user76498: Try adding the -std=c++11 flag. 
I had the same problem and the following worked for me:
g++ -std=c++11 -o test test.cpp $(pkg-config --cflags --libs libbitcoin)


user25222: The book code examples has an accompanying actively maintained github repo here. However, extra care is needed for the libbitcoin library dependency as it has new breaking changes. For example, #include <bitcoin/bitcoin.cpp> has been rename to #include <bitcoin/system.hpp>. And no more bc::ec_point. It is possible to install an older compatible version of libbitcoin library, but I prefer to use the latest version and made some adjustment in addr.cpp example code.
I manually build and installed the libbitcoin library to a custom location as suggested:
mkdir -p /opt/my/libbitcoin/
$ wget https://raw.githubusercontent.com/libbitcoin/libbitcoin/version3/install.sh
$ chmod +x install.sh
$ ./install.sh --prefix=/opt/my/libbitcoin/ --build-boost --disable-shared

The way I now build addr.cpp is thus:
export PKG_CONFIG_PATH=/opt/my/libbitcoin/lib/pkgconfig/
g++ -o addr addr.cpp $(pkg-config --cflags --libs libbitcoin-system) -lgmp

And then, running the executable:
$ ./addr
Public key: 0202a406624211f2abbdc68da3df929f938c3399dd79fac1b51b0e4ad1d26a47aa
Address: 1PRTTaJesdNovgne6Ehcdu1fpEdX7913CK


83076: <p>the libbitcoin library seems to have been installed just fine. 
but the following code can't seem to include bitcoin/bitcoin.hpp</p>

<pre><code>#include&lt;bitcoin/bitcoin.hpp&gt;
#include&lt;iostream&gt;
using namespace bc;
int main() {
    block_type blk = genesis_block();
    std::cout&lt;&lt;encode_hex(hash_block_header(blk.header))&lt;&lt;std::endl;
    return 0;
}
</code></pre>

<p>Error: </p>

<pre><code>g++ -o test test.cpp $(pkg-config --cflags --libs libbitcoin)
test.cpp: In function ‘int main()’:
test.cpp:5:5: error: ‘block_type’ was not declared in this scope
     block_type blk = genesis_block();
     ^~~~~~~~~~
test.cpp:5:5: note: suggested alternative: ‘clock_t’
     block_type blk = genesis_block();
     ^~~~~~~~~~
     clock_t
test.cpp:6:45: error: ‘blk’ was not declared in this scope
     std::cout&lt;&lt;encode_hex(hash_block_header(blk.header))&lt;&lt;std::endl;
                                             ^~~
test.cpp:6:45: note: suggested alternative: ‘brk’
     std::cout&lt;&lt;encode_hex(hash_block_header(blk.header))&lt;&lt;std::endl;
                                             ^~~
                                             brk
test.cpp:6:27: error: ‘hash_block_header’ was not declared in this scope
     std::cout&lt;&lt;encode_hex(hash_block_header(blk.header))&lt;&lt;std::endl;
                           ^~~~~~~~~~~~~~~~~
test.cpp:6:16: error: ‘encode_hex’ was not declared in this scope
     std::cout&lt;&lt;encode_hex(hash_block_header(blk.header))&lt;&lt;std::endl;
                ^~~~~~~~~~
</code></pre>
 76498: <p>Try adding the -std=c++11 flag. </p>

<p>I had the same problem and the following worked for me:</p>

<pre><code>g++ -std=c++11 -o test test.cpp $(pkg-config --cflags --libs libbitcoin)
</code></pre>
 25222: <p>The book code examples has an accompanying actively maintained github repo <a href="https://github.com/bitcoinbook/bitcoinbook" rel="nofollow noreferrer">here</a>. However, extra care is needed for the <code>libbitcoin</code> library dependency as it has new breaking changes. For example, <code>#include &lt;bitcoin/bitcoin.cpp&gt;</code> has been rename to <code>#include &lt;bitcoin/system.hpp&gt;</code>. And no more <code>bc::ec_point</code>. It is possible to install an older compatible version of <code>libbitcoin</code> library, but I prefer to use the latest version and made some adjustment in <code>addr.cpp</code> example code.</p>
<p>I manually build and installed the <code>libbitcoin</code> library to a custom location <a href="https://github.com/libbitcoin/libbitcoin-system" rel="nofollow noreferrer">as suggested</a>:</p>
<pre><code>mkdir -p /opt/my/libbitcoin/
$ wget https://raw.githubusercontent.com/libbitcoin/libbitcoin/version3/install.sh
$ chmod +x install.sh
$ ./install.sh --prefix=/opt/my/libbitcoin/ --build-boost --disable-shared
</code></pre>
<p>The way I now build <code>addr.cpp</code> is thus:</p>
<pre><code>export PKG_CONFIG_PATH=/opt/my/libbitcoin/lib/pkgconfig/
g++ -o addr addr.cpp $(pkg-config --cflags --libs libbitcoin-system) -lgmp
</code></pre>
<p>And then, running the executable:</p>
<pre><code>$ ./addr
Public key: 0202a406624211f2abbdc68da3df929f938c3399dd79fac1b51b0e4ad1d26a47aa
Address: 1PRTTaJesdNovgne6Ehcdu1fpEdX7913CK
</code></pre>
