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
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
).
Check if /usr/local/include/time.h
exists on your system, remove it if it exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With