clinuxlibexif

Libexif undefined reference error


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!


Solution

  • yes you need to link the library:

    gcc test.c -o test -lexif