I am following this example. However, I want to compile a static binary for the given toy example code. Normally, I use -static
during compilation but here it gives an error message.
The compile command which works fine:
g++ freeimagetest.cpp -o freeimagetest -lfreeimageplus
The compile command which does not works fine:
g++ freeimagetest.cpp -o freeimagetest -lfreeimageplus -static
The last few lines of the error message:
In function `ZIPPreDecode':
(.text+0x6f8): undefined reference to `inflateReset'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libfreeimageplus.a(tif_zip.o): In function `ZIPSetupDecode':
(.text+0x783): undefined reference to `inflateInit_'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib/libfreeimageplus.a(tif_zip.o): In function `ZIPSetupDecode':
(.text+0x7b4): undefined reference to `deflateEnd'
collect2: ld returned 1 exit status
So how could this be done/fixed?
EDIT: I could not see how the attached link solves my problem. Apparently, it looks that, due to the error messages, however, there is some problem in the way I am trying to compile it statically. I could not find the right way to do so. I think the error message is missleading - It just ends with these lines (where these lines are less than one percent of the all message). Anyone who has done it can better answer. If you think your answer is more than just an educated guess, i would request you to please give it a try before answering. It will only take a couple minutes if you follow the attached link. Moreover, I have tagged C
also because it is same for C language programs as well.