Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

including C/C++ headers in Xcode 4

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?

like image 560
Eric Avatar asked Dec 16 '22 05:12

Eric


1 Answers

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.

like image 190
Eric Avatar answered Dec 27 '22 10:12

Eric