compilation of Qt 5 fails under make in debian64 - c++

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.

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.

Linking library with gcc - ld: cannot find -larpack

I am installing software on a server with no root privileges. I come across the following error during installation:
make[1]: *** [hgaprec] Error 1
make[1]: Leaving directory `/seq/.../SOFTWARE/hgaprec/src'
make: *** [all-recursive] Error 1
Making install in src
make[1]: Entering directory `/seq/.../SOFTWARE/hgaprec/src'
g++ -O3 -o hgaprec ratings.o main.o log.o hgaprec.o -larpack -llapack -
lblas -lgsl -lpthread -lgslcblas
/.../software/free/Linux/redhat_6_x86_64/pkgs/gcc_5.2.0/bin/ld: cannot
find -larpack
collect2: error: ld returned 1 exit status
make[1]: *** [hgaprec] Error 1
make[1]: Leaving directory `/seq/.../SOFTWARE/hgaprec/src'
make: *** [install-recursive] Error 1
Since library arpack could not be found, I then installed it here /seq/.../SOFTWARE/hgaprec/ARPACK and found that the process generated a static file libarpack_LINUX.a. To link this static library to gcc the following command was used:
gcc -larpack -L/seq/.../SOFTWARE/hgaprec/ARPACK/libarpack_LINUX.a
However, I keep getting the same error while installation of the software that larpack was not found. Am I using the linking command wrong?
You either want gcc main.c /seq/../SOFTWARE/hgaprec/ARPACK/libarpack_LINUX.a (you don't need -l and -L if you're specifying the full path to static library), or as #Julian_Cienfuegos suggested gcc main.c -L/seq/../SOFTWARE/hgaprec/ARPACK/ -larpack_LINUX. This assumes you're only compiling a single file called main.c which contains your main() function, and outputs the a.out binary.
EDIT: Added explanation of main.c.
My issue got solved after including the ARPACK library path as part of LD flag in configure like so:
./configure --prefix=/seq/.../SOFTWARE/hgaprec LDFLAGS="-L/seq/.../SOFTWARE/hgaprec/ARPACK/"

Building error, cmake, can not be used when making a shared object; recompile with -fPIC

When I build a project with cmake, I got following error. Though I tried to add compiling flag -fPIC by add_definition() in the CMakeLists.txt, this error persists. Can anyone help? I am a new guy to cmake. Any suggestions will be highly appreciated.
/usr/bin/ld: /act/mvapich2-1.9/gcc-4.7.2/lib/libmpich.a(mvapich_malloc.o): relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC
/act/mvapich2-1.9/gcc-4.7.2/lib/libmpich.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [src/libstracker.so] Error 1
make[2]: Leaving directory `/home/xxxx/success/AutomaDeD-master'
make[1]: *** [src/CMakeFiles/stracker.dir/all] Error 2
make[1]: Leaving directory `/home/xxxx/success/AutomaDeD-master'
make: *** [all] Error 2
add_definitions is is intended to add preprocessor definitions, not a flag
-fPIC is present by default in the linker flags for a shared library build with GCC, see Modules/Compiler/GNU.cmake. You can see all flags by running make VERBOSE=1.
As for the error itself, see this answer.

llvm error: linking error to libLTO.so

During compilation of llvm I get following error:
llvm[2]: ======= Finished Linking Debug+Asserts Executable llvm-config
llvm[2]: Installing Debug+Asserts /usr/local/bin/llvm-config
make[2]: Leaving directory `/usr/bin/tools/llvm-config'
make[2]: Entering directory `/usr/bin/tools/lto'
llvm[2]: Compiling LTODisassembler.cpp for Debug+Asserts build (PIC)
llvm[2]: Compiling lto.cpp for Debug+Asserts build (PIC)
llvm[2]: Linking Debug+Asserts Shared Library libLTO.so
collect2: ld terminated with signal 9 [Killed]
make[2]: *** [/usr/bin/Debug+Asserts/lib/libLTO.so] Error 1
make[2]: Leaving directory `/usr/bin/tools/lto'
make[1]: *** [install] Error 1
make[1]: Leaving directory `/usr/bin/tools'
make: *** [install] Error 1
I do configure llvm by giving path of gcc & g++ compilers.
I don't get any error during configuration; but during build same error persist with clang also. I am using Ubntu-12.10 32 bit.
OK, so to solve this problem, I referred to llvm.org and during configuration added few options as follows:
sudo ./configure CC="/usr/bin/gcc" CXX="/usr/bin/g++" --enable-optimization --enable-jit --enable-debug-runtime --enable-targets=all
And I ran a build as SuperUser.
I faced the same error using Ubuntu 13.04 (arch: x86_64). The following error
collect2: ld terminated with signal 9 [Killed]
was an issue with memory usage. I was indeed using a Koding.com cloud VM with 1GB RAM.
I tried the compilation on my laptop as a normal user and the compilation finished without any issues. I used:
$ ./configure
$ make -j4

using a custom compiler flag in cmake?

I'm trying to compile some code I found on GitHub https://github.com/tapio/Wendy
I'm just trying to compile the stuff in tests/. I never had any experience with cmake, but they're kinda logical anyway.
I got stuck at the part where cmake does this:
/usr/bin/c++ CMakeFiles/clear.dir/clear.o -o clear -rdynamic -lwendy -lglfw -lGLEW -lglm -lz
and gets this error:
Linking CXX executable clear
/usr/bin/ld: cannot find -lwendy
/usr/bin/ld: cannot find -lglm
collect2: ld returned 1 exit status
make[3]: *** [clear] Error 1
make[2]: *** [CMakeFiles/clear.dir/all] Error 2
make[1]: *** [CMakeFiles/clear.dir/rule] Error 2
make: *** [clear] Error 2
I don't understand how the Wendy and glm folder became a compiler flag. Somebody please explain how this is possible. :(
In tests/CMakeLists.txt the line target_link_libraries(${test} wendy ${WENDY_LIBRARIES}) instructs cmake to link the list of libraries in WENDY_LIBRARIES to the executable.