我正在尝试在我的新Macbook上构建一个项目,该项目之前通常是在Linux计算机上构建的。
首先,当我运行cmake
时,我得到以下内容:
-- The C compiler identification is Clang 5.1.0
-- The CXX compiler identification is Clang 5.1.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Performing Test HAVE_CLOCK_GETTIME
-- Performing Test HAVE_CLOCK_GETTIME - Failed
-- Boost version: 1.55.0
-- Found the following Boost libraries:
-- graph
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- -> doxygen not found -> api-doc will not be created
-- Configuring done
-- Generating done
-- Build files have been written to: /path/to/folder
然后当我运行make
时,它会一直运行到30%左右然后会因此错误而停止:
/path/to/project/lib/helpers.cpp:555:2: error: use of undeclared identifier 'gettimeofday'
gettimeofday(&tv, NULL);
^
1 error generated.
make[2]: *** [lib/CMakeFiles/genom.dir/helpers.cpp.o] Error 1
make[1]: *** [lib/CMakeFiles/genom.dir/all] Error 2
make: *** [all] Error 2
我在线查看了一些建议,可以将clock_gettime(CLOCK_REALTIME, &t);
更改为clock_get_time(CLOCK_REALTIME, &t);
但他们没有工作。
答案 0 :(得分:2)
您提供的错误消息表明未包含gettimeofday
。 clock_gettime
与您的关系无法从您提供的信息中说出来。
快速搜索这个产量,gettimeofday
应该可用(它是POSIX的一部分)。
您有#include <sys/time.h>
(Apple Docs)还是#include <sys/types.h>
(SO Answer)?