2012-01-05 21 views
0

問題:我需要鏈接以獲取/asm-generic/cmpxchg-local.h可訪問的內容?無法編譯針對asm-generic/cmpxchg-local.h


信息:

我知道我錯過了一些鏈接在哪裏,但我不能找出正確的命令。鏈接編譯器時,我不太好。我試圖編譯一個簡單的程序來測試我對cmpxchg-local.h的訪問。我看到有人將其作爲「asm-generic/cmpxchg-local.h」來執行,但這也不起作用。我跑定位,並發現這裏的文件:

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

所以我試圖把整個文件路徑爲我有,像這樣:

#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 

回答

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路徑才能使用該頭文件進行編譯(但是,這可能不是您想要執行的操作)。