Question

I've been using a C++ library without problems on projects built with Xcode 3, but I'm now getting build problems on projects built with Xcode 4.

Drop the library into the Xcode 4 project and it builds fine, but as soon as I #include it, I get a "Lexical or Preprocessor Issue" error, more specifically " 'string' file not found, on line 4 of its main header file.

On closer inspection, the error specifies that 'string' file not found in ~/my project's directory/include/mainheader.h

I've tried the solutions listed here, but none worked.

So it thinks that header file is in my project directory, but it's obviously a C/C++ header… How can I tell Xcode to look for these C/C++ headers?

Was it helpful?

Solution

The problematic #include was at the top of my ViewController.mm, which I had already turned into Objective-C++ by giving it .mm as its extension. But ViewController.mm gets eventually imported by AppDelegate.m, which is Objective-C by default – and I had forgotten to make it Objective-C++, hence the problem.

So renaming AppDelegate.m to AppDelegate.mm solved the problem.

OTHER TIPS

I think #include is a c++ class template..so you need to used using namespace std in your header file and also rename your source file .m format to .mm format.

it works for me :) try this...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top