1

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • 1
    Looks like `uBlas` is a header only libraries see: https://www.boost.org/doc/libs/1_67_0/more/getting_started/windows.html#header-only-libraries – Richard Critten May 12 '18 at 21:06
  • 1
    C++ doesn't have modules - it's not clear if you are asking about shared libraries, static libraries, header files or what. –  May 12 '18 at 21:26
  • 1
    If it is header only, it won't make any static or dynamic library. You just have to include the header in your program, and then you can use it. No need to link with any library. – R zu May 12 '18 at 21:28
  • @R zu What are you talking about? –  May 12 '18 at 21:30
  • @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) – Deily Angel May 12 '18 at 21:51
  • 2
    The problem with header-only template 'libraries', it seems to me, is that they can't be loaded dynamically — you have to run the compiler to make them usable. So, dynamically loaded libraries is problematic. You'd have to create a source file that instantiates the templates with the types that you're interested in, compile that instantiation into a shared object and then load that. So, I think you should either change your mind about dynamically loaded objects or about using Boost. Or you have to find a way to convert the templates you need into share objects that can be dynamically loaded. – Jonathan Leffler May 12 '18 at 21:58
  • @DeilyAngel: You can copy the whole ublas library or even the boost library, and paste that into a directory in the include folder of your project. If you use CMake to build your project, you can ask CMake to fetch boost from the git repository online. – R zu May 13 '18 at 00:39

2 Answers2

2

@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.

sehe
  • 374,641
  • 47
  • 450
  • 633
0

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);
Cem Bassoy
  • 29
  • 3