Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error regarding libjpegturbo.a on Ubuntu 14.04 #36

Closed
floe opened this issue Aug 7, 2014 · 30 comments
Closed

Build error regarding libjpegturbo.a on Ubuntu 14.04 #36

floe opened this issue Aug 7, 2014 · 30 comments
Labels
Milestone

Comments

@floe
Copy link
Contributor

floe commented Aug 7, 2014

On current Ubuntu 14.04 amd64, even with all dependencies installed, you can get the following build error:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libturbojpeg.a(libturbojpeg_la-turbojpeg.o): relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libturbojpeg.a: error adding symbols: Bad value

This is due to a bug in the libturbojpeg package. A one-line fix is to execute:

sudo ln -s /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.0.0 /usr/lib/x86_64-linux-gnu/libturbojpeg.so
@floe
Copy link
Contributor Author

floe commented Aug 7, 2014

Note that this isn't a bug in libfreenect2, but I'm posting the issue/fix here for reference.

@rocha
Copy link

rocha commented Nov 6, 2014

Mmm, I made the symbolic link and still have the error. Any pointers? Thanks.

@floe
Copy link
Contributor Author

floe commented Nov 18, 2014

Could you post the exact build error?

@fstafforini
Copy link

This confirmed bug could be the culprit, apparently there is a symlink missing.

@sketchc89
Copy link

I've installed all dependencies and added the symbolic link with

sudo ln -s /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.0.0 /usr/lib/x86_64-linux-gnu/libturbojpeg.so

but the make step still fails on Ubuntu 14.04

Linking CXX shared library lib/libfreenect2.so
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libturbojpeg.a(libturbojpeg_la-turbojpeg.o): relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libturbojpeg.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libfreenect2.so] Error 1
make[1]: *** [CMakeFiles/freenect2.dir/all] Error 2
make: *** [all] Error 2

@xlz
Copy link
Member

xlz commented Jun 9, 2015

We have created a workaround that does not requires creating symlink under /usr. Please test latest master.

@sketchc89
Copy link

The workaround worked using the latest master (commit 42da6d8 ) and I have Protonect up and running.
I upgraded Kernel to 3.16 per the instructions using:
sudo apt-get install linux-image-generic-lts-utopic
Thanks for the great work guys.

@SebastianVarma
Copy link

I installed the latest commit, but it still returns the same error.

@floe
Copy link
Contributor Author

floe commented Jun 9, 2015

@SebastianVarma can you post the output of ls -la /usr/lib/*/libturbojpeg*?

@SebastianVarma
Copy link

@floe I will do so tomorrow morning when I will be in front of my computer. Thank you for helping.

@SebastianVarma
Copy link

@floe The output is as follows:

-rw-r--r-- 1 root root 499438 Dec 19 2013 /usr/lib/x86_64-linux-gnu/libturbojpeg.a
lrwxrwxrwx 1 root root 47 Jun 9 13:42 /usr/lib/x86_64-linux-gnu/libturbojpeg.so -> /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.0.0
lrwxrwxrwx 1 root root 21 Dec 19 2013 /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0 -> libturbojpeg.so.0.0.0
-rw-r--r-- 1 root root 301472 Dec 19 2013 /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.0.0

@floe
Copy link
Contributor Author

floe commented Jun 10, 2015

This does look correct... can you please open a new issue and post the exact build error?

@neorobo
Copy link

neorobo commented Jun 11, 2015

Just wanted to chime in that I have this exact same issue, with the same output from ls -la /usr/lib/*/libturbojpeg*

@xlz
Copy link
Member

xlz commented Jun 11, 2015

@neorobo
Can not reproduce.

I also have this same output from ls -la /usr/lib/*/libturbojpeg* and my build works fine.

Can you post the log of your cmake ..?

(Should have Found TurboJPEG: /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0)

@floe
Copy link
Contributor Author

floe commented Jun 11, 2015

@neorobo Duplicate issue #286 was fixed by a fresh clone of master and re-run of cmake, maybe try that first?

@neorobo
Copy link

neorobo commented Jun 12, 2015

@xlz Based on your suggestion I checked CMakeCache.txt. It was pointing to the static library. I edited it to point to .so.0 as you suggested should be the case and protonect was succesfully installed.

@xlz
Copy link
Member

xlz commented Jun 17, 2015

I checked again. On Ubuntu 14.04, /usr/lib/x86_64-linux-gnu/libturbojpeg.a is provided by libjpeg-turbo8-dev, but /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0 is provided by libturbojpeg. If the users follow the documentation, they will only install libjpeg-turbo8-dev, and can not find libturbojpeg.so.0. The docs need fixing.

I was also confused by this in several previous comments.

@sketchc89
Copy link

I've compiled libfreenect2 quite a few times in the past couple weeks and I don't know if I've ever gotten it to work on the first time through following the order in the documentation.
After failing, I remove it entirely from my system, reclone it, run ./depends/install_ubuntu.sh, cmake CMakeLists.txt, make && sudo make install it builds almost every time. Have repeated this on Ubuntu 14.04 32-bit & 64-bit and 15.04.

@floe
Copy link
Contributor Author

floe commented Jun 17, 2015

I'm hoping that this is finally fixed for Debian and Ubuntu with latest master (both CMakeLists.txt and install_ubuntu.sh). I'll close it for now, but please comment if this is still a problem.

@Pincello
Copy link

I had the same Problem and had to delete /libfreenect2 and clone it again from Git. Now it works.

@jamesbellaero
Copy link

Fixed it with ./depends/install_ubuntu.sh and then installing libturbojpeg with apt-get.

@YandanYang
Copy link

I met the same problem, and I refer to this page : http://www.jetsonhacks.com/2015/02/26/install-kinect-v2-using-libfreenect2-on-nvidia-jetson-tk1/
Fixed with :sudo apt-get install -y build-essential libturbojpeg libtool autoconf libudev-dev cmake mesa-common-dev freeglut3-dev libxrandr-dev doxygen libxi-dev libjpeg-turbo8-dev

@rayjs
Copy link

rayjs commented Jan 3, 2018

On Ubuntu 16, I had the same issue. Here is how it got fixed. Hope it helps
Step 1:
Install libjpeg-turbo8-dev
Step 2:
The libturbojpeg.so file was missing so I had to create a sym-link.
I ran sudo ln -s /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0 /usr/lib/x86_64-linux-gnu/libturbojpeg.so
Step 3:
Deleted the build directory and ran cmake again.

@xlz
Copy link
Member

xlz commented Jan 3, 2018

The above suggestion is wrong.

The issue was fixed. Follow the instructions in README, and no workaround is necessary.

@paulnord
Copy link

paulnord commented Jan 5, 2018

@xlz can you point me to the README to which you refer?

@xlz
Copy link
Member

xlz commented Jan 6, 2018

(Ubuntu 14.04 and newer) sudo apt-get install libturbojpeg libjpeg-turbo8-dev

According to https://packages.ubuntu.com/trusty/amd64/libturbojpeg/filelist, libturbojpeg provides /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0. Our CMake was specifically made to detect libturbojpeg.so.0 in the absence of libturbojpeg.so.

@Smilels
Copy link

Smilels commented Mar 28, 2018

@rayjs your solution also works for me in Ubuntu 16.04. Thanks a lot.

@hsandt
Copy link

hsandt commented Sep 9, 2018

I know the issue is closed, but in case someone still has it after trying the other suggestions:

We had a very similar issue on HaxeFoundation/hashlink#147 and our solution was to follow the error message on -fPIC and rebuild libjpeg-turbo ourselves with Position-Independent Code. It should be the default when building with cmake/make, but apparently was not done so for the Ubuntu package.

@xlz
Copy link
Member

xlz commented Sep 10, 2018

@hsandt It's generally better to link shared libraries not static objects. In this case it's better to link libturbojpeg.so not libturbojpeg.a. This is also the reason libturbojpeg.a is not built with -fPIC, because it's not meant for building shared libraries. Either you go all shared or all static.

@hsandt
Copy link

hsandt commented Sep 11, 2018

Ah! I missed that point. I'll go all dynamic next time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests