0

Libtiff is a C library, but I want to use it with a C++ project in Qt Creator. Does anyone know how to do this? I get compile time errors when I try to use the C library, so I'm not sure what to do.

The compile time error I get is:

c:\libtiff\libtiff\tiff.h:69: error: C4430: missing type specifier - int assumed. Note: C++ does not support default-int

for the line: typedef TIFF_INT8_T int8;

plus a bunch of more similar errors. Someone please help.

Danny Ahdoot
  • 19
  • 1
  • 9
  • 1
    Instead of trying to compile libtiff as C++, compile it as C, and link it to your C++ code. – Jerry Coffin Dec 20 '12 at 18:28
  • not exactly sure how to do that. can you guide me through it? – Danny Ahdoot Dec 20 '12 at 18:44
  • You need to configure libtiff for building on Windows with the C compiler that matches the C++ compiler you are using. You have to use a C compiler to build libTIFF. To use libTIFF you can use a C++ or C compiler. – Damian Dixon Jul 24 '17 at 17:46

1 Answers1

1

You need to wrap the include statements on an extern C block --

extern "C"{
#include "tiff.h"
}

This tells the compiler to view those files as C, not C++, so you should not get strict C++ errors.

iagreen
  • 31,470
  • 8
  • 76
  • 90
  • Is it because there is no C compiler available in Qt Creator? – Danny Ahdoot Dec 20 '12 at 19:01
  • no sure about Qt Creator, just C/C++ in general. It could also be a problem in your tiffconf.h. Did you install and complie libtiff yourself? It might not be configured properly for your system, specifically the HAVE_INT8/16/32 #defs – iagreen Dec 20 '12 at 19:15
  • i didn't even compile it. i just unzipped it into a folder and set the include path in my Qt project file. How do I "compile" a library? – Danny Ahdoot Dec 21 '12 at 00:14