"Parse issue: Unknown type name" error after upgrading XCode - c++

After I upgraded my Mac OS X to Mountain Lion (all the way from Snow Leopard) and XCode 5 (all the way from XCode 3.2) I can no longer build a C++ project that I used to build in XCode successfully. I get loads of errors now all saying "Parse issue: Unknown type name *" for different objects. I tried an older version of XCode (4.6) and set the SDK to Mac OS X 10.7. This problem was solved but not using the latest version of XCode caused other problems.
To be specific, the errors (at least the first ones) seem to be related to Carbon graphic library. I don't know if that matters. I know that Carbon is somehow outdated but an official release of the application I'm extending runs on Mac OS 10.8 so I wonder why I can't build the code on 10.8.
What can be the cause of this error? The code is big and is not written by me so changing it is not an option. I really need to build it on XCode 5 or else I should downgrade my OS!

Several things that have been long deprecated in Carbon were finally removed in the Mac OS X 10.7 SDK.
You will need the Mac OS X 10.6 SDK to build your project. Apple stopped automatically including older SDKs with newer versions of Xcode but you can download older Xcode versions (from Apple's Developer site) and one of them...maybe Xcode 4.3 or so...will have the 10.6 SDK.
In order to use an older SDK with a newer Xcode, you must install it manually. The correct location is:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/
Also note, any upgrade to Xcode (such as an update downloaded from the App Store) will obliterate your manually-installed SDKs. I recommend archiving the ones you need somewhere else so you can replace them as needed.

Related

How do I get back c++0x/c++11 support for Mac OS X 10.6 deployment using Xcode 4.6.2 thru 7.1.1

I heavily use the c++0x/c++11 features in my project, particularly code blocks and shared pointers. When I upgraded my OS to 10.8 Mountain Lion (Edit: From 10.7), I was forced to upgrade Xcode. In upgrading Xcode, I lost the ability to compile my c++ project for deployment on 10.6 systems as I get the following error.
clang: error: invalid deployment target for -stdlib=libc++ (requires Mac OS X 10.7 or later)
It appears that Apple is trying to force people to upgrade by not allowing developers to support Snow Leopard. This makes me angry. Arrrggg!!!
What can I do?
EDIT: After several comments back and forth, it should be made clear that 10.6 does not ship with system libc++ libraries. As a result, simply being able to build a libc++ project for 10.6 deployment is not enough. You would also need to include libc++ binaries with your 10.6 distribution or statically link to them. So lets continue with the premise that I am already doing that.
UPDATE 1: This question was originally intended for use with Xcode 4.5.2 (the latest version at the time the question was asked). I have since upgraded to Xcode 4.6.3 and have updated the question and answer to reflect that.
UPDATE 2: I've since upgraded to Xcode 5.0.2. The technique listed in the selected answer below still works as expected.
UPDATE 3: I've since upgraded to Xcode 5.1. The technique listed in the answer below does not yet work for this version!
UPDATE 4: I've since upgraded to Xcode 6.0.1. The technique listed in the selected answer below appears to be working again.
UPDATE 5: I've since upgraded to Xcode 7.1.1. The technique listed in the selected answer below appears to be working again, with one important caveat. You must disable Bitcoding used for AppThinning since the opensource LLVM version doesn't support it (nor should it). So you will need to switch between the open source and Apple LLVM clang in order to compile for both 10.6 and tvOS/watchOS (since Bitcoding is required for those OSes).
Apple has decided to only officially support libc++ on 10.7 or higher. So the version of clang/llvm that ships with Xcode checks to see if the deployment target is set for 10.6 when using libc++, and prevents you from compiling. However, this flag is not included in the open source version of clang/llvm.
Take a look at this thread:
http://permalink.gmane.org/gmane.comp.compilers.clang.devel/17557
So, to compile a project that is using c++11 for 10.6 deployment, you need to give Xcode the open source version. Here is one way of doing it:
Download the open source version of clang from here (use LLVM 3.1 for Xcode 4.5.x; use LLVM 3.2 for Xcode 4.6.x; use LLVM 3.3 for Xcode 5.0.x; use LLVM 3.5.0 for XCode 6.0.1; use LLVM 3.7.0 for XCode 7.1.1):
http://llvm.org/releases/download.html
Make a backup of Xcode's default clang compiler and put it in a safe place (In case you screw up!)
This is located at:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
Replace the default clang compiler with the one you downloaded from [1]
chown the clang binary for root:wheel with sudo chown root:wheel clang from the bin directory listed in [2].
Startup Xcode and compile!
UPDATE #1: This technique does not currently work for Xcode 5.1 or newer, which relies on LLVM 3.4. When I get some more time, I will try and find a solution to post here. But if someone comes up with a solution before me, they should post it as an answer.
UPDATE #2: Unfortunately I can't remember if I ever found a solution for Xcode 5.1, however I can confirm that the technique does still work for Xcode 6.0.1. I haven't tested on versions newer than that, but it could still work.
UPDATE #3: This technique appears to still work with XCode 7.1.1 using LLVM 3.7.0. However, the open source LLVM clang does not support Bitcoding. So you will need to switch between the open source compiler and Apple's compiler in order to develop for both 10.6 and tvOS/watchOS (which require Bitcoding).
P.S.: The Mac OS X binaries for LLVM 3.4 and 3.5.0 are listed as "Clang for Darwin 10.9" at www.llvm.org/releases/download.html rather than as "Clang Binaries for Mac OS X" in previous versions.
While Xcode 4.5.x is the current default version on OS X 10.8, you can have other, older versions of Xcode, such as Xcode 3.2.6 for OS X 10.6, available on 10.8 as long as you have access to their installers. You will need to ensure you install each one to a unique directory. Also, one thing you can't or shouldn't do is to install the Command Line Tools component or installer package of older Xcodes onto your 10.8 system, i.e. not into /usr or /System/Library. You can use the xcodebuild, xcode-select, and xcrun command line tools to access non-default Xcode components. See their man pages for more info. Older versions of Xcode are available to registered users of developer.apple.com
UPDATE: Based on your subsequent comments, I believe I did miss the point of the question and also that you had answered your own question. I think what you are saying is that you upgraded from 10.7 to 10.8, not from 10.6 to 10.8 as I assumed. You also did not make clear in the original question that you were distributing your own version of Apple's libc++ and friends from 10.7 with your own app. Apple does not make it easy in Xcode to do something like that since it has long been Apple's policy to discourage static linking with libs or distributing duplicate libs (which in some cases could violate license terms). There are good reasons for that policy.
The bottom line is that libc++ is only shipped with OS X 10.7 or later systems. There never was Apple support for libc++ in 10.6, so it's misleading to say it was removed. If you want to supply an app that is deployable on 10.6 and later systems and depends on libc++, the safest approach is to build your own clang/llvm and libc++ targeted for OS X 10.6 and use that to build your project. There are various ways to do that, probably the easiest is to use the MacPorts versions and set the deployment target in MacPorts for 10.6. Or build it all from scratch yourself. But modifying the clang compiler within Xcode 4.5 is a bad idea. And copying Apple libraries to one's app is generally a bad idea.
If you have a solution that works for you, great. But I would not recommend it to others.

Compile for OS X 10.6?

Normally for my OS X builds I have been compiling my applications on an old Mac Book Pro that runs 10.6. This assures that I support this version of OS X.
However for various reasons, the MBP is no longer a long term option so I have been compiling on a more recent device which runs 10.8. However when I do this, my application does not work on 10.6 even with the -mmacosx-version-min=10.6 flag set. The error that happens when I set the flag is "Symbol not found: _wcsdup" in libSystem.B.dynlib
I looked up this error and the only recommendations I can find is to directly link against the 10.6 SDK. However when I tried copying the 10.6 SDK from my MPB to the new machine (because 10.6 SDK is not installed on 10.8), it fails to compile with errors like "error: bits/c++config.h: No such file or directory" I assume this is because of the way I "installed" the SDK, although others have had success with this.
Does anyone have a solution?
Run 10.6 in a VM, like VMWare or VirtualBox.
I am able to reinstall older SDKs and compilers with this procedure: How can we restore ppc/ppc64 as well as full 10.4/10.5 SDK support to Xcode 4?
You need to change the path of xcode installs in the script.
Also you probably won't be able to use -std=c++11 when targeting 10.6 since you will mostly also need -stdlib=libc++ which is only available when targeting 10.7 or above.
Apple only distributes libc++ binaries since 10.7. You could build your own libc++ and deploy it with your app to 10.6 machines. But Apple hard coded the compiler to disallow -stdlib=libc++ when targeting anything lower than 10.7.

Building 10.7 Lion apps with Xcode 3.2.6 - Do they work

Long time browser, first time asker...
Maybe you can help. I've searched and searched, and seen it asked a few times, but it always turns into a "Xcode 4 sucks" debate.
QUESTION: Do projects built in Xcode 3.2.6 on OSX 10.7, using "Current OS" as base SDK and 10.5 as the target actually work with all versions of OSX?
I had Xcode 3.2.6 on my 10.6 OSX build. I upgraded to Lion, and installed Xcode 4. Xcode 3 was moved to /Developer-3.2.6.
Now some of my old projects don't work in Xcode 4 and I personally prefer 3 (I GIT via command line anyway). But if I build in Xcode 3, it lets me pick "Current OS" as the base SDK, and 10.5 as the target. Am I right in presuming Xcode 3 will now build 10.7, 10.6, and 10.5 apps in 1 binary?
Your applications built with Xcode 3.2.6 should run on 10.7. They won't take advantage of any features added in 10.7, like fullscreen windows.
As long as your code doesn't call any methods added in 10.6 or 10.7, your application will run on 10.5 and above if you set the deployment target to 10.5. You don't have to specify Intel only to run on 10.5 through 10.7.

Stanford CS106B C++ libraries in XCode 4

I'm trying to use the Stanford CS106B C++ libraries, like simpio.h and genlib.h. I'm using XCode 4 (this is a beta version btw) and Mac OS X 10.6. I installed the libraries, but they don't seem to be showing up when I try to create a new project in XCode. Is there something different I should be doing with XCode 4 to get these libraries in?
There's probably a pretty basic solution to this problem, and if it were just a matter of frameworks in iOS, I could definitely get that to work with this version of XCode, but I've not really done this with C++ and XCode before, so I'm stuck.
Update on 7/20/11
I found a link to download the Xcode 2.5 tools as well as Xcode 3.0, both of which are described in the handout. I'm downloading both of them now. Does anyone know if Xcode 3.0 and 4.2 will run fine on the same machine?
Yes, multiple versions of Xcode work fine together. During the install, after the "Select a Destination" screen, you see a screen with the packages that will be installed. Click "Developer" folder to change to a custom location for each different Xcode version. The other tools (system and UNIX) cannot be moved.
After you have Xcode installed, just install your libraries in the usr/lib folder under your custom Xcode folder, and you should be good to go.

C++ Programming on a Mac

I have installed Xcode 4.0 (XCode Toolset, System Tools and Documentation components only), but have Netbeans with the C/C++ plugin. However when I try to create a new C++ project in Netbeans it tells me that no compiler was found on my system. The recommended course of action is to install Xcode, which I have done so.
How do I get Netbeans to recognize that I already have Xcode?
Most likely, you reinstall Xcode and this time don't uncheck the option that installs the compiler, etc. under /usr/bin for command line use. What's wrong with just having a full installation of Xcode?
If that doesn't work, it may be an incompatibility due to Xcode 4 installing to /Xcode4 instead of /Developer. You can fix that with a symlink or by installing Xcode 3.