0

I use cmake to create my project using ffmpeg lib, the project is simple.

add_executable(testffmpeg main.cpp)
link_directories( /usr/lib/x86_64-linux-gnu )
target_link_libraries(testffmpeg libavcodec.a libavutil.a )

When make, there's lots of undefined reference errors (my default cxx compiler is clang by "export cxx=/usr/bin/clang++").

/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libavcodec.a(crystalhd.o): In function `receive_frame':(.text+0xef): undefined reference to `DtsProcOutputNoCopy'

but when I just use command, it's OK.

clang -o testffmpeg -lavutil -lavcodec main.cpp

while using gcc also get this error gcc -o testffmpeg -lavutil -lavcodec main.cpp

so, how can I resolve this problem and where is the mistake?

Ming Wang
  • 3
  • 2
  • Possible duplicate of [Cmake cannot find library using "link\_directories"](https://stackoverflow.com/questions/31438916/cmake-cannot-find-library-using-link-directories) – ComicSansMS Jun 06 '17 at 09:22
  • I try this, while cannot solve my problem. I think the key issus it's the linker cannot resolve the function used by libavcodec.a just link the error upon, " libavcodec.a(crystalhd.o): In function `receive_frame':(.text+0xef): undefined reference to `DtsProcOutputNoCopy' " – Ming Wang Jun 07 '17 at 02:28

1 Answers1

0

You need add -lcrystalhd in your linker flags. You can use code below to find all linker flags.

pkg-config --libs libavformat
-L/usr/local/lib -lavformat -lXv -lX11 -lXext -ldl -lvdpau -lva -lva-x11 -lX11 -lva -lva-drm -lva -lxcb -lxcb-shm -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lsndio -ljack -lasound -lSDL2 -lx264 -lcrystalhd -lm -llzma -lbz2 -lz -pthread -lavcodec -lXv -lX11 -lXext -ldl -lvdpau -lva -lva-x11 -lX11 -lva -lva-drm -lva -lxcb -lxcb-shm -lxcb -lxcb-xfixes -lxcb-render -lxcb-shape -lxcb -lxcb-shape -lxcb -lsndio -ljack -lasound -lSDL2 -lx264 -lcrystalhd -lm -llzma -lbz2 -lz -pthread -lswresample -lm -lavutil -lm