3

When I compile a open source program called gate with "make" I have this error message:

error <atomic> is not implemented

I must add that I know this program and I compiled it several times previously with no problem

My setup looks like:

sudo xcode-select --install 
which gcc
gcc --version

I run on yosemite 10.10.5, xcode 7.1.1 and I tried several compilations with clang and gcc

  • Welcome to Ask Different. Could you run two things and edit the post with the details? I'll edit your post with the commands, you can enter the results next... You also might need to show that make command to let us know the flags and/or if it indicates a specific header file is missing or cannot be found. – bmike Nov 29 '15 at 17:49
  • 1
    Thanks bmike. xcode-select --install was done. gcc -v gives: 'Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 7.0.0 (clang-700.1.76) Target: x86_64-apple-darwin14.5.0 Thread model: posix'. I tried to get the last check out of llvm and clang according to this post I wait for the results and tell you tomorrow – Luc SIMON Nov 29 '15 at 23:30
  • Perfect. Please edit the body with your results and then @ ping me - that tool looks very nice so I hope we can get you an answer and it running again. – bmike Nov 30 '15 at 1:47
  • well... It doesn't work. Sometimes I feel like I should not touch a computer anymore :-) I installed llvm localy (in /Applications/) and found an executable called build/bin/clang-3-8 as a compiler. So I compiled my program using ccmake and with clang-3-8 as C and C++ compiler. It fails after 1% with message "could not find iostream". – Luc SIMON Dec 2 '15 at 6:33
  • OK - we're getting somewhere (slowly) - the compilers seem to not have everything they need. You shouldn't need to go install anything - in fact - if you have two or three compliers, determining which one is being used is problematic. I'll make an answer on how to move forward, but you might need to post the exact two responses - word for word to the sudo xcode-select --install and which gcc so I can tailor my answer to your situation. – bmike Dec 2 '15 at 14:15
1

Looking at the question, the edits and the comments, it's becoming clear that the setup of your compiler chain and the headers is probably the cause. You could keep trying to add things, but I would take a different tack:

  1. Make a full backup of the Mac - one that you are serious about using if you wipe the machine and run a test compile of the program and then restore either the full backup or files you need selectively from the backup.
  2. Remove Xcode and remove all the compilers you have downloaded and installed.
  3. Install a tool to assist with the maintenance and installation of the compiler and the need header library files for the latest c++ standard.

The tool I use is homebrew, so you can install it per https://brew.sh

  1. brew update
  2. brew doctor - and be sure you follow any of the advice in the doctor or post here for advice
  3. brew install gcc

Here is the test program I used for a "minimal test case"

#include<atomic>
#include<iostream>

using namespace std;

int main()
{
    cout << "Hello World" << endl;
}

Before using the "brew" version of gcc, I get what I presume is the same error as you:

mac:Desktop me$ /usr/bin/gcc gate\ test.cpp
In file included from gate test.cpp:1:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/atomic:543:2: error: <atomic> is not implemented
#error <atomic> is not implemented
 ^
1 error generated.
mac:Desktop me$ which gcc
/usr/bin/gcc

But if I compile it using the "brew installed gcc", I'm getting a very nice detailed message

mac:Desktop me$ g++-5 gate\ test.cpp 
In file included from /usr/local/Cellar/gcc/5.2.0/include/c++/5.2.0/atomic:38:0,
                 from gate test.cpp:1:
/usr/local/Cellar/gcc/5.2.0/include/c++/5.2.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
mac:Desktop me$ g++-5 gate\ test.cpp -std=c++11

TLDR;

  1. pointing your compiler to g++5
  2. delete other compilers as needed (including Xcode possibly)
  3. adding the compile option -std=c++11
  • Any way to make this a global setting? – Shamoon May 17 '18 at 17:55
1

Had the same issue with xCode 6.4. When using atomic in a simple helloWorld program it worked, but when using a project generated by CMake, I had the "#error is not implemented"

It appears CMake needs special flags to enable c++11 on mac... So, did exactly (almost... replaced if(UNIX) by if(APPLE)) as kitware indicates here:

https://cmake.org/Wiki/CMake/Tutorials/C%2B%2B11Flags

In case the link stops working one day....

cmake_minimum_required(VERSION 2.6)

PROJECT(Test)

if(UNIX)
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")
endif()

# MSVC does not require any special flags

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .