[CMake] Problems with static jpeg library

world at masterdevops.eu world at masterdevops.eu
Tue Sep 11 05:59:34 EDT 2018


Hi,

I am trying to compile the project libgd 
(https://github.com/libgd/libgd) with the option ENABLE_JPEG enabled.

I.e. first I downloaded the source code of libjpeg-turbo from 
https://sourceforge.net/projects/libjpeg-turbo/files/2.0.0/, compiled it 
and afterwards I started to compile libgd with this command:

> cmake -G "Unix Makefiles" \
         -DENABLE_JPEG=ON \
         -DJPEG_INCLUDE_DIR="../${JPEG_DIR}" \
         -DJPEG_LIBRARY="../${JPEG_DIR}/libjpeg.a" \
         .

You can check the CMakeLists.txt in that project 
(https://github.com/libgd/libgd/blob/master/CMakeLists.txt)

As you can see, I want to compile libgd with a static libjpeg library. 
But I get several errors like this one:

> /usr/bin/ld: .../libjpeg-turbo-2.0.0/libjpeg.a(jcmainct.c.o): 
> relocation R_X86_64_32S against `.text' can not be used when making a 
> shared object; recompile with -fPIC

When I use the shared library version of libjpeg, i.e. I try to compile 
libgd with the shared version of libjpeg, i.e.

> cmake -G "Unix Makefiles" \
         -DENABLE_JPEG=ON \
         -DJPEG_INCLUDE_DIR="../${JPEG_DIR}" \
         -DJPEG_LIBRARY="../${JPEG_DIR}/libjpeg.so" \
         .

then there is no error.

Is this a problem of CMake or a problem of the CMakeLists.txt of the 
libgd project?


More information about the CMake mailing list