无法针对asm-generic / cmpxchg-local.h进行编译

时间:2012-01-05 02:10:43

标签: compiler-construction linker

问题:我需要链接什么才能获得/asm-generic/cmpxchg-local.h?


的信息:

我知道我错过了一些链接,但我找不到合适的命令。在链接编译器方面我不是很好。我尝试编译一个简单的程序来测试我对cmpxchg-local.h的访问。我看到有人把它作为“asm-generic / cmpxchg-local.h”来做,但这也不起作用。我运行了locate,它在这里找到了文件:

/usr/src/linux-headers-3.0.0-14/include/asm-generic/cmpxchg-local.h

所以我尝试将整个文件路径放入我的include中,如下所示:

#include </usr/src/linux-headers-3.0.0-14/include/asm-generic/cmpxchg-local.h>
#include <stdio>

int main()
{
    printf("Hello world!\n");
}

然后继续告诉我它找不到linux / irqflags.h。显然有些链接在哪里缺少,有什么建议吗?

编译:

 gcc cmpandswp.c -o test -lm

1 个答案:

答案 0 :(得分:0)

您可能不希望在用户程序中包含内核头...但您要查找的是以下GCC标志(来自手册页):

   -I dir
       Add the directory dir to the list of directories to be searched for header files.  Directories named by -I are searched before the standard system include directories.  If the
       directory dir is a standard system include directory, the option is ignored to ensure that the default search order for system directories and the special treatment of system
       headers are not defeated .  If dir begins with "=", then the "=" will be replaced by the sysroot prefix; see --sysroot and -isysroot.

这样,您可以执行gcc -I/usr/src/linux-headers-3.0.0-14/include <objects>之类的操作,并将包含更改为#include <asm-generic/cmpxchg-local.h>。您可能需要添加更多-I路径以使用该头文件进行编译(但同样,这可能不是您想要做的)。