Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix missing time related no member in global namespace errors on MacOSX?

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

like image 916
user1729210 Avatar asked Oct 03 '14 12:10

user1729210


2 Answers

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).

like image 50
user1729210 Avatar answered Sep 26 '22 13:09

user1729210


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

like image 31
fool Avatar answered Sep 22 '22 13:09

fool