Writing, building, and running your C++ on a Mac

The very first wall that I had hit when I was looking for a C++ tutorial was that I struggled finding one that was OS X friendly. Most of the tutorials that I had found started out with installing software onto your PC and then explaining it based on how that program ran. I only have my iMac and Macbook right now (although the Macbook can run Ubuntu as well!), so finding something that would work for me was important. After realizing this initial problem I was seeking out information on how to write and build C++ programs on a Mac.

running c on mac

The first guides that I found said that if you download and install Xcode, which is free to download from the Apple website, you can write and quickly run your C++ code from there. I had installed Xcode ages ago so I got that up and running and ready to receive my code. But for some reason the code I was entering just wasn’t running right! I was getting errors for code that was syntactically correct (as far as I could tell) and I couldn’t understand the errors. Even worse, when I looked up the errors I was receiving the solutions were a little over my head at my current level. I have a half dozen more text editors that do all sorts of things, so I figured that one of them should be able to help me.

The first that I tried was TextWrangler, which I liked A LOT for Python because you could push your code straight to the terminal from the program. Couldn’t manage to get that to work with C++.
After that I tried Komodo Edit, which I also like a lot for its interface. There is an option to view a portion of the editing screen for debugging, and my code was all lit up for strange errors similar to what I was dealing with while running Xcode.
I finally opened Sublime Text 3 although I wasn’t terribly hopeful just because I just don’t use it terribly often. But Sublime Text is how I got my C++ codes to work! I opened up my test.cpp file, made sure again that the syntax was correct and then went to tools > run, which showed a small partition in the bottom of the editing screen and ran my code!

I then wrote a code that required user input, hit run, and was a little disappointed that i wasn’t able to participate with the program, it just skipped over the user input sections. But I instead hit tools > build and ran the executable file that Sublime Text created and it ran perfectly in my Terminal window! It was such a relief!

I apologize if any experienced programmer might look at my excitement and blow it off as me being a complete novice, but for people that are complete beginners just getting a “Hello World” code to run is a huge victory!

Read More Post

STAY CONNECTED

Most Popular

Why Serviced Apartments Are the Perfect Choice for Long-Term Stays in Singapore – Everything You Need to Know
17 Dec

Why Serviced Apartments Are the Perfect Choice for Long-Term Stays in Singapore – Everything You Need to Know

If you’re heading to Singapore for a few weeks or many months, maybe for work or study or just to

Manifesting Your Dream Career: Finding Your Passion And Purpose
01 Aug

Manifesting Your Dream Career: Finding Your Passion And Purpose

Are you passionate about finding your dream career? Manifesting can help you align your career with your passions and purpose.

Revolutionizing Your Ride: Expert Auto Service At Carolina Auto Service
27 Feb

Revolutionizing Your Ride: Expert Auto Service At Carolina Auto Service

Finding a reliable auto service provider is paramount in the bustling world of vehicle maintenance and repair. That's where Carolina

Floratam: The Robust Grass Solution From Council Growers SOD
25 Jan

Floratam: The Robust Grass Solution From Council Growers SOD

Floratam grass, a popular St. Augustine variety, has become a go-to choice for homeowners and landscapers seeking a lush, durable

Carolina Mobile Autoservice: Your Go-To For Expert Brake Service Repair
25 Jan

Carolina Mobile Autoservice: Your Go-To For Expert Brake Service Repair

For vehicle owners, the braking system is among the most critical components for safety and performance. Carolina Mobile Autoservice, a

Safeguarding Your Property: Expert Water Damage Services By MBC Capital
24 Jan

Safeguarding Your Property: Expert Water Damage Services By MBC Capital

Water damage can significantly impact homes and businesses, often leaving a trail of destruction and disruption in its wake. Understanding