relocation R_X86_64_PC32 against `_ZN7QStringD1Ev' can not be used when making a shared object; recompile with -fPIC - qtwebkit

When I build qtwebkit, I got this problem.
/usr/bin/ld: /data/zhengjie/qt-everywhere-opensource-src-5.5.1/qtmultimedia/lib/libQt5Multimedia.a(qmediametadata.o): relocation R_X86_64_PC32 against `_ZN7QStringD1Ev' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make: *** [../../lib/libWebCore.so.1.0.0] Error 1
Can anyone help?

Related

cuda: undefined reference to `cufftExecR2C'

Im using Cudas cuFFT library and therefore I have added the library path to $LD_LIBRARY_PATH. When compiling, Im using the -lcufft flag, after including the header with #include<cufft.h>. But I still receive the following errors:
/usr/bin/ld: tmpxft_000029f1_00000000-6_render.cudafe1.cpp:(.text+0x51b): undefined reference to `cufftExecR2C'
/usr/bin/ld: tmpxft_000029f1_00000000-6_render.cudafe1.cpp:(.text+0x528): undefined reference to `cufftDestroy'
/usr/bin/ld: tmpxft_000029f1_00000000-6_render.cudafe1.cpp:(.text+0x16d8): undefined reference to `cufftPlan2d'
/usr/bin/ld: tmpxft_000029f1_00000000-6_render.cudafe1.cpp:(.text+0x16f3): undefined reference to `cufftExecC2R'
/usr/bin/ld: tmpxft_000029f1_00000000-6_render.cudafe1.cpp:(.text+0x16fd): undefined reference to `cufftDestroy'
collect2: error: ld returned 1 exit status
This is a CMake project and I link via: set(CMAKE_CUDA_FLAGS_RELEASE " -I/opt/nvidia/hpc_sdk/Linux_x86_64/22.11/math_libs/include -L/opt/nvidia/hpc_sdk/Linux_x86_64/22.11/math_libs/lib64 -lcufft")
Am I missing something crucial?

Difficulty in linking FFTW library with gfortran

I have a c++ program, which uses the FFTW3 library, which I would like to translate to Fortran. I am using Ubuntu 22.04.1.
I installed the FFTW3 library as detailed in Installation on UNIX
The c++ main program is named ksbenchmark.cpp and, using g++, I compile it and link it (to the math and fftw3 libraries) with
g++ -o my_executable.out ksbenchmark.cpp -lm -lfftw3
which works great.
I have translate the c++ code in Fortran, the source file being named ksbenchmrk.f90.
If I issue
gfortran ksbenchmark.f90 -lfftw3 -lm
I get error messages
/usr/bin/ld: /tmp/cca2xMGa.o: in function `ksintegrate_':
ksbenchmark.f90:(.text+0x59): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksbenchmark.f90:(.text+0x94): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksbenchmark.f90:(.text+0xcf): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksbenchmark.f90:(.text+0x4de): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksbenchmark.f90:(.text+0x5db): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksbenchmark.f90:(.text+0x626): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksbenchmark.f90:(.text+0x780): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksbenchmark.f90:(.text+0xa1c): undefined reference to `dfftw_execute_'
collect2: error: ld returned 1 exit status
I have spent the afternoon reading about it, and it seems I may have to use -I and -L flags such as
gfortran test.f90 -L/new/path/to/lib -I/new/path/to/include -lfftw3 -lm
as illustrated in the post Problems linking FFTW with gfortran (symbol(s) not found for architecture x86_64).
The first question is, what paths to use?
I can find files referring to fftw3 in /usr/local/lib as well as in /usr/local/include, but the attempt
gfortran ksbenchmark.f90 -L/usr/local/lib -I/usr/local/include -lfftw3 -lm
returns the same error as before
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: /tmp/ccW2DYGP.o: in function `ksintegrate_':
ksintegrate.f90:(.text+0x62): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksintegrate.f90:(.text+0x9d): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksintegrate.f90:(.text+0xd8): undefined reference to `dfftw_plan_dft_1d_'
/usr/bin/ld: ksintegrate.f90:(.text+0x4df): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksintegrate.f90:(.text+0x5f7): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksintegrate.f90:(.text+0x643): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksintegrate.f90:(.text+0x79d): undefined reference to `dfftw_execute_'
/usr/bin/ld: ksintegrate.f90:(.text+0xa5b): undefined reference to `dfftw_execute_'
collect2: error: ld returned 1 exit status
I am unable to understand which paths to the library are to be used.
How to find where the library is saved?
Why does not g++ need any paths to the library?
I apologise for how trivial the question might seem, I am a total newbie can ensure I put a significant effort in trying to sort this out. Any hint would be most appreciated, thanks
EDIT
Following Vladimir F Героям слава's advice, I tried using the nm command to verify the library contains what is expected to.
In /usr/local/lib
I found libfftw3.a and libfftw3.la files.
Issuing nm libfftw3.a I get quite a long list.
I tried looking for one of the commands I get an error about, dfftw_plan_dft_1d
nm -S libfftw3.a | grep dfftw_plan_dft_1d
and indeed it returns hits
00000000000003a0 0000000000000026 T _Z18dfftw_plan_dft_1d_PP11fftw_plan_sPiPA2_dS4_S2_S2_
0000000000002df0 0000000000000026 T _Z19dfftw_plan_dft_1d__PP11fftw_plan_sPiPA2_dS4_S2_S2_

How can I resolve this Cmake Error When Installing TrajOpt to my catkin workspace?

I'm trying to install TrajOpt to my catkin workspace. I have gotten up to make -j. See my terminal output below.
How do I proceed? Thank you in advance!
$ make -j
Scanning dependencies of target json
Scanning dependencies of target utils
Scanning dependencies of target bpmpd_caller
Scanning dependencies of target gtest
[ 1%] Building CXX object src/sco/CMakeFiles/bpmpd_caller.dir/bpmpd_caller.cpp.o
[ 3%] Building CXX object src/utils/CMakeFiles/utils.dir/stl_to_string.cpp.o
[ 5%] Building CXX object src/utils/CMakeFiles/utils.dir/config.cpp.o
[ 7%] Building CXX object src/utils/CMakeFiles/utils.dir/logging.cpp.o
[ 9%] Building CXX object src/utils/CMakeFiles/utils.dir/clock.cpp.o
[ 10%] Building CXX object ext/json/CMakeFiles/json.dir/src/lib_json/json_value.cpp.o
[ 12%] Building CXX object ext/json/CMakeFiles/json.dir/src/lib_json/json_reader.cpp.o
[ 14%] Building CXX object ext/json/CMakeFiles/json.dir/src/lib_json/json_writer.cpp.o
[ 16%] Building CXX object ext/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 18%] Linking CXX executable ../../bin/bpmpd_caller
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(bpmdll.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(mprnt.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(pddrv.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(readpar.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(rowact.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(rowdup.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(rowsng.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(scale.o): relocation R_X86_64_32S against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(wrimps.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(aggreg.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(bndchk.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(bpmpd.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(cdiag.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(cdircc.o): relocation R_X86_64_32S against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(cdirpc.o): relocation R_X86_64_32S against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(cfixvar.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(chepdu.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(coldbl.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(colsng.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(cstpcrt.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(cstplen.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(dblrow.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(duchek.o): relocation R_X86_64_32S against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(facts5c.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(factsnb3.o): relocation R_X86_64_32S against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(fbtran8.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(itrefsol.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(lindep.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(nfacts5c.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(nfactsb3.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(pbcgm.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(pbqmr.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(refactm.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(rngchk.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(setlam.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(sparsr.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(supnode.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(symfactq.o): relocation R_X86_64_32 against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(symmfo.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(unroll.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(warmstrt.o): relocation R_X86_64_32S against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(affsdir.o): relocation R_X86_64_32S against `.bss' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(ordctl.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(metis.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(mfillind.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: /home/sophie/caris_ws/trajopt/3rdpartylib/bpmpd_linux64.a(mfillin.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
src/sco/CMakeFiles/bpmpd_caller.dir/build.make:95: recipe for target 'bin/bpmpd_caller' failed
make[2]: *** [bin/bpmpd_caller] Error 1
CMakeFiles/Makefile2:286: recipe for target 'src/sco/CMakeFiles/bpmpd_caller.dir/all' failed
make[1]: *** [src/sco/CMakeFiles/bpmpd_caller.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 20%] Linking CXX shared library ../../lib/libjson.so
[ 20%] Built target json
[ 21%] Linking CXX shared library ../../lib/libutils.so
[ 21%] Built target utils
[ 23%] Linking CXX static library ../../lib/libgtest.a
[ 23%] Built target gtest
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2
I had the same issue. It looks like the master trajopt repository hasn't been updated in a couple years, but there's a forked repository which has some recent branches, and this branch at this link has solved that error for me. Then, I was running into another issue, which I was able to resolve by following these instructions.
Checkout new trajopt branch:
git checkout https://github.com/cedriclmenard/trajopt.git
cd trajopt
git checkout --track origin/fixes-cedric
Fixes for new error:
sudo apt-get install libopenscenegraph-dev
sudo cp /usr/include/osg/CameraNode usr/local/include/osg/
sudo apt-get remove libopenscenegraph-dev
Finish making trajopt (I added 1 to the make command that way I didn't get a "out of memory" error):
cd ..
mkdir build_trajopt
cmake path/to/trajopt
make -j 1

/usr/bin/ld: cannot find -lpq

I want connect to postgresql by libpqxx (C++)
When running g++ with -lpq I got this error:
[michael#michael cpp]$ g++ Store.cpp -lpqxx -std=c++11 -lpq
/usr/bin/ld: cannot find -lpq collect2: error: ld returned 1 exit
status
When I remove -lpq it's run well and work, I want to know why with -lpq it's not work and how fix it.
Thanks, Michael.

FreeRDP CMAKE Error

Hello I am brand new to linux and i am trying to install FreeRDP. I keep getting this error:
/usr/bin/ld: /usr/local/ssl/lib/libcrypto.a(hmac.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/local/ssl/lib/libcrypto.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [winpr/libwinpr/utils/libwinpr-utils.so.1.1.0] Error 1
make[1]: *** [winpr/libwinpr/utils/CMakeFiles/winpr-utils.dir/all] Error 2
make: *** [all] Error 2
After I type the "make" command.
Sorry if this question has already been asked but i have thorougly searched stack overflow and havent found it. Thanks in advance:)
It wants you to add a parameter to ld: -fPIC
So if there is a line beignning with ld or gcc, just add it.
Mostly it is gcc and the parameter -shared already exists, so just add -fPIC behind it.