3

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;
}
Theolodis
  • 4,977
  • 3
  • 34
  • 53
nadeem
  • 215
  • 2
  • 10

2 Answers2

14

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.

Community
  • 1
  • 1
Bily
  • 751
  • 6
  • 15
2

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.

unwind
  • 391,730
  • 64
  • 469
  • 606