1

I have a program that uses the libexif C library found here http://libexif.sourceforge.net/

I installed the library and it is found at /usr/include/libexif

I include these at the top of the program

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

My compile statement:

`gcc -o test test.c` 

When I compile I get these errors

/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

The program sees to read the included files fine, but for some reason does not know these functions. All I did when I installed the library was unzip it, ./configure, make && make install

Do I need to reference this library elsewhere or something similar?

Thanks for any help!

iabdalkader
  • 17,009
  • 4
  • 47
  • 74
Irlanco
  • 769
  • 1
  • 8
  • 22
  • [Why do I get “undefined reference” errors even when I include the right header files?](http://stackoverflow.com/questions/4121090/why-do-i-get-undefined-reference-errors-even-when-i-include-the-right-header-f) – netcoder Nov 26 '12 at 21:55

1 Answers1

5

yes you need to link the library:

gcc test.c -o test -lexif
iabdalkader
  • 17,009
  • 4
  • 47
  • 74
  • Ah thanks I thought so. This may be a noob question, but how did you know the link name "-lexif". I was pretty sure I needed to link I just wasn't sure what the link name would be. – Irlanco Nov 26 '12 at 22:03
  • 2
    @Irlanco when you use `-lNAME` gcc searches for `libNAME` and links it – iabdalkader Nov 27 '12 at 19:34