0

I use this command to compile the file:

g++ rec.cpp -o rec -I /usr/local/include -L /usr/local/lib -lavformat -lavcodec -lavutil -lavdevice -lswscale -lasound -ldl -pthread -lz -lbz2 -lswresample -llzma -lva -lX11

After excute it I got the error:

/usr/bin/ld: /usr/local/lib/libavdevice.a(xcbgrab.o): undefined reference to symbol 'xcb_setup_pixmap_formats_length'//usr/lib/x86_64-linux-gnu/libxcb.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

How could I cope with this issue?

Stanuns
  • 1
  • 2
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Scheff's Cat Jan 26 '18 at 07:53
  • somewhere you need a `-lxcb` in that line...probably there's a pkg-config command to see all the "required" dependencies of libavdevice ... – rogerdpack Jan 26 '18 at 19:31

2 Answers2

0

I found a way to deal with my issue. Since it's definitely a library problem so you can check how many libraries you need before compiling. For example:

 pkg-config --libs libavcodec libavformat libswscale libavutil libavdevice

Then it'll tell you:

-L/usr/local/lib -lavdevice -lm -lxcb -lxcb-shm -lxcb -lxcb-shape -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lasound -lavfilter -pthread -lm -lva -ldl -lswscale -lm -lavformat -lm -lbz2 -lz -lavcodec -pthread -lm -llzma -lz -lva -ldl -lswresample -lm -lavutil -pthread -lva -lva-drm -lva -lva-x11 -lX11 -lm -lva -ldl

These libraries are what you need when you compile and then it's done.

Stanuns
  • 1
  • 2
0

You may also need pkg-config --cflags libavcodec libavformat libswscale libavutil libavdevice to add you CFLAGS or CXXFLAGS.

the kamilz
  • 1,860
  • 1
  • 15
  • 19