Xcode C++ Standard Libraries not found - c++

I've created an Allegro 5 project in Xcode 4.6.3 as an empty project. I've added all the Allegro 5 libraries as described in the Allegro documentation. But now I need to use some C/C++ libraries and get the error, that Xcode doesn't find the libraries (e.g. 'fstream file not found').
#include <allegro5/allegro5.h>
#include <allegro5/allegro_native_dialog.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_image.h>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
How can I add the standard libraries to Xcode projects so that it finds them? Unfortunatelly I can't find any solution. This is not an Objective-C Project. It's written in C++ and also works if I don't use any of these libraries.
Thanks!

Does the name of your source file end with an extension that indicates it's C++? If it ends in (for instance) .c or .m, the compiler will not consider it to be C++, therefore the C++ headers won't be found. Try changing the extension on the source file name to .cpp (or some other extension that implies C++, see C++ code file extension? .cc vs .cpp ) and see if the header is found.

Related

xcode C++ : Lexical or Preprocessor issue 'memory' file not found

I'm including a library in a C++ program, which includes memory and other libraries from the std c++ implementation, like so:
#include <memory>
There is an error happening:
Lexical or Preprocessor issue 'memory' file not found
This happens the same with all the includes in this file:
#include <cmath>
#include <vector>
I'm wondering what could cause such an issue? Could it be that the compiler is not set somewhere properly in the build settings? If so, any idea where?

namespace boost has no member

I downloaded the latest version of Boost libraries 1_60_0 and I tried to use it but I quickly ran into troubles.
boost::unordered_map<int, int> map;
This piece of code says "namespace boost has no member unordered_map". I checkd the file, it is there though. The same happened for basically everything I tried to acces from the boost namespace.
Header includes are as follows:
#include <D:/IP/boost_1_60_0/boost/graph/adjacency_list.hpp>
#include <D:/IP/boost_1_60_0/boost/graph/graph_traits.hpp>
#include <D:/IP/boost_1_60_0/boost/graph/connected_components.hpp>
#include <D:/IP/boost_1_60_0/boost/unordered_map.hpp>
#include <D:/IP/boost_1_60_0/boost/graph/floyd_warshall_shortest.hpp>
#include <D:/IP/boost_1_60_0/boost/numeric/ublas/matrix.hpp>
#include <D:/IP/boost_1_60_0/boost/numeric/ublas/io.hpp>
I'm guessing I should include something more, but no clue what. Any tips?
unordered_map.hpp includes other boost header files this way:
#include <boost/config.hpp>
Which means that the boost folder has to be set as an additional include directory for this to work.
I'm assuming you're compiling on MSVC, if so, right click your project : properties -> C/C++ -> General and add the folder D:/IP/boost_1_60_0/ as Additional Include Directory.
The docs also answers this question for you.

How to use CImg in Objective C / XCode?

I know that clang can compile C++ files as .mm, but CImg comes as just an individual .h file. Regardless if I change the extension to .mm or keep it as .h, it doesn't work.
First, it complains that it can't find cstdio.h. As a result, I changed all the cstd.. imports to their c counterpart as a
// Include standard C++ headers.
// This is the minimal set of required headers to make CImg-based codes compile.
#include <stdio.h> // (was #import <cstdio>)
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <exception.h>
After bringing in the x11 library, I get past the import errors into syntax errors:
namespace cimg_library_suffixed {
Error: Unknown type name 'namespace'
Is this because I changed cstdio to stdio? I'm confused..
The solution in answer form for future reference:
Compile the file the header is #included from as Obj-C++ and the header will get treated as C++ code.

iOS: building a static library from c++ code fails

I have been trying to create an static library out of C++ code by following this tutorial. If I trying to build the project some error occurs.
#include <limits> "limits" file not found
for example.
I have been trying different build settings, e.g. C++ Standard Library with no luck.
Rename the implementation files from .cpp to .mm did not work also. Is there an workaround to solve this issues?
Try using #include <limits.h> instead of #include <limits>

C++ 3rd party library includes non existing header file?

First things first: I'm a newbie in C/C++.
I have a library that I have to include but it has header files that use
#include <string>
I tried to include <string> but it failed. I can
#include <string.h>
though. Since it's a library I'm trying to use I can't do much about this import right ? How can I fix this problem ? Build terminates with a fatal error.
(In case that's important I'm working on Linux and genicam is the 3rd party library)
<string> is a standard C++ header. Either your compiler is broken, or installed incorrectly, or you are trying to use a C compiler on C++ code (for instance by using gcc instead of g++).