failed to build shared libraries with boost 1.48 - c++

I am trying to build boost 1.48 on an amd64 machine however shared libraries are not built due to a relocation error. Which I assumed due to -fPIC and that is the reason however could not fix that.
More specifically, here is what I get, with the boost from the trunk,
$ ./b2
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a(codecvt.o): relocation R_X86_64_32S against `vtable for std::codecvt<wchar_t, char, __mbstate_t>' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
I also tried these
./bjam -d2
./bjam address-model=64 cxxflags=-fPIC
as explained/discussed here
http://boost.2283326.n4.nabble.com/fPIC-option-for-boost-td3176976.html
however did not help. I could not manage to build the shared libraries that I configure with boostrap.sh.

I had a similar issue trying to build mosh-1.2.2 on a standard debian squeeze installation. The following worked for me:
# cd /usr/lib/gcc/x86_64-linux-gnu/4.4.5
# rm libstdc++.so
# ln -s ../../../x86_64-linux-gnu/libstdc++.so.6 libstdc++.so
To explain in a more detail, the existing symlink was pointing to a non-existent file:
# cd /usr/lib/gcc/x86_64-linux-gnu/4.4.5
# ls -l libstdc++.so
..
lrwxrwxrwx 1 root root 23 May 3 2011 libstdc++.so -> ../../../libstdc++.so.6
..
I located the correct file location
# dpkg -S 'libstdc'
..
libstdc++6: /usr/lib/x86_64-linux-gnu/libstdc++.so.6
..
Then repaired the symlink as described in the first code segment.
The error I was getting during compiling was:
make[3]: *** [mosh-client] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a(functexcept.o): relocation R_X86_64_32 against `std::bad_typeid::~bad_typeid()' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.4.5/libstdc++.a: could not read symbols: Bad value
No idea how this particular debian squeeze server broke. I've been compiling on other squeeze systems with no trouble.

Related

static link glibc & boost_python36 for python extension

I'm writting a extension for pyton3.6. My develop machine run gcc7.3, and production environment os is centos6. I use the following link option to static link glibc to avoid upgrade glibc2.12 to glibc2.14+.
-Wl,-Bdynamic -lpython3.6m -Wl,-Bstatic -lboost_python36
But get error:
[ 50%] Linking CXX shared module helloext.so
/usr/bin/x86_64-linux-gnu-ld: cannot find -lgcc_s
/usr/bin/x86_64-linux-gnu-ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status
CMakeFiles/helloext.dir/build.make:94: recipe for target 'helloext.so' failed
make[2]: *** [helloext.so] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/helloext.dir/all' failed
make[1]: *** [CMakeFiles/helloext.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Anyone known? Thanks.
The reason might be although libgcc is present it may not be in the paths known to ldconfig. Check this by doing
/sbin/ldconfig -p | grep libgcc
Does the output show that there is a link to libgcc corresponds to paths that you have listed above?
A work around for you may be to add the link to the relevant library to your compile command e.g.
... -L /usr/lib/gcc/x86_64-linux-gnu/4.6/
Another may be to create a symbolic link to the library yourself.
ln -s /usr/lib/gcc/x86_64-linux-gnu/4.6/libgcc_s.so /usr/lib/gcc/libgcc_s.so
You have not informed us about Linux you are using. Update 4.6 with the proper number in the command above.

I am trying to install gameplay game engine ,But encountered an error

I am trying to install gameplay game engine on my ubuntuMATE 17.10, following steps here. After cmake I type make and get errors below:
/usr/bin/ld: /home/samdare/Downloads/extracts/GamePlay-master/external-deps/lib/linux/x86_64/libgameplay-deps.a(btVoronoiSimplexSolver.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/samdare/Downloads/extracts/GamePlay-master/external-deps/lib/linux/x86_64/libgameplay-deps.a(SphereTriangleDetector.o): relocation R_X86_64_32S against symbol `_ZTV22SphereTriangleDetector' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/samdare/Downloads/extracts/GamePlay-master/external-deps/lib/linux/x86_64/libgameplay-deps.a(trees.o): relocation R_X86_64_32S against symbol `_length_code' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
samples/browser/CMakeFiles/sample-browser.dir/build.make:745: recipe for target 'samples/browser/sample-browser' failed
make[2]: *** [samples/browser/sample-browser] Error 1
CMakeFiles/Makefile2:235: recipe for target 'samples/browser/CMakeFiles/sample-browser.dir/all' failed
make[1]: *** [samples/browser/CMakeFiles/sample-browser.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
GamePlay : The linker in Ubuntu 16.04 - amd64 is OK with GamePlay as is.
sudo apt install g++ cmake libglu1-mesa-dev libogg-dev libopenal-dev libgtk2.0-dev curl lib32z1-dev
git clone https://github.com/gameplay3d/GamePlay.git
cd GamePlay/
./install.sh
mkdir build && cd build/ && cmake .. && make
Executable´s created :
build/samples/browser/sample-browser
build/samples/racer/sample-racer
build/samples/character/sample-character
build/samples/spaceship/sample-spaceship
The Ubuntu 16.04 files seem to work perfect with Ubuntu 17.10 - amd64. My result "build/" → gameplay-build/ was uploaded as gameplay-build_ubuntu16_amd64.tar.gz (240MB) . Can be unpacked to any location in /home/*
Link https://drive.google.com/file/d/1EIggScf8bGdbBCTMOpjbmKbQcWgs0tpv/view?usp=sharing

errors during link when building glfw in fedora 27

When i try to make the project i get :
[pepe#localhost glfw-3.2.1]$ make
....
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/7/../../../libXinerama.so when searching for -lXinerama
/usr/bin/ld: skipping incompatible //lib/libXinerama.so when searching for -lXinerama
/usr/bin/ld: skipping incompatible //usr/lib/libXinerama.so when searching for -lXinerama
/usr/bin/ld: cannot find -lXinerama
collect2: error: ld returned 1 exit status
make[2]: *** [examples/CMakeFiles/wave.dir/build.make:129: examples/wave] Error 1
make[1]: *** [CMakeFiles/Makefile2:185: examples/CMakeFiles/wave.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
I have xinerama installed but aparently there is no way to link it with make.
See all of those "skipping incompatible" messages? That is because those libraries have the wrong instruction set.
It looks to me as if it is trying to build 32 bit code against 64-bit libraries. Or vice versa.
Here is what I get on my Fedora system for a library search. You need to install the right "*-devel" package for your build type. You can't have both the i686 and x86_64 devel packages installed at the same time.
$ sudo dnf list 'libXine*'
Installed Packages
libXinerama.i686 1.1.3-9.fc27 #fedora
libXinerama.x86_64 1.1.3-9.fc27 #fedora
Available Packages
libXinerama-devel.i686 1.1.3-9.fc27 fedora
libXinerama-devel.x86_64 1.1.3-9.fc27 fedora
This will do for glfw-3.2.1 :
dnf install mesa-libGL-devel.x86_64 libXi-devel.x86_64 libXcursor-devel.x86_64 doxygen libXrandr-devel.x86_64 libXmu-devel libXinerama-devel.x86_64
cd glfw-3.2.1/
mkdir build
cd build/
cmake ../
make

compilation of Qt 5 fails under make in debian64

I tried to make qt 5.4.1 with openSsl configuration but i got some errors during make it.
I configured it as bellow :
OPENSSL_LIBS='-L/usr/local/ssl/lib -lssl -lcrypto' ./configure -prefix $PWD/qtbase -opensource -debug-and-release -nomake tests -openssl-linked -I/usr/local/ssl/include -L/usr/local/ssl/lib
and then make.
the last 10 line of output is:
/usr/bin/ld: /usr/local/ssl/lib/libssl.a(s2_srvr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/local/ssl/lib/libssl.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[3]: *** [../../lib/libQt5Network.so.5.4.1] Error 1
make[3]: Leaving directory `/mnt/l/software/qt-everywhere-opensource-src-5.4.1/qtbase/src/network'
make[2]: *** [sub-network-make_first] Error 2
make[2]: Leaving directory `/mnt/l/software/qt-everywhere-opensource-src-5.4.1/qtbase/src'
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory `/mnt/l/software/qt-everywhere-opensource-src-5.4.1/qtbase'
make: *** [module-qtbase-make_first] Error 2
To link a static library into a shared library on x86_64, the static library needs to be compiled with -fPIC. You could now build OpenSSL manually with -fPIC set, but that'd be a bit of a hassle.
I'd suggest to configure Qt with -openssl instead of -openssl-linked. Then SSL won't be linked at compile time but loaded dynamically (dlopen) at runtime. It's the usual way to handle OpenSSL in Qt, also because of the incompabilities between the OpenSSL and GPL licenses.

opencv installation error ubuntu

I'm trying to install opencv to my Ubuntu 14.04 machine using the documentation provided in
http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installation
However, during the compilation process I get the following error.
Linking CXX shared library ../../lib/libopencv_videoio.so
/usr/bin/ld: /usr/local/lib/libavcodec.a(avpacket.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libavcodec.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libopencv_videoio.so.3.0.0] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2
I noticed a few posts mentioning similar errors and some solutions suggest removing the libavcodec.a from /usr/local/lib/. I'd like not to do that as I need ffmpeg libraries in the machine as well.
Could someone please help me to resolve this issue?.
Thanks
I got it to work (for installing ffmpeg) by simply reinstalling the whole thing from the beginning with all instances of $ ./configure replaced by $ ./configure --enable-shared (first make sure to delete all the folders and files including the .so files from the previous attempt).
Apparently this works because https://stackoverflow.com/a/13812368/10593190.
And this matches with #camino's comment on https://stackoverflow.com/a/19365454/10593190 and XavierStuvw's answer.
Just run these 2 lines in your terminal/environment:
pip install opencv-python==3.4.5.20
pip install opencv-contrib-python==3.4.5.20