C++找不到库标头

C++ library header not found

本文关键字:找不到 C++      更新时间:2023-10-16

我是OS X用户,我最近使用brew安装了"cppunit"库。当我尝试使用 TestCase.h 标头编译"test.cpp"文件时,发生错误:

> test.cpp:3:10: fatal error: 'TestCase.h' file not found
>     #include "TestCase.h"

我正在编译这个文件:

测试.cpp

#include <iostream>
#include "TestCase.h"
using namespace CppUnit;
class EmptyTest : public TestCase
{
};
int main()
{
}

使用此命令:

g++ -Wall -pedantic -std=c++14 test.cpp -o test.x -lcppunit

我也尝试使用 -I 提供库目录的路径进行编译,但仍然出现相同的错误。我所有使用 cppunit 和 brew 的朋友都可以简单地包含标题,程序运行良好。

我将不胜感激每一个答案。

我已经解决了这个问题。我在使用 Xcode 时遇到了问题。重新安装工作正常。