Boost lib appears to be missing hpp files? - c++

I'm trying to compile a C++ project that requires Boost. I downloaded the latest build from the web site and copied the appropriate files to the appropriate libs folder (I'm using MinGW). When I compile, I'm get this error:
In file included from main.cpp:4:0:
headers.h:59:29: fatal error: boost/foreach.hpp: No such file or directory
compilation terminated.
I can find a working copy of foreach.hpp but I shouldn't have to move code files manually.
Solution
I had copied boost to the wrong folder.

I got this error on Ubuntu 12.10 when trying to use boost with a C++ application without the libraries installed:
el#apollo:~/foo8/33_parse_file$ g++ -o s s.cpp
s.cpp:3:29: fatal error: boost/foreach.hpp: No such file or directory
compilation terminated.
From this code:
#include <iostream>
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
using namespace std;
int main(){
cout << "hi";
}
I'm on Ubuntu 12.10 so I installed Boost like this:
sudo apt-get install libboost-all-dev
Then on recompile, it works and now I can use boost!
#include <iostream>
#include <string>
#include <boost/foreach.hpp>
#include <boost/tokenizer.hpp>
using namespace std;
using namespace boost;
int main(int argc, char** argv)
{
string text = "token test\tstring";
char_separator<char> sep(" \t");
tokenizer<char_separator<char> > tokens(text, sep);
BOOST_FOREACH(string t, tokens)
{
cout << t << "." << endl;
}
}
Prints the three words token, test, string

You should make sure that your include path is set correctly. Assuming you downloaded Boost 1.47.0 your path should contain the location to your Boost installation up to the boost_1_47_0 directory, but leaving out the boost one, e.g.
/path/to/boost/boost_1_47_0
and not
/path/to/boost/boost_1_47_0/boost

On Fedora and Centos yum install -y boost and yum install -y boost-devel

Related

Unable to compile sample crowtest.cpp with crow

I'm trying to run a sample c++ program using crow but getting the error fatal error: asio.hpp: No such file or directory
Installed crow using the instructions in https://crowcpp.org/master/getting_started/setup/linux/#installing-from-source
Followed the instructions and created a crow_all.h file.
Copied and created a sample crowtest.cpp program from the crow website
#include "crow_all.h"
int main()
{
crow::SimpleApp app;
CROW_ROUTE(app, "/")([](){
return "Hello world";
});
app.port(18080).run();
}
Compiled the code g++ crowtest.cpp -o crowtest.o
But getting the following error
In file included from crowtest.cpp:1:
crow_all.h:931:10: fatal error: asio.hpp: No such file or directory
931 | #include <asio.hpp>
| ^~~~~~~~~~
compilation terminated.
Note: Also installed boost using apt install libboost-dev
I'm new to c++ and crow, can anyone please help.
The include isn't the Boost Asio, but the standalone asio: https://think-async.com/Asio/AsioStandalone.html
They're practically the same, so you can probably also get it working with
#include <boost/asio.hpp>
namespace asio = boost::asio;
But if you don't feel confident that you know how to fix any issues, just download the expected version.

Problems to include QT Liraries

I'm currently learning Qt and I'm having some problems to include libraries to my visual studio project. I have installed the Qt5 libraries with vcpkg and used the command vcpkg integrate install correctly.
In my project I have the following code:
#include <iostream>
#include <QApplication>
using namespace std;
int main(int argc, char* argv[]) {
cout << "hello";
}
Very simple. besides that I have the following configuration in vcpkg properties
Properties vcpkg
And i`m having the following two errors:
Cannot open source file "QApplication"
Cannot open include file qt5/QtWidgets/QApplication: no such file or directory
How can I include the librarie?

Include Boost file gets file not found error

I'm trying to get boost running so that I can use a C library as an external library for my python program. But I keep getting the file not found error when including header files.
I'm following the tutorial on Boost's website: https://www.boost.org/doc/libs/1_76_0/more/getting_started/windows.html
I've downloaded boost and extract it to my C disk. Added its directory (C:\Program Files\boost_1_76_0) to the include path in vscode using Microsoft C/C++ extension
However, when I tried to follow this example from the tutorial above:
(There were no python codes involved yet just C++)
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>
int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;
std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " " );
}
I get the error "fatal error: boost/lambda/lambda.hpp: No such file or directory
#include <boost/lambda/lambda.hpp>" even though the file exists.

How to fix "fatal error: filesystem: No such file or directory" in Code::Blocks?

I'm writing a script which deletes old backup files. I've included filesystem as I would normally do, but this time, I got this error:
fatal error: filesystem: No such file or directory
I tried to include experimental/filesystem and I set -lstdc++fs as GCC flag. Nothing has worked for me.
Example code:
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <filesystem>
namespace fs = std::filesystem;
int main()
{
fs::path const directory{ "C:\Test" };
std::vector<fs::directory_entry>::size_type const num_files_to_keep{ 5 };
...
Using CodeBlocks ang GCC 8.0 or above You need to set c++17 compiler option
(I'm using CodeBlock last Nightly build).
Then you must add to the Linker settings options the stdc++fs library.
And then you must add the #include <filesystem> directive, from GCC 8.0, and not <experimental/filesystem>
On windows the directory separator is \\ (two backslash).
You need to write:
fs::path const directory { "C:\\Test" };

cpp_bin_float not found between boost library

I'm using boost library to handle big numbers.
#include <iostream>
#include <boost/multiprecision/cpp_bin_float.hpp>
#include <boost/multiprecision/number.hpp>
namespace mp=boost::multiprecision;
using namespace std;
int main()
{
typedef mp::number<mp::backends::cpp_bin_float<2000> > cpp_bin_float227;
cpp_bin_float227 b = 998;
std::cout << std::numeric_limits<cpp_bin_float227>::digits << std::endl;
cout<<std::setprecision(std::numeric_limits<cpp_bin_float227>::max_digits10)<<pow(b,9999)<<endl;
}
But I got this error at compile-time:
fatal error: boost/multiprecision/cpp_bin_float.hpp: No such file or directory
#include <boost/multiprecision/cpp_bin_float.hpp>
If I use cpp_dec_float instead of cpp_bin_float it works fine.
Why is the library not found and how to fix it?
(I'm using c++11 compiler, in Ubuntu)
SOLUTION:
The problem was that in answe, namely aold version of boost library.
Minimal version to support cpp_bin_float is 1.58
Remove current version with:
apt-get --purge remove libboost-dev libboost-doc
Later I installed version 1.63 (isn't the latest that is 1.64) following
http://www.linuxfromscratch.org/blfs/view/cvs/general/boost.html
That version of boost doesn't have cpp_bin_float. It's also seriously old.
See it live:
boost 1.54 https://wandbox.org/permlink/7MQy5HR90GB0GbVt
boost 1.55 https://wandbox.org/permlink/nPOH5kDRCq1PUXWl
boost 1.56 https://wandbox.org/permlink/IhClSKBx0k0pSVUe OK!