solve the errors building llama.cpp
when cmd shows that
python setup_env.py -md models/BitNet-b1.58-2B-4T -q i2_s INFO:root:Compiling the code using CMake. ERROR:root:Error occurred while running command: Command '['cmake', '--build', 'build', '--config', 'Release']' returned non-zero exit status 1., check details in logs\compile.log
you can add #include
Can you show logs\compile.log file here ?
Had the same problem, used Mingw instead of visual studio, check this out and let me know if it helps. https://github.com/saifxyzyz/Bitnet-Mingw.git
Had the same problem, used Mingw instead of visual studio, check this out and let me know if it helps. https://github.com/saifxyzyz/Bitnet-Mingw.git
Nope it doesn't helps. It just straight fork but without changes.
The only fatal error in the log is: common.cpp(445,32): error : no type named 'system_clock' in namespace 'std::chrono' common.cpp(447,11): error : 'clock' is not a class, namespace, or enumeration
Root Cause
common.cpp uses std::chrono::system_clock (C++11) but the translation unit does not contain #include
Impact Only llama-common.lib fails to build; all subsequent executables (including run_inference) cannot link, so the entire BitNet pipeline is blocked.
One-Click Fix (pick either)
Method 1: Add the missing header locally (fastest, no upstream wait)
Open
~\BitNet\3rdparty\llama.cpp\common\common.cpp
add:
#include
by kimi k2
Root Cause common.cpp uses std::chrono::system_clock (C++11) but the translation unit does not contain #include
, so clang-cl on Windows cannot find the definition. Impact Only llama-common.lib fails to build; all subsequent executables (including run_inference) cannot link, so the entire BitNet pipeline is blocked.
If that so it should be failed build by all platform then. Problem should be that windows is handling clang natively different than other platforms. But using wsl this issue is not happening.
So, the easiest solution is to use wsl for building and running it.
By the way I run it on wsl in windows 10. Because setting clang in windows is quite headache for me.
I added #include
ERROR:root:Error occurred while running command: Command '['cmake', '--build', 'build', '--config', 'Release']' returned non-zero exit status 1., check details in logs\compile.log.
I get several warnings and the following error: ...\BitNet\3rdparty\llama.cpp\common\log.cpp(28,79): error : no member named 'system_clock' in namespace 'std::chrono' [...\BitNet\build\3rdparty\llama.cpp\common\common.vcxproj]
Just completed to compile. I solved adding in CMakeLists.txt: set(CMAKE_CXX_STANDARD 17) # this one set(CMAKE_CXX_STANDARD_REQUIRED true)
and various #include
https://github.com/tinglou/llama.cpp/commit/4e3db1e3d78cc1bcd22bcb3af54bd2a4628dd323
To fix build error do this
🧩 Fix: setup_env.py Compilation Error
If you face errors related to missing <chrono>, you need to modify the following files in the llama.cpp dependency.
Reference Commit:
https://github.com/tinglou/llama.cpp/commit/4e3db1e3d78cc1bcd22bcb3af54bd2a4628dd323
Add this line to each affected file:
#include <chrono>
✅ Modified Files
1. 3rdparty\llama.cpp\examples\imatrix\imatrix.cpp
Location: Line 6 (after existing includes)
Before:
#include "arg.h"
#include "common.h"
#include "log.h"
#include "llama.h"
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <sstream>
#include <thread>
#include <mutex>
#include <vector>
#include <fstream>
#include <unordered_map>
#include <algorithm>
After:
#include "arg.h"
#include "common.h"
#include "log.h"
#include "llama.h"
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <sstream>
#include <thread>
#include <mutex>
#include <vector>
#include <fstream>
#include <unordered_map>
#include <algorithm>
2. 3rdparty\llama.cpp\examples\perplexity\perplexity.cpp
Location: Line 9 (after existing includes)
Before:
#include "arg.h"
#include "common.h"
#include "log.h"
#include "llama.h"
#include <algorithm>
#include <array>
#include <atomic>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <mutex>
#include <random>
#include <sstream>
#include <thread>
#include <vector>
After:
#include "arg.h"
#include "common.h"
#include "log.h"
#include "llama.h"
#include <algorithm>
#include <array>
#include <atomic>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <mutex>
#include <random>
#include <sstream>
#include <thread>
#include <vector>
3. common/log.cpp
#include "log.h"
#include <chrono>
#include <condition_variable>
#include <cstdarg>
#include <cstdio>
4. common/common.cpp
#include "log.h"
#include <chrono>
#include <condition_variable>
#include <cstdarg>
#include <cstdio>