【问题标题】:'CUnit/Basic.h' file not found MacOS'CUnit/Basic.h' 文件未找到 MacOS
【发布时间】:2021-02-22 21:16:40
【问题描述】:

我使用的是 MacBook,最近刚刚安装了带有 HomeBrew 的 CUnit。 安装进展顺利(没有错误或警告,所以我想没关系)。之后我想运行一个测试文件:

#include <stdio.h>
#include <string.h>
#include <CUnit/Basic.h>
int main(void) {
printf("Hello, world!\n");
return 0;
}

很遗憾,在运行gcc -o test test.c 这一行之后,我得到了这个错误:

test.c:3:10: fatal error: 'CUnit/Basic.h' file not found
#include <CUnit/Basic.h>
         ^~~~~~~~~~~~~~~
1 error generated.

谁能帮我解决这个问题?我真的不明白这是怎么发生的,即使安装很顺利(我猜)。

【问题讨论】:

  • 尝试将参数-I/usr/local/include 添加到您的g++ 命令中。
  • 你的意思是这样吗? gcc -I /usr/local/include -o test test.c
  • 是的,-I/usr/local/include 中没有空格。
  • 还是同样的问题
  • 命令ls /usr/local/include的结果是什么?

标签: c macos homebrew


【解决方案1】:

所以问题是,Homebrew 将软件包安装在此路径 /opt/homebrew/Cellar/cunit/2.1-3/gcc 对于 /usr/local/include/usr/include 内的所有头文件看起来都是默认的。

要指向已安装的 Homebrew 包路径,请执行以下步骤: https://web.archive.org/web/20090129230009if_/http://www.network-theory.co.uk/docs/gccintro/gccintro_23.html

你只需要配置环境变量;)

【讨论】:

  • 为了让您的答案更好,请至少添加链接资源的摘录。外部资源可能会消失。
猜你喜欢
  • 2014-11-28
  • 2021-06-29
  • 1970-01-01
  • 2019-04-07
  • 2022-07-18
  • 2017-07-26
  • 1970-01-01
  • 2023-03-23
相关资源
最近更新 更多