Project

General

Profile

Getting started: Samples

Added by Trevor Allen over 4 years ago

Hi,
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
ImageFactory::open.

=== Build: Debug in t5 (compiler: GNU GCC Compiler) ===
obj/Debug/main.o||In function `main':
/home/trevor/workspace/w4/t5/main.cpp
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 over 4 years 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 over 4 years ago

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

    (1-2/2)