I have a /usr/lib/libtiff.so.3 as a symbolic link to /usr/lib/i386-linux-gnu/libtiff.so.4.3.3. I need to use some data structures declared in a file called tiffio.h which is part of the tiff library mentioned above to handle .tif image files in my c++ source. The c++ source mycode.cpp is as follows:
#include <iostream>
#include <tiffio.h>
using namespace std;
int main(int argc, char *argv[]) {
if (argc < 2) {
cout << "USAGE: mycode <inputimage> <outputimage> "<< endl;
return (-1);
}
return 0;
}
I compile the source with g++ in the following way:
g++ -Wall -L/usr/lib mycode.cpp -ltiff -o mycode
I get the following error:
fatal error: tiffio: No such file or directory. compilation terminated.
I have tried with using the following options for including the tiffio.h but error persists.
<tiffio>, "tiffio.h", extern "C" {"tiffio.h"} and extern "C" {<tiffio.h>}
Am I doing anything fundamentally wrong? How can I compile and link the source?
It depends on where your tiffio.h file is.
If it is at a place where your g++ usually looks for header files you can include it using
If it is in the same directory as your .cpp File you can include it using
If it is somewhere else you have two possibilities:
Either add its location to your search path by adding -I pathToLocation to your g++ call
Or include it using
The directorys normaly searched by the g++ are
If the g++ can’t find the library itself (the .so file) you can add it (with path) directly to your g++ call.