Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Is there any way to use c++ without xcode installing

Is there any way to use C plus plus programming without installing xcode

Posted on Feb 28, 2018 7:57 PM

Reply
Question marked as Best reply

Posted on Mar 1, 2018 5:46 AM

Sign-up for a free developer account at developer.apple.com. You can use the same AppleID and password as for the support communities sign-in. You do not need Xcode at all, and can save yourself the 5GB download. Apple makes Command Line Tools that is a 174MB download that gives you a full C/C++/Objective-C compilation environment.


At the bottom of the Apple developer landing page is a link to Downloads, and at the bottom of that page is this download link for more downloads. The command line packages are named: Command Line Tools (os version) for Xcode n.n. So for High Sierra, you want Command Line Tools (macOS 10.13) for Xcode 9.2. As of this post, the version for Xcode 9.3 is really a beta when you look at the filename of the download. Stay away from the beta stuff, and if you install the 9.2 version of command line tools, the Mac App Store will show you an update for 9.3 when it is out of beta.


User uploaded file

If your version of OS X/macOS is older, then find the last Command Line Tools shown for that operating system. It should be worth noting that Apple's compilation environment is not based on GNU compiler technology, and uses the Clang/LLVM technology.

3 replies
Question marked as Best reply

Mar 1, 2018 5:46 AM in response to ankit46

Sign-up for a free developer account at developer.apple.com. You can use the same AppleID and password as for the support communities sign-in. You do not need Xcode at all, and can save yourself the 5GB download. Apple makes Command Line Tools that is a 174MB download that gives you a full C/C++/Objective-C compilation environment.


At the bottom of the Apple developer landing page is a link to Downloads, and at the bottom of that page is this download link for more downloads. The command line packages are named: Command Line Tools (os version) for Xcode n.n. So for High Sierra, you want Command Line Tools (macOS 10.13) for Xcode 9.2. As of this post, the version for Xcode 9.3 is really a beta when you look at the filename of the download. Stay away from the beta stuff, and if you install the 9.2 version of command line tools, the Mac App Store will show you an update for 9.3 when it is out of beta.


User uploaded file

If your version of OS X/macOS is older, then find the last Command Line Tools shown for that operating system. It should be worth noting that Apple's compilation environment is not based on GNU compiler technology, and uses the Clang/LLVM technology.

Mar 1, 2018 6:26 AM in response to VikingOSX

Here is an example C++ program with commented compilation string for clang++. It also utilizes an associative array, memoization technique, and how to use locale to comma punctuate large numbers.


Source (scrollable window)

// memoized version of Fibonacci sequence // Prior results are stored/searched to avoid expensive recalculations // More: http://xlinux.nist.gov/dads/HTML/memoize.html // [ ] below is optional // clang++ -Wall -O2 -o fib_memo fib_memo.C [ -stdlib=libc++ ] #include <iostream> #include <locale> #include <map> using namespace std; // key/value pair associative array std::map<u_long, u_long> alreadyknown; u_long n=0, newvalue=0; u_long fib(u_long n) { // not found is a true condition here if (alreadyknown.find(n) == alreadyknown.end()) { newvalue = fib(n-1) + fib(n-2); alreadyknown[n] = newvalue; } return alreadyknown[n]; } int main(int argc, char* argv[]) { // initialize memoization key/value pair alreadyknown[0] = 0; alreadyknown[1] = 1; alreadyknown[2] = 1; alreadyknown[3] = 2; alreadyknown[4] = 3; alreadyknown[5] = 5; cout<<"Enter the number of terms: "; cin>>n; std::locale mylocale(""); std::cout.imbue(mylocale); // use locale number formatting style cout<<fib(n) << endl; return 0; }

Is there any way to use c++ without xcode installing

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.