如何修复“致命错误:x.264没有这样的文件或目录”

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

我写了一个makefile,它构建了一个附加x.264标头的C程序。尝试在终端中执行makefile后,我收到致命错误:“example.c line [#include的行] x264.h没有这样的文件或目录”。您可以在下面找到C代码和makefile(位于同一文件夹中,包含x264.pc文件的库 - 位于父文件夹的libx264文件夹中)。如果你能帮助联系,我将非常感激。

Makefile文件:

    CC = gcc

    CFLAGS = -c -Wall `export PKG_CONFIG_PATH=../libx264 && pkg-config            --cflags x264`
    LDFLAGS = -static `export PKG_CONFIG_PATH=../libx264 && pkg-config --libs --static libx264`


    all: Release

    Debug: CFLAGS += -g
    Debug: example

    Release: example

    test: example.o
        $(CC) -o example example.o $(LDFLAGS)

    test.o: example.c
        $(CC) $(CFLAGS) example.c -o example.o

    clean:
        rm -f example.o example

example.c代码

    #include <stdio.h>
    #include <x264.h>
    int main( int argc, char **argv )
    {
        int width, height;
         return 0;
    }
c makefile x264 libx264
1个回答
1
投票

您需要告诉编译器(更准确地说:预处理器)头文件使用-I选项:

CFLAGS = -c -Wall -I../libx264

如果我是对的,你需要解压缩那个.pc文件,这样x264.h确实在../libx264

类似的东西为链接器标志(假设在libx264.a中有一个../libx264文件),你必须指定库使用-L选项的位置:

LDFLAGS = -static -L../libx264 -lx264

或者你当然也可以写:

LDFLAGS = -static ../libx264/libx264.a
© www.soinside.com 2019 - 2024. All rights reserved.