13

I'm trying to compile a project on the command line on Maverick 10.9. The project compiles perfectly on Linux. Apparently, there seems to be an issue with ctime on MacOSX. The errors are

$ make
Compiling src//core/AbstractARAClient.cpp
In file included from src//core/AbstractARAClient.cpp:5:
In file included from include/AbstractARAClient.h:8:
In file included from include/ARAMacros.h:14:
In file included from include/Address.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/sstream:174:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:131:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:18:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/mutex:176:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__mutex_base:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/chrono:279:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:56:9: error: no member named
      'clock_t' in the global namespace
using ::clock_t;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:58:9: error: no member named
      'time_t' in the global namespace; did you mean 'size_t'?
using ::time_t;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stddef.h:42:23: note: 
      'size_t' declared here
typedef __SIZE_TYPE__ size_t;

In file included from src//core/AbstractARAClient.cpp:5:
In file included from include/AbstractARAClient.h:8:
In file included from include/ARAMacros.h:14:
In file included from include/Address.h:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/sstream:174:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:131:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:216:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:18:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/mutex:176:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__mutex_base:15:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/chrono:279:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:60:9: error: no member named
      'clock' in the global namespace
using ::clock;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:61:9: error: no member named
      'difftime' in the global namespace
using ::difftime;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:62:9: error: no member named
      'mktime' in the global namespace
using ::mktime;
      ~~^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ctime:63:9: error: no member named
      'time' in the global namespace
using ::time;

I've searched the web and there seems to be an issue if there are headers in a project which are named 'time.h' (like it is the case in this project). There also seems generally to be a problem with an actual incomplete implementation of ctime (but generally people refer to install command line utils via xcode).

I'm wondering what the general issue is and finally how to actually compile the code on mac. In contrast, to the code in the repository, I've added to the Makefile in line 53 a stdlib option

CFLAGS_DEBUG = -g -Wall -stdlib=libc++

The C++11 option is already set in a previous line of the Makefile.

TIA

user1729210
  • 579
  • 1
  • 8
  • 30
  • `The C++11 option is already set in a previous of the Makefile.`... what is the actual command? – Grady Player Feb 18 '15 at 15:47
  • 1
    It doesn't matter anymore. It was not an issue of C++11, but of a header 'Time.h' in the project which resulted in a conflict with /usr/include/time.h. – user1729210 Feb 18 '15 at 15:54

3 Answers3

14

The answer is more or less obvious. The project contains a header Time.h (and corresponding class Time). Unfortunately, the MacOSX file system is case insensitive, meaning that this conflicts with the existing time.h in /usr/include.

You can either include the systems time.h (meaning #include <ctime>) beforehand the Time.h or simply rename your file to something else (e.g. MyTime.h).

user1729210
  • 579
  • 1
  • 8
  • 30
7

Check if /usr/local/include/time.h exists on your system, remove it if it exists.

fool
  • 508
  • 6
  • 15
  • It worked for me! Can you explain how this works? @fool –  Dec 22 '18 at 03:58
  • 1
    In my case it was Homebrew that installed lots of headers into `/usr/local/include`, which overrided system headers. – fool Dec 22 '18 at 12:29
  • All these years later, this was the answer for me when it came to installing certain NPM packages / installing different versions of Python using pyenv. – Michael Bondi Mar 31 '21 at 10:12
4

There is a different way to solve this, which IMHO is better. I write this so I can find the answer easily next time I hit this error and have forgotten the solution (in a couple years?)

Go into Xcode and remove the project files included in the "Headers" section from the Build phases.

This will prevent the inappropriate action of the compiler including from your space (which should only (or at least ordered last) be accessible via "Time.h")

This essentially tells Xcode "No I do not want to search my own headers as if they were a library, because it is my own project"

It probably has other secondary repercussions but, at least for my uses, this is better than renaming my "Time.h"

iamacomputer
  • 518
  • 3
  • 14