Cant use boost in xCode - c++

When I am trying to use the boost library in xCode, i keep getting an error.
I have linked the header and link library like the tutorials say, but i am still getting an error
> #include <iostream>
> #include <string> // std::string
> #include <sstream> // std::stringstream
> #include <initializer_list>
> #include <vector>
> #include <boost/type_index.hpp>
> using std::cout;
> using std::endl;
at the boost index, my compiler says "'boost/type_index.hpp' file not found" when I try building..
How do i fix this?

In your Xcode project build settings, you must ensure you find/choose it in the the header search paths. (eg /usr/local/boost_1_60_0/include/)

Related

I cannot load a texture from a file (SFML c++)

When I use the function .loadFromFile(), i get the following error:
undefined reference to `sf::Texture::loadFromFile(std::__cxx11::basic_string, std::allocator > const&, sf::Rect const&)'|
I have already tried different versions of SFML, and according to their website I'm using the correct one.
Here is my setup:
codeblocks-17.12mingw-setup.exe => download for codeblocks
SFML-2.4.2-windows-gcc-4.9.2-tdm-32-bit => SFML I am using
Here are my settings:
in the compiler tab
in the linker tab
The linking should be ok, as all the other SFML functions work. I have read that it could be because of SFML being compiled by a different compiler than mine? How can I check that? Is it something else that causes this problem?
here is the code :
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
using namespace sf;
int main () {
Texture texun;
texun.loadFromFile("C:\\Users\\j_hyl\\OneDrive\\Bureaublad\\Webdev\Apps\\Drive\\sprite.bmp");
return 0;
}
you have to link to sfml-graphics.lib or if your configuration is debug you have to link with sfml-graphics-d.lib and you have to copy the sfml-graphics-2.dll and sfml-graphics-d-2.dll(if debugging conf.) to the folder where your executable is

include <Eigen/Dense> succeed, include <Eigen> failed

My question is similar to this 5 years old question.
I can successfully compile it if I use the following code:
#include <Eigen/Dense>
#include <iostream>
//#include <boost/serialization/array_wrapper.hpp>
#include <boost/date_time/gregorian/gregorian.hpp>
int main(){
std::cout<<"asfserea"<<std::endl;
boost::gregorian::date d(boost::gregorian::day_clock::local_day());
std::cout << d.year() << d.month() <<d.day() << std::endl;
return 0;
}
But I got errors after I changed annotation from #include <Eigen/Dense> to #include <Eigen>, from #include <boost/date_time...> to #include <boost/serialization...>:
File you are looking for is <Eigen/Eigen>. If you want to include <Eigen>, you should add correct folder to your include path.
For array_wrapper.hpp, you need newer version of Boost. At least version 1.67.0 has this file.
When you #include <Eigen>, your compiler looks at the directories that you have told it about, for a file named Eigen. It only finds a folder named Eigen, and within that folder there are files Eigen and Dense. It does not look inside that folder.
If you change your compilers parameters to include the Eigen folder (rather than it's parent), you can #include <Eigen> and #include <Dense>. Alternatively, you can keep your include directories as they are, and prepend Eigen/ to all the Eigen includes

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.

"No such file" Include issue with Boost dynamic_bitset

I'm trying to use Boost's Dynamic_bitset class for a project, and I (believe I) have taken whichever subset of files I needed from the complete library. Now I'm doing an
#include "boost/dynamic_bitset.hpp" inside my manager.cpp file, and when compiling I get this:
In file included from manager.cpp:4:0:
boost/dynamic_bitset.hpp:15:51: fatal error: boost/dynamic_bitset/dynamic_bitset.hpp: No such file or directory
The file ierarchy inside the project folder goes like this:
proj/extras.h
proj/Makefile~
proj/manager.cpp
proj/boost
proj/boost/limits.hpp
proj/boost/dynamic_bitset.hpp
proj/boost/mpl
proj/boost/mpl/if.hpp
proj/boost/mpl/has_xxx.hpp
proj/boost/iterator.hpp
proj/boost/static_assert.hpp
proj/boost/dynamic_bitset
proj/boost/dynamic_bitset/dynamic_bitset.hpp
proj/boost/dynamic_bitset/config.hpp
proj/boost/config
proj/boost/config/select_platform_config.hpp
proj/boost/config/select_compiler_config.hpp
proj/boost/config/user.hpp
proj/boost/config/suffix.hpp
proj/boost/config/select_stdlib_config.hpp
proj/boost/dynamic_bitset_fwd.hpp
proj/boost/config.hpp
proj/boost/type_traits
proj/boost/type_traits/is_same.hpp
proj/boost/type_traits/is_pointer.hpp
proj/boost/type_traits/remove_pointer.hpp
proj/boost/type_traits/remove_const.hpp
proj/boost/type_traits/is_base_and_derived.hpp
proj/boost/type_traits/detail
proj/boost/type_traits/detail/bool_trait_def.hpp
proj/boost/type_traits/detail/yes_no_type.hpp
proj/boost/pending
proj/boost/pending/integer_log2.hpp
proj/boost/detail
proj/boost/detail/limits.hpp
proj/boost/detail/dynamic_bitset.hpp
proj/boost/detail/workaround.hpp
proj/boost/lowest_bit.hpp
proj/Makefile
proj/generator.cpp~
proj/generator.cpp
This same project compiles fine on my university's linux systems(g++ 4.2.4 there but I doubt it matters), but fails to do so (with the above error) on my Ubuntu laptop. Why isn't it finding the file since it evidently exists?
All my includes are as such:
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include "boost/dynamic_bitset.hpp"
#include <cmath>
#include <list>
#include <unistd.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <errno.h>
#include <wait.h>
#include <time.h>
#include "extras.h"
compilation is done simply with
g++ -o manager manager.c
or
g++ -Iboost -o manager manager.c
if I want to explicitely include the (local..) folder
-I .
At least if you are compiling in the same directory that contains boost.
You wrote -Iboost and #include "boost/…". So it looks in ./boost if there is a boost subdirectory.