How to resolve this libtool linking error - c

Command used to link:
**libtool --tag=CC --mode=link gcc -I/usr/include/libxml2 -I/home/ovsdpdk/rpmbuild/BUILD/openvswitch-2.4.0.1/openvswitch-2.4.0/include/ -I/home/ovsdpdk/rpmbuild/BUILD/openvswitch-2.4.0.1/openvswitch-2.4.0/lib/ -O3 -lxml2 -lnetconf -lopenvswitch -lovsdb -lpthread -lcrypto -lssl -lrt -laio -avoid-version -module -shared -export-dynamic --mode=link -o ietf-interfaces.la .obj/ietf-interfaces.lo .obj/ovs_mediation.lo -rpath /usr/local/lib**
Error:
libtool: link: gcc -shared -fPIC -DPIC .obj/.libs/ietf-interfaces.o .obj/.libs/ovs_mediation.o -lxml2 -lnetconf -lopenvswitch -lovsdb -lpthread -lcrypto -lssl -lrt -laio -O3 -Wl,-soname -Wl,ietf-interfaces.so -o .libs/ietf-interfaces.so
/usr/bin/ld: /usr/local/lib/libopenvswitch.a(ovsdb-idl.o): relocation R_X86_64_TPOFF32 against `var.7533' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libopenvswitch.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status

Related

When I compile simpleleveldb in simplehttp family, here is a ld error but I have no idea about it

I run it on Linux with x86/64 and ubuntu 2204, gcc version 11.2.0, GNU ld version 2.38.
When I run env LIBLEVELDB=/usr/local make in simpleleveldb dir and get this error:
cc -I. -I../simplehttp/.. -I/usr/local/include -I/usr/local/include -Wall -g -O2 -MM -MT simpleleveldb -MF simpleleveldb.deps simpleleveldb.c str_list_set.c
cc -I. -I../simplehttp/.. -I/usr/local/include -I/usr/local/include -Wall -g -O2 -o simpleleveldb simpleleveldb.c str_list_set.c -L. -L../simplehttp -L/usr/local/lib -L/usr/local/lib -L/usr/local/lib -levent -ljson-c -lsimplehttp -lleveldb -lm -lstdc++ -lsnappy -lpthread
/usr/bin/ld: /usr/local/lib/libsimplehttp.a(request.o):/home/zhdi/simplehttp/simplehttp/request.h:12: multiple definition of `simplehttp_reqs'; /usr/local/lib/libsimplehttp.a(simplehttp.o):/home/zhdi/simplehttp/simplehttp/request.h:12: first defined here
collect2: error: ld returned 1 exit status
make: *** [Makefile:26: simpleleveldb] Error 1
before do it I just build simplehttp follow this repo https://github.com/bitly/simplehttp.
Anyone has some idea? thanks!

error compiling c program on r-pi raspbian

I have this code that compiles fine on my desktop, but when I try to compile it on the raspberry pi, I get this error
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` -c main.c
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` -c fft.c
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` -c draw.c
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` -c table.c
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` -c serial.c
gcc -Wall -O2 -lGL -lGLU -lm -lSDL_image -lfftw3 -lftdi `sdl-config --cflags --libs` main.o fft.o draw.o table.o serial.o -o main
/usr/bin/ld: Warning: size of symbol `table' changed from 2048 in
table.o to 204 in
//usr/lib/arm-linux-gnueabihf/pulseaudio/libpulsecommon-10.0.so
/usr/bin/ld: table.o: undefined reference to symbol 'table'
//usr/lib/arm-linux-gnueabihf/pulseaudio/libpulsecommon-10.0.so: error
adding symbols: DSO missing from command line collect2: error: ld
returned 1 exit status makefile:6: recipe for target 'main' failed
make: *** [main] Error 1
I've tried reinstalling libpulse0 and made sure pulseaudio was installed, and I can find the libpulsecommon-10.0.so when I search for it on the pi. So I'm not sure what to do from here.
libpulsecommon has a global symbol named table, and your code (probably table.c) also has a public symbol with this name. The symbols are colliding when linking. Rename that variable/function on your code.

undefined reference to `gst_riff_create_video_caps'

I'm trying to build a software that uses gstreamer-1.0 and its plugins. I get this error when I try to make using the following g++ command:
g++ vis.cpp -o vis -O3 -D__STDC_CONSTANT_MACROS -std=c++11 -lopencv_highgui -lopencv_imgproc -lopencv_core -lpng -lv4l1 -lv4l2 -ldc1394 -lswscale -lavdevice -lavformat -lavcodec -lswresample -lavutil -lpthread -lbz2 -lz -lc -lrt -llzma -lva -Idependencies/include -Ldependencies/lib `pkg-config --cflags --libs gstreamer-1.0 gstreamer-base-1.0 gstreamer-app-1.0 gstreamer-pbutils-1.0 gtk+-2.0`
cap_gstreamer.cpp:(.text._ZN23CvVideoWriter_GStreamer4openEPKcid6CvSizeb+0x434): undefined reference to `gst_riff_create_video_caps'
collect2: error: ld returned 1 exit status
make: *** [vis] Error 1
Isn't gst_riff_create_video_caps already in the base plug-in? Or do I have to link another plugin for it?
I solved my problem. Obviously, I had to add -lgstriff-1.0 to the library flags as pointed out here:
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gstreamer-riff.html

Error in installing ncdf on Linux when ever i want to install ncdf package it show this error

install.packages("ncdf")
* installing source package ‘ncdf’ ...
** package ‘ncdf’ successfully unpacked and MD5 sums checked checking for nc-config... /usr/local/bin/nc-config configure: creating
./config.status config.status: creating src/Makevars
** libs gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/local/include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c ncdf.c -o ncdf.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/local/include
-fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c ncdf2.c -o ncdf2.o gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG
-I/usr/local/include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c ncdf3.c -o ncdf3.o gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions
-Wl,-z,relro -o ncdf.so ncdf.o ncdf2.o ncdf3.o -L/usr/local/lib -lnetcdf -L/usr/lib/R/lib -lR /usr/bin/ld: /usr/local/lib/libnetcdf.a(attr.o): relocation R_X86_64_32 against
`.rodata' can not be used when making a shared object; recompile with
-fPIC /usr/local/lib/libnetcdf.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status make: *** [ncdf.so] Error 1
ERROR: compilation failed for package ‘ncdf’
* removing ‘/home/ayesha/R/x86_64-pc-linux-gnu-library/3.2/ncdf’
The downloaded source packages are in
'/tmp/RtmpSrzd8P/downloaded_packages'

using C and cuda create shared library got error at link stage

I was really struggled with this error when I try to build a shared library. My code utilize the Lapacke library and also CUDA. when I compile them, there are no errors(I compile them as)
gcc -m64 -Wall -fPIC -c xxx.c -o xxx.o $(INC)
where INC includes all directories
INC=-I. -I${JAVA_HOME}/include/ -I${JAVA_HOME}/include/linux/ I$/home/sniu/lapack-3.5.0/lapacke/include/ -I${CUDA_INSTALL_PATH}/include/ -I/home/sniu/CBLAS/include/
for cuda part, I wrote it as:
nvcc -m64 -arch=sm_20 -Xcompiler -fPIC $(INC) -c xxx.cu -o xxx.o
but I got the error message at the link stage:
gcc -m64 -D_REENTRANT -Wall -fPIC -g -shared -o libjniWrapper.so jniWrapper.o cholesky_inv.o wls_acc.o utils.o -L/home/sniu/lapack-3.5.0 -L/opt/cuda-toolkit/5.5.22/lib64 -lm -llapacke -llapack -lblas -lgfortran -lrt -lcudart -lcublas -ldl
/usr/bin/ld: /home/sniu/lapack-3.5.0/liblapacke.a(lapacke_dpotrf.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/home/sniu/lapack-3.5.0/liblapacke.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
I am very sure libraries are there, I really confused why I got this error.
Any suggestions are appreciated, Thank you so much!

Resources