5

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?

Rick Smith
  • 9,031
  • 15
  • 81
  • 85

1 Answers1

6

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,

marol
  • 4,034
  • 3
  • 22
  • 31
  • I didn't know you could namespace includes like that, this is exactly what I was looking for. The libtif:: prefix isn't wonderful, but it's so much better than the alternatives it's a small price to pay. Thanks! – Rick Smith Feb 24 '15 at 20:57
  • I think you can put `using namespace libtiff;` after the includes, and not have any conflicts unless you use the `int64` type in any subsequent code. – Thomas Jun 14 '17 at 14:55