probably this is a trivial newbie question, however, I can't figure out how to solve it.
I'm trying to build a test program using libtiff
(test program copied from here). I've downloaded the static library libtiff.lib
as well as the required header file tiffio.h
. When I compile the main c function with no problem I have a main.o
file. When I try to link main.o with libtiff
using this command
gcc -g -Wall -o test.exe ./libtiff.lib ./test.o
I have this error:
undefined reference to `_imp__TIFFOpen'
I've looked into the lib file with nm -A libtiff.lib
command and I can find this line
libtiff.lib:libtiff3.dll:00000000 I __imp__TIFFOpen
but it has 2 leading underscores instead of 1 as required by the linker. I'm using mingw on Windows 7 and all the required files are in the same directory.
No clue how to link with no errors.
Thanks in advance.
As suggested in the the comments, it was sufficient to invert the order of objects passed as arguments:
gcc -g -Wall -o test.exe ./test.o ./libtiff.lib