-
Notifications
You must be signed in to change notification settings - Fork 151
Installation
Boost.uBlas is a header only library. You only need to include the right headers and take care of the dependencies.
Make sure you have a C++ compiler that supports C++17 (master) and C++20 (develop)
g++ --version
# g++ (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
or
clang++ --version
# Ubuntu clang version 11.0.0-2~ubuntu20.04.1
For Mac user, the only toolset is clang. Installing gcc with Homebrew is not recommended.
pple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
uBlas can be compiled without the boost
super project
Clone the uBlas project
git clone [email protected]:boostorg/ublas.git
cd ublas
Switch to the master branch
git checkout master # develop or any other feature branch
Make sure you have installed boost library
Try out an example(the following examples are available under develop branch):
cd examples/tensor
g++ -std=c++20 simple_expressions.cpp -I../../include -o simple_expressions
g++ -std=c++20 instantiate_tensor.cpp -I../../include -o instantiate_tensor
Clone the Boost super-project
git clone --recursive --jobs 8 https://github.com/boostorg/boost.git
Switch the Boost super-project to desired branch, master
or develop
cd boost
git checkout master
TIP: Modular Boost Library Maintenance
guide, for more realistic test environment, recommends to develop and test
individual Boost library against other Boost libraries as defined by
the Boost super-project master
branch:
cd boost
git checkout master
git pull
git submodule update --init --recursive --jobs 8
Build the b2
driver program for Boost.Build engine.
./bootstrap.sh
./b2 --version
TIP: For more convenient path-less invocation, you can copy the b2
program to a location in your PATH
.
Optionally, create full content of /boost
virtual directory with
all Boost headers linked from the individual modular Boost libraries.
If you skip this step, executing b2
to run tests will automatically
create the directory with all headers required by Boost.uBLAS and tests.
./b2 -j8 headers
Regardless if you decide to develop again master
(recommended) or develop
branch of the Boost super-project, you should always base your contributions (i.e. topic branches) on Boost.uBLAS develop
branch. Go to the Boost.uBLAS library submodule.
cd libs/numeric/ublas
Checkout the develop
branch and bring it up to date
git checkout develop
git branch -vv
git pull origin develop
The b2 invocation explains available options like toolset
, variant
and others. Execute b2
to run all tests built using default variant=debug
and default toolset
determined for your development environment. We also use the latest cxxstd=20
for Boost.uBLAS.
b2
is similar to cmake
or qmake
which is used to build ublas. Refer Documentation for more information.
Build examples of Boost.uBLAS assuming that you are in the boost
folder.
cd libs/numeric/ublas
../../../b2 -j8 release toolset=clang cxxstd=20 examples/tensor
Build tests of Boost.uBLAS assuming that you are in the boost
folder.
cd libs/numeric/ublas
../../../b2 -j8 release toolset=clang cxxstd=20 test/tensor
For macbook user, just in the there are errors during the build.
cd libs/numeric/ublas
echo "using clang : : clang++ : <cxxflags>"-std=c++20" <linkflags>"-lboost_unit_test_framework" ;" >> ~/user-config.jam
../../../b2 -j8 test/tensor
TIP: If something goes wrong, you end up with incomplete or accidentally modified files in your clone of the super-project repository, or you simply wish to start fresh, then you can clean and reset the whole repository and its modules:
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive --jobs 8
For running the tests and compiling ublas on your local machine, refer this according to the operating system you have.