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
Related
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!
everyone.
I'm working on ubuntu, developing this application using the glib resources, I wrote a makefile like this:
INCLUDES= -I ./headers
FLAGS= -g
PKGCONFIGCFLAGS= `pkg-config --cflags qmi-glib` `pkg-config --cflags gio-2.0` `pkg-config --cflags gobject-2.0` `pkg-config --cflags glib-2.0` `pkg-config --cflags gmodule-no-export-2.0` `pkg-config --cflags gmodule-2.0`
PKGCONFIGLIBS= `pkg-config --libs qmi-glib` `pkg-config --libs gio-2.0` `pkg-config --libs glib-2.0` `pkg-config --libs gobject-2.0` `pkg-config --libs gmodule-no-export-2.0` `pkg-config --libs gmodule-2.0`
CC=gcc
OBJECTS=./build/qmi_test.o
all: ${OBJECTS}
$(CC) ${FLAGS} ${INCLUDES} ./sources/main.c ${OBJECTS} -o ./bin/main
./build/qmi_test.o:./sources/qmi_test.c
$(CC) ${FLAGS} ${INCLUDES} ${PKGCONFIGCFLAGS} ./sources/qmi_test.c ${PKGCONFIGLIBS} -lm -o ./build/qmi_test.o
As you may notice, I inserted every glib related resource I found because I keep receiving this in return:
/usr/bin/ld: ./build/qmi_test.o: in function `g_autoptr_cleanup_generic_gfree':
/usr/include/glib-2.0/glib/glib-autocleanups.h:28: undefined reference to `g_free'
/usr/bin/ld: ./build/qmi_test.o: in function `qmi_test1':
/home/myUser/Documents/quectel_eg25-g/./sources/qmi_test.c:24: undefined reference to `g_file_new_for_path'
/usr/bin/ld: /home/myUser/Documents/quectel_eg25-g/./sources/qmi_test.c:25: undefined reference to `g_main_loop_new'
/usr/bin/ld: /home/myUser/Documents/quectel_eg25-g/./sources/qmi_test.c:26: undefined reference to `g_cancellable_new'
/usr/bin/ld: /home/myUser/Documents/quectel_eg25-g/./sources/qmi_test.c:29: undefined reference to `g_main_loop_run'
/usr/bin/ld: /home/myUser/Documents/quectel_eg25-g/./sources/qmi_test.c:31: undefined reference to `g_object_unref'
/usr/bin/ld: /home/myUser/Documents/quectel_eg25-g/./sources/qmi_test.c:32: undefined reference to `g_main_loop_unref'
/usr/bin/ld: /home/myUser/Documents/quectel_eg25-g/./sources/qmi_test.c:33: undefined reference to `g_object_unref'
/usr/bin/ld: ./build/qmi_test.o: in function `Device_Create_Start':
/home/myUser/Documents/quectel_eg25-g/./sources/qmi_test.c:42: undefined reference to `g_file_get_path'
/usr/bin/ld: /home/myUser/Documents/quectel_eg25-g/./sources/qmi_test.c:45: undefined reference to `qmi_device_new'
collect2: error: ld returned 1 exit status
make: *** [Makefile:13: all] Error 1
I read in that the order of ellements when calling gcc does matter. But I'm trying to follow the order of elements as shown here:
glib compiling
Any help or recommendation is welcome.
You need to add the library flags (PKGCONFIGLIBS) to the link step and not the compile step:
all: ${OBJECTS}
$(CC) ${FLAGS} ${INCLUDES} -lm ./sources/main.c ${OBJECTS} ${PKGCONFIGLIBS} -lm -o ./bin/main
./build/qmi_test.o:./sources/qmi_test.c
$(CC) ${FLAGS} ${INCLUDES} ${PKGCONFIGCFLAGS} ./sources/qmi_test.c -o ./build/qmi_test.o
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
I am trying to compile following code webrtc2sip but getting following error.
root#dev1:/usr/local/src/webrtc2sip# g++ -g -O2 -o webrtc2sip webrtc2sip-mp_c2c.o webrtc2sip-mp_engine.o webrtc2sip-mp_mail.o webrtc2sip-mp_mediaproxy.o webrtc2sip-mp_mutex.o webrtc2sip-mp_net_transport.o webrtc2sip-mp_object.o webrtc2sip-mp_peer.o webrtc2sip-mp_proxyplugin.o webrtc2sip-mp_proxyplugin_consumer_audio.o webrtc2sip-mp_proxyplugin_consumer_video.o webrtc2sip-mp_proxyplugin_mgr.o webrtc2sip-mp_proxyplugin_producer_audio.o webrtc2sip-mp_proxyplugin_producer_video.o webrtc2sip-mp_session.o webrtc2sip-mp_session_av.o webrtc2sip-mp_wrap.o webrtc2sip-mp_db_sqlite.o webrtc2sip-sqlite3.o webrtc2sip-mp_db.o webrtc2sip-mp_db_model.o webrtc2sip-jsoncpp.o webrtc2sip-ActionConfig.o webrtc2sip-AudioResampler.o webrtc2sip-DDebug.o webrtc2sip-MediaContent.o webrtc2sip-MediaSessionMgr.o webrtc2sip-Msrp.o webrtc2sip-ProxyConsumer.o webrtc2sip-ProxyPluginMgr.o webrtc2sip-ProxyProducer.o webrtc2sip-SafeObject.o webrtc2sip-SipCallback.o webrtc2sip-SipEvent.o webrtc2sip-SipMessage.o webrtc2sip-SipSession.o webrtc2sip-SipStack.o webrtc2sip-SipUri.o webrtc2sip-SMSEncoder.o webrtc2sip-Xcap.o -L/usr/lib -L/usr/lib -L/usr/local/lib -ltinySAK -L/usr/local/lib -ltinyNET -L/usr/local/lib -ltinyHTTP -L/usr/local/lib -ltinySIP -L/usr/local/lib -ltinyDAV -L/usr/local/lib -ltinySDP -L/usr/local/lib -ltinyBFCP -L/usr/local/lib -ltinySIGCOMP -L/usr/local/lib -ltinyMEDIA -L/usr/local/lib -ltinyXCAP -L/usr/local/lib -ltinySMS -L/usr/local/lib -ltinyMSRP -L/usr/local/lib -ltinyRTP -L/usr/local/lib -ltinyIPSec -lxml2 -lpthread
/usr/bin/ld: webrtc2sip-sqlite3.o: undefined reference to symbol 'dlclose##GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Edit:
I have tried following option in Makefile but no luck :(
LDFLAGS= -ldl
Solution:
Finally find it, used following option and it works!
./configure --prefix=$PREFIX CFLAGS='-lpthread' LDFLAGS='-ldl' LIBS='-ldl'
gcc -o clxd -m64 -L/usr/local/lib64 -L/usr/lib64 -L/usr/lib64/nptl
-Wl,-rpath,/home/y/lib64 -ldl -lrt -lpthread -lstdc++ -lgcc -lc -lm -lev -L/home/y/lib64 -Wl,-Bstatic -lboost_program_options -lboost_date_time -lboost_filesystem -lboost_regex -lboost_system -lboost_thread -llua -lcrypto -Wl,-Bdynamic -L/usr/lib
The above command is from a make file while executing make using V=1 (verbose) to understand if I have passed on directories properly or not. And it exits with the following error:
/usr/bin/ld: cannot find -lcrypto collect2: ld returned 1 exit status
My understanding from the gcc command, -Bstatic tries to statically link lib crypto (-lcrypto).
When I checked under /usr/lib64, I have the following files:
libcrypto.so -> libcrypto.so.1.0.1e
libcrypto.so.10 -> libcrypto.so.1.0.1e
libcrypto.so.1.0.1e
Does -Bstatic link the shared files statically or not? If not how do I get libcrypto.a?
I solved this on Linux/Macosx by installing libssl-dev.
sudo apt-get install libssl-dev