Installing Torch with static libjpeg and libpng

317 views
Skip to first unread message

Ken Graham

unread,
Sep 17, 2016, 8:11:48 PM9/17/16
to torch7
I need to install Torch with a static png and jpeg libs, both of which were built with -fPIC. When the Torch install gets to the image package, it fails, telling me that the static libs needed to be recompiled with -fPIC. 

This is on AWS Linux, btw. I want to include static versions of libpng and libjpeg because I will need to port the installation to CentOS and RHEL and will not be able to install any dependencies. My static libs are in /usr/local/lib.

Any ideas? Do I need to change something in the image package's rockspec or CMakeLists.txt? Nothing I've tried has made a difference.

Error message is below:

cmake -E make_directory build && cd build && cmake .. -DLUALIB= -DLUA_INCDIR="/mnt/ken/torch/install/include" -DLUA_LIBDIR="/mnt/ken/torch/install/lib"  -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/mnt/ken/torch/install/bin/.." -DCMAKE_INSTALL_PREFIX="/mnt/ken/torch/install/lib/luarocks/rocks/image/1.1.alpha-0" && make

-- Found Torch7 in /mnt/ken/torch/install
-- Compiling with OpenMP support
WARNING: Could not find JPEG libraries, JPEG wrapper will not be installed
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/ken/torch/pkg/image/build
[ 33%] Building C object CMakeFiles/image.dir/image.c.o
Linking C shared module libimage.so
[ 33%] Built target image
Scanning dependencies of target png
[ 66%] Building C object CMakeFiles/png.dir/png.c.o
Linking C shared module libpng.so
/usr/bin/ld: /usr/local/lib/libpng.a(png.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpng.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [libpng.so] Error 1
make[1]: *** [CMakeFiles/png.dir/all] Error 2
make: *** [all] Error 2

Error: Build error: Failed building.

soumith

unread,
Sep 17, 2016, 8:23:37 PM9/17/16
to torch7 on behalf of Ken Graham
usually the error message means that they were NOT built with -fPIC. Are you sure libpng.a was built with -fPIC?
I've been doing some static linking recently, and as soon as I recompiled my static libs with -fPIC, things worked okay.

--
You received this message because you are subscribed to the Google Groups "torch7" group.
To unsubscribe from this group and stop receiving emails from it, send an email to torch7+unsubscribe@googlegroups.com.
To post to this group, send email to tor...@googlegroups.com.
Visit this group at https://groups.google.com/group/torch7.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages