在mac上创建失败的建筑项目



我正在尝试在我的新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);

您提供的错误消息表明没有包含gettimeofday。从你提供的信息来看,clock_gettime与它有什么关系是不可能的。

对此进行快速搜索,发现gettimeofday应该可用(它是POSIX的一部分)。你有#include <sys/time.h> (Apple Docs)还是#include <sys/types.h> (SO Answer)?

最新更新