简体   繁体   中英

An error occurred while compiling the FFmpeg framework on the iOS platform

I use the ffmpeg version is 3.0, Xcode version 7.3.1, compile time has been reported as the following error:

Undefined symbols for architecture x86_64:
 "_libiconv", referenced from:
   _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
 "_libiconv_close", referenced from:
  _avcodec_open2 in libavcodec.a(utils.o)
  _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
 "_libiconv_open", referenced from:
  _avcodec_open2 in libavcodec.a(utils.o)
  _avcodec_decode_subtitle2 in libavcodec.a(utils.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

My project has been introduced in the following framework and library:

1.VideoToolbox.framework

2.libiconv.2.4.0.tbd

3.libz.tbd

4.libbz2.tbd

I have the same issue with you. What I found is that the libiconv.tbd (or libiconv2.tbd or libiconv2.4.0.tbd) comes from macOS 10.12(in my case) have compatible issue where the exported symbols are iconv/iconv_open/iconv_close whereas ffmpeg calls libiconv functions like libiconv/libiconv_open/libiconv_close .

Solution is to remove libiconv.2.4.0 from framework/library and one specific version of libiconv.a where libiconv/libiconv_open/libiconv_close are the exported symbols. In my case, I found another copy of libiconv.a in /opt/local/lib. I simply copy this lib file to my project and add it.

Please have a try and let me know if it's able to resolve your issue.

I agree with Eureka.gh. The root cause should be symbol mismatch.
I show my test result below.

LiaotekiMacBook-Pro:lib liaokuohsun$ nm libavcodec.a | grep iconv
                 U _libiconv
                 U _libiconv_close
                 U _libiconv_open

LiaotekiMacBook-Pro:lib liaokuohsun$ nm libiconv.dylib | grep iconv
00000000000f2d80 S ___iconv_2VersionNumber
00000000000f2d50 S ___iconv_2VersionString
00000000000f4750 D __libiconv_version
0000000000003174 T _iconv
00000000000034b7 T _iconv_canonicalize
0000000000003196 T _iconv_close
0000000000001cdd T _iconv_open
00000000000031a3 T _iconvctl
00000000000032ac T _iconvlist
0000000000015f0d T _libiconv_relocate
00000000000f4760 b _libiconv_relocate.initialized
0000000000015e54 T _libiconv_set_relocation_prefix

Here I provide another solution.
With some wrapper functions in your code, this link error can be fixed.

#include <iconv.h>
iconv_t libiconv_open(const char *tocode, const char *fromcode)
{
    return iconv_open(tocode, fromcode);
}

size_t libiconv(iconv_t cd,
             char **inbuf, size_t *inbytesleft,
             char **outbuf, size_t *outbytesleft)
{
    return iconv( cd, inbuf, inbytesleft, outbuf, outbytesleft);
}

int libiconv_close(iconv_t cd)
{
    return iconv_close(cd);
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM