Boost logo

Boost Users :

From: Edward Diener (eldiener_at_[hidden])
Date: 2020-10-12 18:04:25


On 10/12/2020 9:25 AM, Stefano Gragnani via Boost-users wrote:
> Hi,
>
> how should i configure vs code to use Boost?
>
> I tried to compile the following example:
>
> #include<iostream>
> #include<boost/multiprecision/float128.hpp>
> #include<boost/math/special_functions/gamma.hpp>
>
> int main()
> {
> using namespace boost::multiprecision;
>
> // Operations at 128-bit precision and full numeric_limits support:
> float128 b = 2;
> // There are 113-bits of precision:
> std::cout << std::numeric_limits<float128>::digits << std::endl;
> // Or 34 decimal places:
> std::cout << std::numeric_limits<float128>::digits10 << std::endl;
> // We can use any C++ std lib function, lets print all the digits as well:
> std::cout << std::setprecision(std::numeric_limits<float128>::max_digits10)
> << log(b) << std::endl;// print log(2) =
> 0.693147180559945309417232121458176575
> // We can also use any function from Boost.Math:
> std::cout << boost::math::tgamma(b) << std::endl;
> // And since we have an extended exponent range we can generate some
> really large
> // numbers here (4.02387260077093773543702433923004111e+2564):
> std::cout << boost::math::tgamma(float128(1000)) << std::endl;
> //
> // We can declare constants using GCC or Intel's native types, and the Q
> suffix,
> // these can be declared constexpr if required:
>
> constexpr float128 pi =
> 3.1415926535897932384626433832795028841971693993751058Q;
>
> return 0;
> }
>
>
> but that's what I get:
>
> Executing task: g++-10 -g -std=c++17 '-fext-numeric-literals' main.cpp
> -L/usr/local/Cellar/gcc/10.2.0/lib/gcc/10/ -lquadmath -o main.out <
>
> main.cpp:2:10: fatal error: boost/multiprecision/float128.hpp: No such
> file or directory
>     2 | #include <boost/multiprecision/float128.hpp>
>       |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> compilation terminated.

I do not know VS code, but I can see from your g++-10 command line that
you have no -I parameter for the Boost top-level directory, off of which
your <boost/multiprecision/float128.hpp> can be found, thus your compile
error.

> The terminal process "/bin/zsh '-c', 'g++-10 -g -std=c++17
> '-fext-numeric-literals' main.cpp
> -L/usr/local/Cellar/gcc/10.2.0/lib/gcc/10/ -lquadmath -o main.out'"
> failed to launch (exit code: 1).
>
> My task.json is:
>
> {
> // See https://go.microsoft.com/fwlink/?LinkId=733558
> // for the documentation about the tasks.json format
> "version": "2.0.0",
> "tasks": [
> {
> "label": "Build with g++ 10",
> "type": "shell",
> "command": "g++-10",
> "args": [
> "-g",
> "-std=c++17",
> "'-fext-numeric-literals'",
> "main.cpp",
> "-L/usr/local/Cellar/gcc/10.2.0/lib/gcc/10/",
> "-lquadmath",
> "-o",
> "main.out"
> ],
> "group": {
> "kind": "build",
> "isDefault": true
> }
> },
> {
> "label": "Build with Intel ICC",
> "type": "shell",
> "command": "icc",
> "args": [
> "-g",
> "-std=c++17",
> "main.cpp",
> "-o",
> "main.out"
> ],
> "group": {
> "kind": "build",
> "isDefault": true
> }
> },
> {
> "label": "Run Project",
> "type": "shell",
> "command": "./main.out",
> "group": {
> "kind": "build",
> "isDefault": true
> }
> }
> ]
> }
>
> And my c_cpp_properties.json is:
>
> {
> "configurations": [
> {
> "name": "Mac",
> "includePath": [
> "${workspaceFolder}/**",
> "/usr/local/Cellar/boost/1.73.0/include/**"
> ],
> "defines": [],
> "macFrameworkPath": [],
> "compilerPath": "/usr/local/bin/g++-10",
> "cStandard": "gnu18",
> "cppStandard": "gnu++14",
> "intelliSenseMode": "gcc-x64"
> }
> ],
> "version": 4
> }


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net