Exiv2 with makefile

402 views Asked by At

I need to include my Exiv2 extension in my project using Makefile. I succeeded to run it directly through terminal with:

g++ -std=c++11 test.cpp -I/usr/local/include -L/usr/local/lib -lexiv2

My original Makefile (it works) important part:

COMPILER_FLAGS      =   -Wall -c -O2 -std=c++11 -fpic -o
LINKER_FLAGS        =   -shared
LINKER_DEPENDENCIES =   -lphpcpp -lopencv_core -lopencv_imgproc -lopencv_highgui \
                        -lopencv_ml -lopencv_video -lopencv_features2d \
                        -lopencv_calib3d -lopencv_objdetect \

Now I have to run a program that uses Exiv2 with a Makefile. Now I'm trying to customize the Makefile, tried

COMPILER_FLAGS      =   -Wall -c -O2 -std=c++11 -I/usr/local/include -L/usr/local/lib -fpic -o
LINKER_FLAGS        =   -shared
LINKER_DEPENDENCIES =   -lphpcpp -lopencv_core -lopencv_imgproc -lopencv_highgui \
                        -lopencv_ml -lopencv_video -lopencv_features2d \
                        -lopencv_calib3d -lopencv_objdetect \
                        -lexiv2 \

Doesn't work, output of make is:

[root@localhost psdk4]# make
g++ -Wall -c -O2 -std=c++11 -I/usr/local/include -L/usr/local/lib -fpic -o metacopy.o metacopy.cpp
metacopy.cpp: In member function ‘int Params::copyMetadata(int, char**)’:
metacopy.cpp:50:9: error: ‘AutoPtr’ is not a member of ‘Exiv2::BasicIo’
         Exiv2::BasicIo::AutoPtr fileIo(new Exiv2::FileIo(params.read_));
         ^
metacopy.cpp:50:33: error: expected ‘;’ before ‘fileIo’
         Exiv2::BasicIo::AutoPtr fileIo(new Exiv2::FileIo(params.read_));

...

It means that it doesn't find the Exiv2 methods, how to customize my Makefile?

2

There are 2 answers

4
n. m. could be an AI On

AutoPtr (which was an alias to std::auto_ptr) was removed from Exiv2 in December 2018. Note that std::auto_ptr itself was deprecated from C++ in 2011 and removed altogether in 2017.

Relevant Diff on Github

Your code that depends on AutoPtr is too old. You might be able to update it by replacing AutoPtr with UniquePtr. You will have to find all places where the former auto_ptr was copied (assigned, passed to a function and the like) and insert a call to std::move around the source of the copy. The compiler will complain about a deleted function (copy constructor or copy assignment), so it's easy to fix these places one by one. For example:

 AutoPtr some_variable = ...;
 ...
 some_function(some_variable);

needs to become

 UniquePtr some_variable = ...;
 ...
 some_function(std::move(some_variable));
0
Tomer Barak On

This worked:

readImg = Exiv2::ImageFactory::open(std::move(memIo));