-
Notifications
You must be signed in to change notification settings - Fork 11.5k
error: 'CLOCK_MONOTONIC' undeclared #54
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
same question (base) lizheng@lizheng-System-Product-Name:/home/ytkj/root1/liuxiao/LLM/llama.cpp$ make
I llama.cpp build info:
I UNAME_S: Linux
I UNAME_P: x86_64
I UNAME_M: x86_64
I CFLAGS: -I. -O3 -DNDEBUG -std=c11 -fPIC -pthread -mavx -mavx2 -mfma -mf16c -msse3
I CXXFLAGS: -I. -I./examples -O3 -DNDEBUG -std=c++11 -fPIC -pthread
I LDFLAGS:
I CC: cc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
I CXX: g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
cc -I. -O3 -DNDEBUG -std=c11 -fPIC -pthread -mavx -mavx2 -mfma -mf16c -msse3 -c ggml.c -o ggml.o
ggml.c: In function ‘ggml_time_ms’:
ggml.c:309:5: warning: implicit declaration of function ‘clock_gettime’ [-Wimplicit-function-declaration]
clock_gettime(CLOCK_MONOTONIC, &ts);
^
ggml.c:309:19: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)
clock_gettime(CLOCK_MONOTONIC, &ts);
^
ggml.c:309:19: note: each undeclared identifier is reported only once for each function it appears in
ggml.c: In function ‘ggml_time_us’:
ggml.c:315:19: error: ‘CLOCK_MONOTONIC’ undeclared (first use in this function)
clock_gettime(CLOCK_MONOTONIC, &ts);
^
Makefile:182: recipe for target 'ggml.o' failed
make: *** [ggml.o] Error 1 |
在ggml.h头文件中增加以下宏定义即可 |
This fixed it for me |
Adding |
我的机器是centos7, 我在 Makefile文件添加 -D_POSIX_C_SOURCE=199309L 可以解决问题。
|
Same happens when compiling on macOS 10.7: |
- Define `_POSIX_C_SOURCE` with value `199309L` ggml-org/llama.cpp#54 Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
The initial
make
fails withCLOCK_MONOTONIC undeclared
This can be solved by adding
-D_POSIX_C_SOURCE=199309L
to theC{,XX}FLAGS
in the Makefile. See this Stackoverflow question: https://stackoverflow.com/questions/29666937/error-clock-monotonic-undeclared-first-use-in-this-functionThe text was updated successfully, but these errors were encountered: