Getting started: Samples

Added by Trevor Allen 4 months ago

I'm new to C++ and to exiv so apologies for a very basic question.

I've installed exiv2 as per instructions and loaded exifprint sample, but I cannot build the sample application, as it complains about an undefined reference on the

=== Build: Debug in t5 (compiler: GNU GCC Compiler) ===
obj/Debug/main.o||In function `main':
undefined reference to `Exiv2::ImageFactory::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)'
error: ld returned 1 exit status
=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===

It must be something in my IDE set up or install. Code is:

#include <exiv2/exiv2.hpp>
#include <iostream>
#include <cassert>
using namespace std;
int main(int argc, char* const argv[])
    string file(argv[1]);
    Exiv2::Image::AutoPtr greg = Exiv2::ImageFactory::open( file,true);
    cout << "Hello world!" << endl;
    return 0;
Can someone give me a pointer what to look for.

Regards Trev

Replies (2)

RE: Getting started: Samples - Added by Robin Mills 4 months ago

Easy one, Trev. You have to link the exiv2 library.

$ g++ foo.cpp -o foo -lexiv2

RE: Getting started: Samples - Added by Trevor Allen 4 months ago

Robin: Many thanks. I'm not used to these IDEs in this language. Anyway, problem solved. Again, thanks for speedy response.


Redmine Appliance - Powered by TurnKey Linux