so how should I complie your example? and for the following code:
> #include <iomanip> > #include <iostream> > #include <boost/multiprecision/cpp_int.hpp> > #include <boost/multiprecision/cpp_bin_float.hpp> > #include <boost/multiprecision/float128.hpp> > #include <boost/math/special_functions/gamma.hpp> > #include <boost/multiprecision/cpp_dec_float.hpp> > #include <boost/math/constants/constants.hpp> > > int main() > { > using boost::multiprecision::float128; > > float128 b = 2; > std::cout << std::numeric_limits<float128>::digits << std::endl; > std::cout << std::numeric_limits<float128>::digits10 << std::endl; > std::cout << > std::setprecision(std::numeric_limits<float128>::max_digits10) << log(b) << > std::endl; > constexpr float128 pi = > 3.1415926535897932384626433832795028841971693993751058Q; > return 0; > } > > I get: > > > Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ > > -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ > > -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ > > -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ > > -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem > > '-fext-numeric-literals' fs_main.cpp -o main < > > Undefined symbols for architecture x86_64: > "__Z17quadmath_snprintfPcmPKcz", referenced from: > > __ZNK5boost14multiprecision8backends16float128_backend3strB5cxx11ElSt13_Ios_Fmtflags > in ccGxvsSR.o > "__Z4logqg", referenced from: > > __ZN5boost14multiprecision8backends8eval_logERNS1_16float128_backendERKS2_ in > ccGxvsSR.o > ld: symbol(s) not found for architecture x86_64 > collect2: error: ld returned 1 exit status > The terminal process "zsh '-c', 'g++-11 -g > -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ > -L/usr/local/Cellar/boost/1.76.0/lib/ > -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ > -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ > -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem > '-fext-numeric-literals' fs_main.cpp -o main'" terminated with exit code: 1. Thanks Stefano Gragnani > Il giorno 21 lug 2021, alle ore 17:56, Stefano Gragnani > <stefano.gragn...@gmail.com> ha scritto: > > ok things are better but i still get errors: > > > Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ > > -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ > > -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ > > -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ > > -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem > > '-fext-numeric-literals' float128_example.cpp -o main < > > float128_example.cpp: In function 'int main()': > float128_example.cpp:186:20: error: call of overloaded 'exp(__float128)' is > ambiguous > 186 | float128 e1 = exp(1.Q); // Note argument to exp is type float128. > | ~~~^~~~~ > In file included from > /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:45, > from > /usr/local/Cellar/boost/1.76.0/include/boost/config/no_tr1/cmath.hpp:21, > from > /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/config.hpp:19, > from > /usr/local/Cellar/boost/1.76.0/include/boost/math/cstdfloat/cstdfloat_types.hpp:18, > from > /usr/local/Cellar/boost/1.76.0/include/boost/cstdfloat.hpp:18, > from float128_example.cpp:19: > /usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/gcc/x86_64-apple-darwin20/11.1.0/include-fixed/math.h:376:15: > note: candidate: 'double exp(double)' > 376 | extern double exp(double); > | ^~~ > In file included from > /usr/local/Cellar/boost/1.76.0/include/boost/config/no_tr1/cmath.hpp:21, > from > /usr/local/Cellar/boost/1.76.0/include/boost/math/tools/config.hpp:19, > from > /usr/local/Cellar/boost/1.76.0/include/boost/math/cstdfloat/cstdfloat_types.hpp:18, > from > /usr/local/Cellar/boost/1.76.0/include/boost/cstdfloat.hpp:18, > from float128_example.cpp:19: > /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:226:3: note: > candidate: 'constexpr long double std::exp(long double)' > 226 | exp(long double __x) > | ^~~ > /usr/local/Cellar/gcc/11.1.0_1/include/c++/11.1.0/cmath:222:3: note: > candidate: 'constexpr float std::exp(float)' > 222 | exp(float __x) > | ^~~ > The terminal process "zsh '-c', 'g++-11 -g > -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ > -L/usr/local/Cellar/boost/1.76.0/lib/ > -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ > -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ > -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem > '-fext-numeric-literals' float128_example.cpp -o main'" terminated with exit > code: 1. > > Compiling the following example: > > #include <iomanip> > #include <iostream> > #include <boost/multiprecision/cpp_int.hpp> > #include <boost/multiprecision/cpp_bin_float.hpp> > #include <boost/multiprecision/float128.hpp> > #include <boost/math/special_functions/gamma.hpp> > #include <boost/multiprecision/cpp_dec_float.hpp> > #include <boost/math/constants/constants.hpp> > > int main() > { > using boost::multiprecision::float128; > > float128 b = 2; > std::cout << std::numeric_limits<float128>::digits << std::endl; > std::cout << std::numeric_limits<float128>::digits10 << std::endl; > std::cout << > std::setprecision(std::numeric_limits<float128>::max_digits10) << log(b) << > std::endl; > constexpr float128 pi = > 3.1415926535897932384626433832795028841971693993751058Q; > return 0; > } > > I get: > > > Executing task: g++-11 -g -I/usr/local/Cellar/boost/1.76.0/include/ > > -I/usr/local/include/ -L/usr/local/Cellar/boost/1.76.0/lib/ > > -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ > > -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ > > -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem > > '-fext-numeric-literals' fs_main.cpp -o main < > > Undefined symbols for architecture x86_64: > "__Z17quadmath_snprintfPcmPKcz", referenced from: > > __ZNK5boost14multiprecision8backends16float128_backend3strB5cxx11ElSt13_Ios_Fmtflags > in ccGxvsSR.o > "__Z4logqg", referenced from: > > __ZN5boost14multiprecision8backends8eval_logERNS1_16float128_backendERKS2_ in > ccGxvsSR.o > ld: symbol(s) not found for architecture x86_64 > collect2: error: ld returned 1 exit status > The terminal process "zsh '-c', 'g++-11 -g > -I/usr/local/Cellar/boost/1.76.0/include/ -I/usr/local/include/ > -L/usr/local/Cellar/boost/1.76.0/lib/ > -L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/ > -L/usr/local/Cellar/gmp/6.2.1/lib/ -L/usr/local/Cellar/mpfr/4.1.0/lib/ > -std=gnu++20 -lmpfr -lgmp -lquadmath -lboost_system -lboost_filesystem > '-fext-numeric-literals' fs_main.cpp -o main'" terminated with exit code: 1. > > Note that if I compile the following example without using Boost I have no > linking errors with quadmath: > > #include <quadmath.h> > #include <iostream> > #include <stdlib.h> > #include <stdio.h> > > int print(const char *label, __float128 r) { > int prec = 20; > int width = 46; > char buf[128]; > > int n = quadmath_snprintf(buf, sizeof buf, "%+-#*.36Qe", width, r); > printf ("%s: %s\n", label, buf); > return 0; > } > > int main () { > __float128 x = 3.14159265358979323846264338327950288q; > print("value", x); > print("log", logq(x)); > print("log10", log10q(x)); > print("cos", cosq(x)); > print("sin", sinq(x)); > print("sqrt", sqrtq(x)); > } > > Executing task: ./es1.out < > > value: +3.141592653589793238462643383279502797e+00 > log: +1.144729885849400174143427351353058656e+00 > log10: +4.971498726941338543512682882908988723e-01 > cos: -1.000000000000000000000000000000000000e+00 > sin: +8.671810130123781024797044026043352254e-35 > sqrt: +1.772453850905516027298167483341145140e+00 > > The settings are: > > "tasks": [ > { > "label": "Build with g++ 11", > "type": "shell", > "command": "g++-11", > "args": [ > "-g", > "-std=gnu++20”, > "es1.cpp", > "-L/usr/local/Cellar/gcc/11.1.0_1/lib/gcc/11/", > "-lquadmath", > "-o", > "es1.out" > ], > "group": { > "kind": "build", > "isDefault": true > }, > "problemMatcher": [] > }, > >> Il giorno 21 lug 2021, alle ore 13:08, John Maddock via Boost-users >> <boost-users@lists.boost.org <mailto:boost-users@lists.boost.org>> ha >> scritto: >> >> On 20/07/2021 18:44, Stefano Gragnani via Boost-users wrote: >>> >>> Hi, >>> >>> I'm having trouble compiling code that contains float128 data type. >>> I'm using MacOS Big Sur 11.4. >>> Compiler: gcc version 11.1.0 (Homebrew GCC 11.1.0_1) >>> >>> I have no other problems with Boost, the only problem is when I use >>> float128. >>> >>> Please note that I have no problem compiling using libquadmath without >>> using Boost using the __float128 data type. >>> >>> I use Visual Studio Code: >>> >> You can manually fix this by defining BOOST_HAS_FLOAT128 on the command >> line. However, you may still hit other errors as __float128 and quadmath.h >> aren't really fully supported in ISO C++ mode. The correct fix is to use >> -std=gnu++20, and then GNU extensions including __float128 are turned on. >> >> HTH, John. >> >> >> -- >> This email has been checked for viruses by Avast antivirus software. >> https://www.avast.com/antivirus <https://www.avast.com/antivirus> >> >> _______________________________________________ >> Boost-users mailing list >> Boost-users@lists.boost.org >> https://lists.boost.org/mailman/listinfo.cgi/boost-users >
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users