致命错误:include/chrono:没有这样的文件或目录 14 | #包括<chrono>

问题描述 投票:0回答:1

我正在尝试构建https://github.com/eunomia-bpf/bpftime/ 当我使用

#include <chrono>
时,它给出以下错误:

fatal error: include/chrono: No such file or directory    14 | #include <chrono>

编译器版本:

pegasus@pegasus:~$ clang --version
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 815644b4dd882ade2e5649d4f97c3dd6f7aea200)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/pegasus/Documents/llvm-project/build/bin
pegasus@pegasus:~$ g++ --version
g++ (Ubuntu 13.2.0-4ubuntu3) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

pegasus@pegasus:~$ gcc --version
gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Makefile。它调用 cmake 命令。我从 bpftime 存储库内部运行它。

.PHONY: install coverage test docs help build clean unit-test-daemon unit-test unit-test-runtime
.DEFAULT_GOAL := help

define BROWSER_PYSCRIPT
import os, webbrowser, sys

try:
    from urllib import pathname2url
except:
    from urllib.request import pathname2url

webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT

define PRINT_HELP_PYSCRIPT
import re, sys

for line in sys.stdin:
    match = re.match(r'^([a-zA-Z\d_-]+):.*?## (.*)$$', line)
    if match:
        target, help = match.groups()
        print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT

BROWSER := python3 -c "$$BROWSER_PYSCRIPT"
INSTALL_LOCATION := ~/.local
CXXFLAGS += -std=c++17
JOBS := 1

help:
    @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

build-unit-test:
    cmake -Bbuild  -DBPFTIME_ENABLE_UNIT_TESTING=1 -DCMAKE_BUILD_TYPE:STRING=Debug
    cmake --build build --config Debug --target bpftime_runtime_tests bpftime_daemon_tests  -j$(JOBS)

unit-test-daemon: 
    ./build/daemon/test/bpftime_daemon_tests

unit-test-runtime:
    make -C runtime/test/bpf && cp runtime/test/bpf/*.bpf.o build/runtime/test/
    ./build/runtime/unit-test/bpftime_runtime_tests
    cd build/runtime/test && make && ctest -VV

unit-test: unit-test-daemon unit-test-runtime ## run catch2 unit tests

build: ## build the package with test and all components
    cmake -Bbuild -DBPFTIME_ENABLE_UNIT_TESTING=1 -DBUILD_BPFTIME_DAEMON=1 -DCMAKE_BUILD_TYPE:STRING=Debug
    cmake --build build --config Debug  -j$(JOBS)

build-iouring: ## build the package with iouring extension
    cmake -Bbuild -DBPFTIME_ENABLE_IOURING_EXT=1 -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
    cmake --build build --config RelWithDebInfo  -j$(JOBS)

release: ## build the release version
    cmake -Bbuild  -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
                   -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO
    cmake --build build --config RelWithDebInfo --target install  -j$(JOBS)

release-with-llvm-jit: ## build the package, with llvm-jit
    cmake -Bbuild  -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo \
                   -DBPFTIME_LLVM_JIT=1
    cmake --build build --config RelWithDebInfo --target install -j$(JOBS)

build-vm: ## build only the core library
    make -C vm build

build-llvm: ## build with llvm as jit backend
    cmake -Bbuild   -DBPFTIME_ENABLE_UNIT_TESTING=1 \
                    -DBPFTIME_LLVM_JIT=1 \
                    -DCMAKE_BUILD_TYPE:STRING=Debug
    cmake --build build --config Debug -j$(JOBS)

clean: ## clean the project
    rm -rf build
    make -C runtime clean
    make -C vm clean

install: release ## Invoke cmake to install..

我用来构建项目的:

make release JOBS=$(nproc)

c++ c++11 cmake include c++-chrono
1个回答
0
投票

我想通了。我导入错了。由于 chrono 是一个 cpp 库,我也在 c 代码中使用导入它。

© www.soinside.com 2019 - 2024. All rights reserved.