Linking dynamically to Boost's library instead of header-only

473 Views Asked by At

I am new to using Boost, and I have understood how to deal with that by dint of including headers files I am interested in.

For some reasons, I have to work with dynamic libraries. I have installed that one, but I'm not able to see the most important module for me - the module for dealing with matrices and so on. I think it should be uBlas.

***ESSENCE:*

I am trying to replace those lines**

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>

on loading .a .so libraries. The problem is, I can`t understand which one module corresponds to uBlas. I'm not sure if there is that module.

A list of available libraries (I call those "modules")

You can see there aren't any "numeric" or "ublas" modules...

I am a little bit bewildered. Which one module do I have to use to approach same capability as I had with using #include and so on?

Some clarifications:

How do I see that one? I can use headers files only or instead load library (.a or .so). And I would like to find file-analog (.a or .so), allowing to use ublas as well as I included header files.

2

There are 2 best solutions below

0
sehe On

@Rzu i would like to use libraries instead using headers. And i can't find appropriate library. And for me it`s weird that there are headers but if i generate .a and .so files, there are no right file ( ublas)

That's a false dichotomy. Even with shared libraries, you'd usually use (effectively: need) to have the corresponding headers and include them while compiling your code.

The only difference is whether the implementation (technically, the definitions) are also within the header files. If that's the case, there's no need to link in the definitions (neither statically or dynamically).

This is inevitable for template libraries:

So really if you require a non-generic interface that you can dynamically link, you need to define the subset in a library of your own, which you can then distribute and link in the form you prefer.

0
Cem Bassoy On

You do not need to create any static or dynamic library for using ublas. ublas is a header only (fully templated) library.

If you have installed Boost with a package manager (like apt), the ublas header files should be in the /usr/include/boost/numeric/ublas folder.

Just add the lines

#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>

into your source or header files. You might then e.g. instantiate a matrix class

boost::numeric::ublas::matrix<float> A(3,4);