Problems with static jpeg library

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems with static jpeg library

world
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?
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Problems with static jpeg library

Rolf Eike Beer
[hidden email] wrote:
> 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

You need to make sure that this compile includes -fPIC in the compileflags of
libjpeg.

> 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

As said here.

Eike
--
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problems with static jpeg library

world
Hi,

thank you for your reply. I could solve the problem. The part I didn't
knew was that static libraries also needed to be compiled with -fPIC.
I've found a good summary of this topic at
https://lists.debian.org/debian-devel/2016/05/msg00309.html
I want to share it for those, who also stumble upon this problem.


On 2018-09-11 13:47, Rolf Eike Beer wrote:

> [hidden email] wrote:
>> 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
>
> You need to make sure that this compile includes -fPIC in the
> compileflags of
> libjpeg.
>
>> 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
>
> As said here.
>
> Eike
> --

--
German DevPos site: https://www.masterdevops.eu
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Problems with static jpeg library

Eric Noulard


Le mar. 11 sept. 2018 à 16:10, <[hidden email]> a écrit :
Hi,

thank you for your reply. I could solve the problem. The part I didn't
knew was that static libraries also needed to be compiled with -fPIC.
I've found a good summary of this topic at
https://lists.debian.org/debian-devel/2016/05/msg00309.html
I want to share it for those, who also stumble upon this problem.


And for project using CMake as build system one can use, POSITION_INDEPENDENT_CODE
target property:
or globally:

in order to enable such flags.




On 2018-09-11 13:47, Rolf Eike Beer wrote:
> [hidden email] wrote:
>> 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
>
> You need to make sure that this compile includes -fPIC in the
> compileflags of
> libjpeg.
>
>> 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
>
> As said here.
>
> Eike
> --

--
German DevPos site: https://www.masterdevops.eu
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake


--
Eric

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake