2012-11-26 39 views
1

我已經使用了libexif C庫的程序在這裏找到http://libexif.sourceforge.net/Libexif未定義的引用錯誤

我安裝了庫,它是在位於/ usr/include中/ libexif

我包括這在頂部程序

#include <libexif/exif-data.h> 
#include <libexif/exif-content.h> 
#include <libexif/exif-entry.h> 

我的編譯聲明:

`gcc -o test test.c` 

當我編譯我得到這些錯誤

/tmp/ccUUWpcw.o: In function `show_tag': 
test.c:(.text+0x91): undefined reference to `exif_content_get_entry' 
test.c:(.text+0xc0): undefined reference to `exif_entry_get_value' 
test.c:(.text+0xef): undefined reference to `exif_tag_get_name_in_ifd' 
/tmp/ccUUWpcw.o: In function `main': 
test.c:(.text+0x179): undefined reference to `exif_data_new_from_file' 
test.c:(.text+0x1cd): undefined reference to `exif_data_unref' 
collect2: ld returned 1 exit status 

程序認爲讀取包含文件罰款,但由於某種原因不知道這些功能。我安裝庫時所做的所有操作都是將其解壓縮./configure,make & & make install

我需要在其他地方或類似的地方引用此庫嗎?

感謝您的幫助!

+0

[?爲什麼即使我有正確的頭文件,我得到「未定義的引用」錯誤](http://stackoverflow.com/questions/4121090/why-do-i-get-undefined-reference-errors-even-when-i-include-the-right-header -f) – netcoder

回答

5

是你需要鏈接庫:

gcc test.c -o test -lexif 
+0

啊,謝謝我這麼認爲。這可能是一個noob問題,但您是如何知道鏈接名稱「-lexif」的。我很確定我需要鏈接,我只是不確定鏈接名稱是什麼。 – Irlanco

+2

@Irlanco當您使用'-lNAME'時,gcc搜索'libNAME'並將其鏈接 – iabdalkader