Commit 98990e70 authored by Davis King's avatar Davis King

Changed how we #include and compile our own copy of libjpeg. This is to make

the build more robust against name conflicts from other libraries that also
statically compile libjpeg or stick incompatible versions of libjpeg's header
files into folders in the include search path.
parent 73231f43
...@@ -283,7 +283,7 @@ if (NOT TARGET dlib) ...@@ -283,7 +283,7 @@ if (NOT TARGET dlib)
set (dlib_needed_libraries ${dlib_needed_libraries} ${JPEG_LIBRARY}) set (dlib_needed_libraries ${dlib_needed_libraries} ${JPEG_LIBRARY})
else() else()
# If we can't find libjpeg then statically compile it in. # If we can't find libjpeg then statically compile it in.
include_directories(external/libjpeg) add_definitions(-DDLIB_JPEG_STATIC)
set(source_files ${source_files} set(source_files ${source_files}
external/libjpeg/jcomapi.cpp external/libjpeg/jcomapi.cpp
external/libjpeg/jdapimin.cpp external/libjpeg/jdapimin.cpp
......
...@@ -171,8 +171,13 @@ typedef unsigned int JDIMENSION; ...@@ -171,8 +171,13 @@ typedef unsigned int JDIMENSION;
#define LOCAL(type) static type #define LOCAL(type) static type
/* a function referenced thru EXTERNs: */ /* a function referenced thru EXTERNs: */
#define GLOBAL(type) type #define GLOBAL(type) type
/* a reference to a GLOBAL function: */ /*
#ifdef __cplusplus Use C linking unless we are supposed to be compiling our own copy of
libjpeg. Then let it use C++ linking so that we are less likely to get
linker name conflicts with other libraries that happen to statically include
libjpeg as well.
*/
#if defined(__cplusplus) && !defined(DLIB_JPEG_STATIC)
#define EXTERN(type) extern "C" type #define EXTERN(type) extern "C" type
#else #else
#define EXTERN(type) extern type #define EXTERN(type) extern type
......
...@@ -11,7 +11,11 @@ ...@@ -11,7 +11,11 @@
#include "../dir_nav.h" #include "../dir_nav.h"
#include "jpeg_loader.h" #include "jpeg_loader.h"
#include <stdio.h> #include <stdio.h>
#include <jpeglib.h> #ifdef DLIB_JPEG_STATIC
# include "../external/libjpeg/jpeglib.h"
#else
# include <jpeglib.h>
#endif
#include <sstream> #include <sstream>
#include <setjmp.h> #include <setjmp.h>
......
...@@ -10,7 +10,11 @@ ...@@ -10,7 +10,11 @@
#include "../pixel.h" #include "../pixel.h"
#include "save_jpeg.h" #include "save_jpeg.h"
#include <stdio.h> #include <stdio.h>
#include <jpeglib.h> #ifdef DLIB_JPEG_STATIC
# include "../external/libjpeg/jpeglib.h"
#else
# include <jpeglib.h>
#endif
#include <sstream> #include <sstream>
#include <setjmp.h> #include <setjmp.h>
#include "image_saver.h" #include "image_saver.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment