Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incompatible openCV and libtiff libs on OSX

I am working with a pyramided tiff file. However, OpenCV does not support pyramided tiff files and so I am attempting to use libtiff 4.0.3 to extract the layer/directory/resolution that I need and then pass it to OpenCV for processing.

I include as follows:

#include "tiffio.h"
#include "opencv2/highgui/highgui.hpp"

But doing so gives me the following in types_c.h:

typedef int64_t int64;
Typedef redefinition with different types ('int64_t(aka 'long long') vs 'long')

It appears int64_t is being defined differently by each of the 2 libraries.

I have used homebrew to install both libraries and so I'd prefer not to have to edit those libraries since that will cause problems with getting updates, being a pain for future developers on my team, etc.

Is there a way I can use both libraries without modifiying them?

like image 981
Rick Smith Avatar asked Feb 24 '15 18:02

Rick Smith


1 Answers

Since both libraries "polute" global namespace with definitions (and you see, how important is to have proper namespaces in third party libraries) there is no way to include both to the global namespace. You have include one of them wrapped in an user defined namespace like this:

namespace libtiff {
    #include "tiffio.h"
}
#include "opencv2/highgui/highgui.hpp"

That will solve compilation issue although I am not sure if this solution is convenient for use, as you will have to use libtiff members using libtif:: prefix,

like image 137
marol Avatar answered Nov 15 '22 01:11

marol