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 instructions (on Ubuntu 16.04) #147

Closed
jcward opened this issue May 14, 2018 · 6 comments
Closed

Build instructions (on Ubuntu 16.04) #147

jcward opened this issue May 14, 2018 · 6 comments

Comments

@jcward
Copy link
Contributor

jcward commented May 14, 2018

Using the apt-get from the readme, I get:

sudo apt-get install libpng16-dev libturbojpeg-dev libvorbis-dev libopenal-dev libsdl2-dev libmbedtls-dev libuv1-dev
E: Unable to locate package libturbojpeg-dev

The package is not libturbojpeg-dev, it's called libjpeg-turbo8-dev

But joy upon joy, that package's install is missing a symlink, which causes hl build to break with:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/5/../../../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/5/../../../x86_64-linux-gnu/libturbojpeg.a: error adding symbols: Bad value

(Same problem and solution is mentioned here.)

It shouldn't pick up the .a file, it should pick up the .so file. The solution is to create the missing symlink:

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

Then hl build completes successfully!

image

We could update the readme with the above, or point folks to this issue.

@andyli
Copy link
Member

andyli commented May 14, 2018

As you've found out, the libjpeg-turbo8-dev package on Ubuntu 16.04 provides a static library that was not compiled with -fPIC, which it should. The problem has been fixed in later version of the package, which was renamed to libturbojpeg-dev. The libturojpeg-dev package also provides libturbojpeg.so.

If you use Ubuntu 18.04, the current instruction is all good. For Ubuntu 16.04, I will try to figure what is the best instruction.

It shouldn't pick up the .a file, it should pick up the .so file.

I wouldn't say it should pick up which one, since there are reasons for choosing either of those. However, it should be possible to use either. It's just the 16.04 package being faulty.

@ncannasse
Copy link
Member

@jcward yes the instructions could be updated for Ubuntu 16.x, they are valid for Ubuntu 18.x

jcward added a commit to jcward/hashlink that referenced this issue May 14, 2018
Add a note about building on ubuntu 16.04 linking to HaxeFoundation#147
ncannasse pushed a commit that referenced this issue Jul 31, 2018
Add a note about building on ubuntu 16.04 linking to #147
@sonygod
Copy link

sonygod commented Aug 6, 2018

Try libpng-dev instead of libpng16-dev

@hsandt
Copy link

hsandt commented Sep 9, 2018

So, I built libjpeg-turbo myself from the GitHub repository (I picked version 2.0.0). Building is easy on Linux, you can just follow the instructions at https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/BUILDING.md. The only special requirement is that you need NASM or YASM; I don't know anything about them, so I just installed the first one:

sudo apt install nasm
cd {libjpeg-turbo-root}
mkdir build
cd build
cmake -G"Unix Makefiles" ..
make
sudo make install

If you look at the CMakeLists.txt, you'll see CMAKE_POSITION_INDEPENDENT_CODE mentioned. Basically, if you set no extra option for cmake you should get position-independent code (-fPIC) which is what we want.

Now just try to make hashlink again.

P.S.: I managed to build hashlink this way but couldn't test it due to compatibility issues with haxe (1.7 is too advanced, I need to go back to 1.1 or get a nightly build of haxe). I didn't manage to make that work, so maybe I'll post another issue later.

@ikoryakovskiy
Copy link

I had exactly same issue on Ubuntu 16.04 but with caffe. A workaround that worked for me:

sudo apt-get install libturbojpeg
sudo ln -s /usr/lib/x86_64-linux-gnu/libturbojpeg.so.0.1.0 /usr/lib/x86_64-linux-gnu/libturbojpeg.so

If I understand it correctly, the libturbojpeg package is a workaround for the -fPIC, however, for other libraries to pick a new libturbojpeg, the new link has to be created.

@jingkang99
Copy link

jingkang99 commented Jan 15, 2022

!!! for libjpeg-turbo and turbovnc, specify -fPIC when create make file !!!

cmake -G "Unix Makefiles" -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=Release ..

otherwise, link error when build turbovnc

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

No branches or pull requests

7 participants