【问题标题】:Header file not found while path is included in configure command配置命令中包含路径时找不到头文件
【发布时间】:2019-12-20 16:17:22
【问题描述】:

尝试使用此配置命令从源代码构建 FFMPeG

./configure --x86asmexe=/home/mahmood/yasm-1.3.0/bin/yasm --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp \
--extra-cflags=-I"~/cuda-10.1.168/include,~/nv_codec_headers/include/ffnvcodec/" \
--extra-ldflags=-L"~/cuda-10.1.168/lib64/,~/nv_codec_headers/lib/pkgconfig/"

我在无法找到 npp.h 的 config.log 中收到此错误。请注意,gcc 命令提供了额外的包含文件夹,并且 npp.h 实际上存在于我提供的路径中。

gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
-D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -DPIC -I~/cuda-10.1.168/include,~/nv_codec_headers/include/ffnvcodec/ \
-std=c11 -fomit-frame-pointer -fPIC -pthread -c \
-o /tmp/ffconf.dk4hdPMF/test.o /tmp/ffconf.dk4hdPMF/test.c
/tmp/ffconf.dk4hdPMF/test.c:1:10: fatal error: npp.h: No such file or directory
 #include <npp.h>
          ^~~~~~~

npp.h 在这里

$ ls -l ~/cuda-10.1.168/include/npp.h
-rw-r--r-- 1 mahmood mahmood 2864 Dec 16 18:24 /home/mahmood/cuda-10.1.168/include/npp.h

我该如何解决这个问题?

【问题讨论】:

  • 我不太确定 -I 是否可以使用逗号分隔的目录

标签: gcc makefile configure


【解决方案1】:

这不是真正的 makefile 问题。

你有两个问题。首先,您不能通过用逗号分隔多个路径来将多个路径传递给-I 选项,例如-I&lt;dir1&gt;,&lt;dir2&gt;。您必须使用多个-I 选项,例如-I&lt;dir1&gt; -I&lt;dir2&gt;

其次,~ 是一个特殊字符在调用编译器之前由 shell 扩展,并且 shell 不会在命令行的任何地方扩展 ~。例如,如果您运行echo foo~bar 甚至echo foo~/bar,shell 将不会将~ 视为对您的主目录的引用并且不会扩展它。仅当它是单词中的 first 字符时才会被特殊处理。您需要使用$HOME 环境变量,否则您需要在-I 和目录之间添加一个空格,以便~ 是单词中的第一个字符:-I$HOME/&lt;dir1&gt; -I$HOME/&lt;dir2&gt;-I ~/&lt;dir1&gt; -I ~/&lt;dir2&gt;

如果您使用 $HOME,请记住您需要在 make recipe 中转义 $

【讨论】:

    猜你喜欢
    • 2012-12-16
    • 2018-01-19
    • 2014-10-21
    • 1970-01-01
    • 2017-12-07
    • 2021-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多