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

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>

Related

Mongoose - error when including standard C++ library files

I'm using mongoose to build an HTTP server in C++, and I'm getting an error message when I try to include other files in my program:
/Library/Developer/CommandLineTools/usr/include/c++/v1/cstdint:183:8: error:
expected unqualified-id
using::intptr_t;
^
/Users/cs/Downloads/mongoose-master/mongoose.c:2415:18: note:
expanded from
macro 'intptr_t'
#define intptr_t long
^
This happens whenever I attempt include the following files in my program:
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <iterator>
#include <sstream>
I've tried to narrow it down to one of these files causing the problem by commenting out some of them, but it appears that any one of them causes the error. Interestingly enough, string.h does not cause the error.
It sounds like your source code contains something like this:
#include <mongoose.c>
The .c file defines a macro that collides with words used in the standard library headers.
Including a .c file is not a good practice. Instead, you should build the mongoose library, and link your program against it.
If you really have to keep everything in a single translation unit, you should be able to move that dubious include statement to after all other headers, or even to the bottom of your cpp file.
But it would be best to figure out how to build mongoose.c separately, then link against the resulting library. You can ask a separate question, or see if you get anything out of this: Can't figure out how to build C application after adding Mongoose Embedded

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?

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++).

Xcode C++ Standard Libraries not found

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.

Xcode Error - No such file or directory

I'm trying to build a project of mine that includes fuzzylite C++ libraries within a Carbon C++ application. However the compiler throws out an error for each fuzzylite's library I include in my source code. I've tried to include the Header Search Path and the Library Search Path on my target application build info but it doesn't work.
I've included the header file using double quote markers just like the following example:
#include "fuzzylite/test.h"
How can I include such library in my project and get it to work properly?
Easy, you need clean the path: #include "fuzzylite/test.h" for ALL #include, like this: #include "test.h"
From version 3.1, you should use #include fl/Headers.h.
If you are running into problems, I strongly encourage you to report the problem in the forums at http://www.fuzzylite.com, where I and others will be very happy to help you.