Reputation: 225
I install libjpeg-dev and all files are in the include folder
/usr/include/jerror.h
/usr/include/jmorecfg.h
/usr/include/jpegint.h
/usr/include/jpeglib.h
/usr/include/turbojpeg.h
/usr/include/x86_64-linux-gnu
/usr/include/x86_64-linux-gnu/jconfig.h
And when I try this simple code to decompress a jpeg image I got the error as in title.
here is the code:
#include <stdlib.h>
#include <stdio.h>
#include <jpeglib.h>
int main(void){
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
return 0;
}
Upvotes: 3
Views: 7665
Reputation: 801
The same problem has buged me for about two days!
my solution is use:
gcc your_code.c -ljpeg
instead of:
gcc -ljpeg your_code.c
to compile your code.
here is the explanation:Why does the order in which libraries are linked sometimes cause errors in GCC?
hope this will help.
Upvotes: 15
Reputation: 399703
That sounds like a linking error.
You are probably not linking to the library code; just including the header is not enough, that's not how C works.
Add something like -ljpeg
last on your command line.
Upvotes: 3