• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

ios - 链接错误 Xcode libx264.a ARM

[复制链接]
菜鸟教程小白 发表于 2022-12-12 16:27:06 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在尝试构建 libx264.a 以在我的 iphone 4s(运行 iOS 6.1.3)上运行

我正在使用 MACOSX 10.9 终端应用程序构建它:

CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang ./configure 
--host=arm-apple-darwin 
--sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk 
--prefix=armv7 
--extra-cflags='-no-integrated-as -arch armv7' 
--extra-ldflags="-L/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/usr/lib/system -arch armv7" 
--enable-pic --enable-static

这给了我输出:

platform:      ARM
system:        MACOSX
cli:           yes
libx264:       internal
shared:        no
static:        yes
asm:           yes
interlaced:    yes
avs:           avxsynth
lavf:          no
ffms:          no
mp4:           no
gpl:           yes
thread:        posix
opencl:        yes
filters:       crop select_every 
debug:         no
gprof:         no
strip:         no
PIC:           yes
bit depth:     8
chroma format: all

然后我运行“make”,它会生成一个 libx264.a 存档。

到目前为止,一切都很好。

在我设置的 Xcode(版本 5.0.2 (5A3005))应用程序上:

1) Build Settings -> Header Search Path -> x264 父目录 (../x264 )
2) 构建阶段 -> 使用二进制文件链接库 -> 添加其他... ( ../x264/libx264.a )
3)build设置->其他链接器标志:-ObjC

在我的 AppDelegate.mm 中:

#import "AppDelegate.h"
#import "x264.h"

@implementation AppDelegate

- (BOOL)applicationUIApplication *)application 
didFinishLaunchingWithOptionsNSDictionary *)launchOptions
{    
    x264_param_t x264param;
    x264_param_default(&x264param);

    // Override point for customization after application launch.
    return YES;
}

...

当我尝试在设备上运行它时出现错误:

Undefined symbols for architecture armv7:
  "x264_param_default(x264_param_t*)", referenced from:
  -[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 
(use -v to see invocation)

这里是 xcode 调用的命令:

Ld /Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Products/Debug-iphoneos/testingCpp.app/testingCpp normal armv7
cd /Users/danieldantas/Desktop/projects/testingCpp
setenv IPHONEOS_DEPLOYMENT_TARGET 6.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch armv7 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk 
-L/Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Products/Debug-iphoneos 
-L/Users/danieldantas/Desktop/projects/testingCpp -L/Users/danieldantas/Desktop/projects/x264 
-F/Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Products/Debug-iphoneos 
-filelist /Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Intermediates/testingCpp.build/Debug-iphoneos/testingCpp.build/Objects-normal/armv7/testingCpp.LinkFileList 
-dead_strip -ObjC -stdlib=libc++ -fobjc-arc -fobjc-link-runtime -miphoneos-version-min=6.0 -lx264 -framework CoreGraphics -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker 
/Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Intermediates/testingCpp.build/Debug-iphoneos/testingCpp.build/Objects-normal/armv7/testingCpp_dependency_info.dat -o 
/Users/danieldantas/Library/Developer/Xcode/DerivedData/testingCpp-bvawshyhjcybwvadwwwjqxuomjts/Build/Products/Debug-iphoneos/testingCpp.app/testingCpp

知道如何解决这个问题吗?

谢谢



Best Answer-推荐答案


刚刚找到解决办法:

问题在于 import 语句周围缺少 extern "C":

固定版本:

#import "AppDelegate.h"
extern "C" {
    #import "x264.h"
}

@implementation AppDelegate

- (BOOL)applicationUIApplication *)application 
didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{        
    x264_param_t x264param;
    x264_param_default(&x264param);

    // Override point for customization after application launch.
    return YES;
}

关于ios - 链接错误 Xcode libx264.a ARM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20077902/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap