I have downloaded and setup the libjpeg package for Dev C++. I have ensured it is the most recent version. Then I have added the respective libraries in Dev C++:
Tools > Compiler > Directories I also have the compiler set to TDM-GCC 4.8.1 64-bit Release
What I have added: Bin: Dev-Cpp\bin
Libraries: Dev-Cpp\lib
C Includes: Dev-Cpp\include
C++ Includes: Dev-Cpp\include
I have also add a link in the project parameters Linker: Dev-Cpp/lib/libjpeg.a
My code:
#include <iostream>
#include <cstdlib>
#include <cstdio>
extern "C" {
#include <jpeglib.h>
#include <jerror.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;
}
I am getting the errors:
D:\FP\main.o In function `main':
14 D:\FP\main.cpp undefined reference to `jpeg_std_error'
15 D:\FP\main.cpp undefined reference to `jpeg_CreateDecompress'
...
I have looked at this post which seems relevant but I don't know how to apply it to C++. In that forum I've linked to, the problem was somehow solved when a commenter told the OP to specify which compiler was used for the library. I.e. GCC for C and G++ for C++. I am getting the same errors as he did, so I think it is related, but I'm not sure how to reconfigure it.
I've looked at the post:
What is an undefined reference/unresolved external symbol error and how do I fix it?
But this does not answer my question as this is a general answer for undefined references.