Symbol boost could not be resolved - c++

I am using boost and eclipse as my IDE.
Boost is located in /home/ubuntu/cpp/boost_1_52_0/boost
In eclipse IDE I get a red squiggly line in red that says:
symbol boost could not be resolved-> using namespace boost;
In the ide and eclipse settings I have the includes have the path home/ubuntu/cpp/boost_1_52_0/
specified. Soo..how to I make boost work? What am I missing?
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <time.h>
#include <boost/tokenizer.hpp>
using namespace boost;
using namespace std;

Related

Syntax highlighting for llvm c++ api in clion

Right now I'm quite extensively using the C++-Api for LLVM IR. I'm using CLion as my IDE and im building and linking the project via a Makefile.
The includes look like the following
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
The problem now is that I don't have any syntax highlighting for the things coming from the llvm headers. How do I enable that.

Cannot resolve namespace std in Android Studio

I have a native library for an Android app. When I load the entire C++ project in Android Studio, some errors are thrown by the IDE saying:
cannot resolve namespace std and cannot find any C++ headers.
#include <fstream>
#include <iostream>
#include <map>
using namespace std;
For all of the above code, fstream, iostream, etc is being marked red and shows cannot find. Any workaround to fix the above issue?

Using declaration "not found" in mongodb c++ driver

I'm using the mongo-cxx-driver-r3.1.1 based on mongo-c-driver-1.6.2.
Using the latest examples provided on github, I managed to find how to connect the database and how to save documents.
I'm struggling to fetch results using a filter following the informations provided in the mongocxx/query.cpp example.
There's a lot of call to a make_document method but I have no class/method/template in the bsoncxx namespace with that name (same problem with make_array).
Heres's the includes, the using directives and using declarations :
#include <bsoncxx/builder/basic/document.hpp>
#include <bsoncxx/builder/basic/array.hpp>
#include <bsoncxx/builder/basic/kvp.hpp>
#include <bsoncxx/types.hpp>
#include <bsoncxx/json.hpp>
#include <bsoncxx/stdx/make_unique.hpp>
#include <bsoncxx/stdx/optional.hpp>
#include <bsoncxx/stdx/string_view.hpp>
#include <mongocxx/instance.hpp>
#include <mongocxx/pool.hpp>
#include <mongocxx/stdx.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/logger.hpp>
#include <mongocxx/uri.hpp>
#include <mongocxx/exception/exception.hpp>
#include <mongocxx/options/find.hpp>
using namespace mongocxx;
using namespace bsoncxx;
using bsoncxx::builder::basic::document;
using bsoncxx::builder::basic::kvp;
using bsoncxx::builder::basic::sub_document;
using bsoncxx::builder::basic::sub_array;
using bsoncxx::builder::basic::array;
using bsoncxx::types::value;
using mongocxx::result::insert_one;
The using declarations "not found" :
using bsoncxx::builder::basic::make_array;
using bsoncxx::builder::basic::make_document;
Am I missing something obvious ?
Are there more recent examples ?
Your code looks right, as you included all necessary header files needed for make_document and make_array.
You said in your comment, that the document.hpp doesn't contain the make_document and the array.hpp doesn't contain the make_array template.
This is right for the release mongo-cxx-driver-r3.1.1.
In the current master branch the header files exists as you can see if you follow the source links for them: document.hpp and array.hpp. The examples you use are probably for the new master branch as they are also from a current branch from git.

error when including <chrono>

I've tried to include the class to measure the time it takes for a segment of code to run. These are my includes:
#include <iostream>
#include <fstream>
#include <math.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
my error message is:
FILENAME.cpp:4: chrono: No such file or directory
What's the matter with my code?
From my comment:
Are you using a C++11 compiler? With g++, try giving it "-std=c++11".
g++ -std=c++11 myfile.cpp
With clang it's probably the same.

Conflict between OpenCV and Boost filesystem

I'm having a problem with Boost libraries, particularly filesystem when used with OpenCV. Apparently the problem is similar to the one described in Conflict between Boost, OpenCV and Eigen libraries?. In that particular case the problem was solved by preceding the "using namespace" statement with all the "#include" statements. In my case, this was done in this way from the beginning.
I'm using OpenCV 2.4.3 and Boost 1.48 (already tried with 1.52 having the same exact problem). The programming is being done in Windows 7 (64 bit) using Eclipse CPP plugin and MinGW.
When trying to build my program I get the following errors:
C:\Boost\boost_1_48_0/boost/type_traits/decay.hpp:28:66: error: 'cvflann::<anonymous enum>' is/uses anonymous type
C:\Boost\boost_1_48_0/boost/type_traits/decay.hpp:28:66: error: trying to instantiate 'template<class T> struct boost::remove_reference'
C:\Boost\boost_1_48_0/boost/type_traits/decay.hpp:38:17: error: 'cvflann::<anonymous enum>' is/uses anonymous type
C:\Boost\boost_1_48_0/boost/type_traits/decay.hpp:38:17: error: trying to instantiate 'template<class T> struct boost::remove_reference'
In my case the using namespace statements are after the include statements:
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <boost/filesystem.hpp>
#include <boost/multi_index_container.hpp>
using namespace std;
using namespace cv;
using namespace boost::filesystem;
Any idea in how to solve this problem will be greatly appreciated :D:D:D
Regards,
Luis
I suggest you remove the section:
using namespace std;
using namespace cv;
using namespace boost::filesystem;
and use the scope operator :: in code.
Here's an example of these 2 different modes.