My app fails to link to swscale library at all. I mean that any swscale method I'm trying to use in my code becomes an undefined reference. I know what this error means - a linker couldn't find any definition of used functions.
But the problem is that I made sure that:
-L/usr/local/Cellar/ffmpeg/2.8.2/lib -lswscale
is in linker output, and the linker actually finds the lib, otherwise it would complain about missing swscale
The library is really there:
$ll /usr/local/Cellar/ffmpeg/2.8.2/lib/libswscale*
output:
-r--r--r-- 1 myuser admin 519K Nov 20 19:33 /usr/local/Cellar/ffmpeg/2.8.2/lib/libswscale.3.1.101.dylib
lrwxr-xr-x 1 myuser admin 24B Nov 20 19:32 /usr/local/Cellar/ffmpeg/2.8.2/lib/libswscale.3.dylib -> libswscale.3.1.101.dylib
-r--r--r-- 1 myuser admin 607K Nov 20 19:32 /usr/local/Cellar/ffmpeg/2.8.2/lib/libswscale.a
lrwxr-xr-x 1 myuser admin 24B Nov 20 19:32 /usr/local/Cellar/ffmpeg/2.8.2/lib/libswscale.dylib -> libswscale.3.1.101.dylib
The library is of the correct architecture:
$lipo -info /usr/local/Cellar/ffmpeg/2.8.2/lib/libswscale.3.dylib
output:
Non-fat file: /usr/local/Cellar/ffmpeg/2.8.2/lib/libswscale.3.dylib is architecture: x86_64
My machine architecture:
$uname -m
output:
x86_64
The symbols exist in the binary, for example:
$nm /usr/local/Cellar/ffmpeg/2.8.2/lib/libswscale.3.1.101.dylib | grep sws_alloc_context
output:
000000000004e3b4 T _sws_alloc_context
This is actually a QT app I'm trying to build. I should mention, that I don't have issues with linking other libraries the same way. I also compiled successfully swscale-test.c
(which is in libwscale sources) using:
clang swscale-test.c -lswscale -lavutil
Do you have any ideas what is wrong or what else can I try to find out the reason?
You're not showing your code, but typically the problem is that you need extern "C"
around ffmpeg #include statements when compiling c++ code (see FAQ ):
extern "C" {
#include "libswscale/swscale.h"
}
The same goes for all other ffmpeg includes.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.