CMake error when trying to setup testing on MacOS

Hi guys,

As the C++ learning track was just released, I thought I’d give it a go for JurassicJuly. I’ve downloaded the lasagna exercise to my machine, have created the build directory as per the instructions, running cmake -G Xcode .. from the build directory returns the below error

-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:8 (project):
No CMAKE_CXX_COMPILER could be found.

Any help would be much appreciated!

Is the c++ compiler installed? On linux, i believe the typical compiler is called g++. What’s the output of the command g++?

1 Like

edited to add Apologies - I should not assume that you are on a Mac!

If you are on a Mac:
You might need to install or update XCode or XCode Command Line Tools.

This article has several strategies for C++ - there are instructions there for both XCode and the Command line tools.

This SO post also has some good comments and explanations of what might be going on with a Mac not finding a compiler and linker. TL;DR: if you don’t install the command line tools, you don’t get LLVM and other goodies.

1 Like

Sorry guys I forgot to say my os is MacOS! @BethanyG I will give your suggestions a try!

Is there anything we can change in the docs to make it easier for other people to get the thing running on a Mac?

I’m happy to improve that part of the track, but I don’t have a Mac to test things.

Thank you @BethanyG, after following the step 1 instructions to install Xcode and setup a C++ project in the link you sent, I have successfully created the the inital build with no errors!

@vaeng perhaps you want to include instructions on setting up the prerequisites? If you’d like, I can submit a PR for this.

  • Cmake - brew install cmake
  • Xcode - install Xcode from the app store, initialize a MacOS C++ project

Please, you know best what you did to make it run. Ping me, so I can reopen the PR when the bot has closed it.

Upon further inspection, I probably should have just read the installation instructions, I think installing GCC via brew would’ve cleared up the compiler issue I first created this post about.

That said, the CMake command wouldn’t work until I installed and configured a project in Xcode. It threw an error along the lines of Xcode 1.5 not supported. Prior to this, I hadn’t installed Xcode as the development I do is in VSCode and Eclipse. The installation instructions seem to infer that as long as you have a major IDE installed, you should be fine "so you should only need to install the IDE.".

I can still make a PR to really try and clarify this point within the installation instructions and probably make a reference back to the installation prerequisites from the testing instructions.

Let me know!

I think PR-ing to clarify would be great. It is super-annoying to be in the middle of things, only to realize that you have to stop and download or update Xcode/Xcode tools and configure a project there before you can even run CMake.

…even when you aren’t going to use Xcode as a dev environment!
I love my Apple 'puter, but :woman_facepalming:

And it’s an easy detail to miss.

1 Like

Thanks guys!

@vaeng here you are :smiley:

1 Like