• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Unable to compile Cocoa/Objective-C program to C++
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unable to compile Cocoa/Objective-C program to C++


  • Subject: Re: Unable to compile Cocoa/Objective-C program to C++
  • From: Dan Treiman <email@hidden>
  • Date: Sun, 12 May 2013 15:48:02 -0500

	This is a bit of a shot in the dark, but are you by any chance including a C++ header in your Objective-C++ header file?  This would account for the error you are seeing.

Here is a typical pattern:  ObjC.m  includes  ObjC++.h.  ( ObjC++.mm also includes ObjC++.h ).  ObjC++.h must contain obnly Objective-C since it will be included by an Objective-C class.  If you use any C++ types in ObjC++.h, compilation of ObjC.m will fail, so you need to completely encapsulate all of your C++ code within .mm files.

	Hope this helps.  If not, maybe send some of your code?

	- Dan Treiman


On May 12, 2013, at 12:06 PM, Paul Johnson <email@hidden> wrote:

> I am able to compile my one Objective-C++ file as Objective-C++. (I
> selected the Build Phases tab for the project I expanded the Compile
> Sources section and on the line for the Objective-C++ file I added in
> the Compiler Flags column: '-x objective-c++'.
>
> When I do this, this compiler is called twice, one to compile the
> Objective-C file and one to compile the Objective-C++ file.
>
> I'm still getting a fatal compile error in one of the header files
> #included in the 3rd party software though.
>
> (If I compile the Objective-C++ file, by a calling clang in  Terminal,
> I can compile the Objective-C++ file with just one warning message, so
> I'm definitely getting closer to solving this problem.)
>
> On Sun, May 12, 2013 at 11:03 AM, Paul Johnson <email@hidden> wrote:
>> In my Cocoa/Objective-C program I'm trying to access 3rd party
>> software written in C++.
>>
>> I'm trying to use Objective-C++ to accomplish this but it appears that
>> Xcode is not recognizing the file where I call the C++ as having been
>> written in Objective-C++. (The long compiler command contains '-x
>> objective-c'.) I've renamed the file to give it a .mm extension, which
>> is the extension used for Objective-C++ files, and I've also set the
>> File Type to 'Default- Objective-C++' in the Identity and Type section
>> of the File Inspector. I also removed the Objective-C++ file from my
>> project and reinserted it.)
>>
>> I #include one header from the 3rd party software and have one line
>> that calls the software to instantiate a C++ object there. This header
>> file references other header files and one of them has the line
>> '#include <string>'. The compiler complains that it can't find the
>> file 'string'.
>>
>> I used the 'locate' command in Terminal to find the 'string' file, and
>> found two occurrences, one at /usr/include/c++/4.2.1/string and
>> another at /usr/lib/c++/v1/string.
>>
>> I've tried adding /usr/include/c++/4.2.1 to the HEADER_SEARCH_PATHS in
>> Xcode but get lots of additional compile errors.
>>
>> Can someone help me with this issue with calling C++?
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Unable to compile Cocoa/Objective-C program to C++ (From: Paul Johnson <email@hidden>)
 >Re: Unable to compile Cocoa/Objective-C program to C++ (From: Paul Johnson <email@hidden>)

  • Prev by Date: Re: instruments stall
  • Next by Date: Provisioning Profile Expiring
  • Previous by thread: Re: Unable to compile Cocoa/Objective-C program to C++
  • Next by thread: Provisioning Profile Expiring
  • Index(es):
    • Date
    • Thread