Libexif未定义的引用错误

Irl*_*nco 1 c linux libexif

我有一个使用libexif C库的程序http://libexif.sourceforge.net/

我安装了库,它位于/ usr/include/libexif

我将这些包含在程序的顶部

#include <libexif/exif-data.h>
#include <libexif/exif-content.h>
#include <libexif/exif-entry.h>
Run Code Online (Sandbox Code Playgroud)

我的编译声明:

`gcc -o test test.c` 
Run Code Online (Sandbox Code Playgroud)

当我编译时,我得到这些错误

/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
Run Code Online (Sandbox Code Playgroud)

该程序看到很好地读取包含的文件,但由于某种原因不知道这些功能.我在安装库时所做的就是解压缩它,./ configure,make && make install

我是否需要在其他地方引用此库或类似的东西?

谢谢你的帮助!

iab*_*der 5

是的你需要链接库:

gcc test.c -o test -lexif
Run Code Online (Sandbox Code Playgroud)

  • @Irlanco当你使用`-lNAME` gcc搜索`libNAME`并链接它 (2认同)