首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将AVFoundation包括在iOS qbs项目中

将AVFoundation包括在iOS qbs项目中
EN

Stack Overflow用户
提问于 2018-07-16 19:06:15
回答 1查看 475关注 0票数 0

我正在使用Xcode 9.4.1和QT5.11,目前有一个工作的.pro文件,用于在iOS上运行Qt应用程序。

只是为了好玩,我想尝试qbs,因为我真的喜欢语法。现在,我已经尝试编写一个反映我的.qbs文件的.pro文件。

所有东西都编译得很好,但是当链接时,我在尝试运行ios模拟器时会遇到以下问题(对于ios也是如此,但具有不同的体系结构):

代码语言:javascript
复制
Undefined symbols for architecture x86_64:
  "_AVAudioSessionCategoryPlayback", referenced from:
      -[MyClass enable] in MediaPlayer.mm.o
  "_MPMediaItemPropertyArtist", referenced from:
      -[MyClass setMediaInfo:artist:] in MediaPlayer.mm.o
  "_MPMediaItemPropertyTitle", referenced from:
      -[MyClass setMediaInfo:artist:] in MediaPlayer.mm.o
  "_OBJC_CLASS_$_AVAudioSession", referenced from:
      objc-class-ref in MediaPlayer.mm.o
  "_OBJC_CLASS_$_MPNowPlayingInfoCenter", referenced from:
      objc-class-ref in MediaPlayer.mm.o
  "_OBJC_CLASS_$_MPRemoteCommandCenter", referenced from:
      objc-class-ref in MediaPlayer.mm.o
ld: symbol(s) not found for architecture x86_64

我在.pro文件中为包含框架所做的工作如下:

代码语言:javascript
复制
LIBS += -framework MediaPlayer -framework AVFoundation

对于我所写的.qbs:

代码语言:javascript
复制
cpp.frameworks: base.concat(["MediaPlayer", "AVFoundation"])

also tried:

cpp.frameworkPaths: base.concat(["/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Frameworks"])
cpp.frameworks: base.concat(["MediaPlayer", "AVFoundation"])

and:

cpp.frameworks: ["MediaPlayer", "AVFoundation"]

我已经被这个问题困扰了几个小时了,很难找到类似的qbs文件在线使用和Github文件。有人知道为什么链接器找不到框架吗?

编辑

我尝试使用qbs创建一个新项目,但遇到了类似的问题。以下是完整的构建日志:

代码语言:javascript
复制
19:12:55: Running steps for project Test...
linking Test (x86_64, debug)
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -Wl,-arch,x86_64,-ios_simulator_version_min,10.0,-syslibroot,/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk,-e,_qt_main_wrapper -stdlib=libc++ -L/Users/john/Qt/5.11.1/ios/lib -L/Users/john/Qt/5.11.1/ios/plugins/platforms -target x86_64-apple-ios10.0-macho -o /Users/john/build-Test-Qt_5_11_1_for_iOS_Simulator-Debug/qtc_Qt_5_11_1_for_iOS_Simulator_Debug/Test.eyJhcmNoaXRlY3R1cmUiOiJ4ODZfNjQiLCJidWlsZFZhcmlhbnQiOiJkZWJ1ZyJ9.260986be/.tmp/Test /Users/john/build-Test-Qt_5_11_1_for_iOS_Simulator-Debug/qtc_Qt_5_11_1_for_iOS_Simulator_Debug/Test.eyJhcmNoaXRlY3R1cmUiOiJ4ODZfNjQiLCJidWlsZFZhcmlhbnQiOiJkZWJ1ZyJ9.260986be/3a52ce780950d4d9/main.cpp.o /Users/john/build-Test-Qt_5_11_1_for_iOS_Simulator-Debug/qtc_Qt_5_11_1_for_iOS_Simulator_Debug/Test.eyJhcmNoaXRlY3R1cmUiOiJ4ODZfNjQiLCJidWlsZFZhcmlhbnQiOiJkZWJ1ZyJ9.260986be/3a52ce780950d4d9/qrc_qml.cpp.o -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Foundation -framework CoreFoundation -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework CoreGraphics -framework Foundation -framework OpenGLES -framework CoreText -framework UIKit -framework QuartzCore -framework CoreText -framework CoreGraphics -framework Foundation -framework CoreFoundation -framework AudioToolbox -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework CoreFoundation -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework CoreGraphics -framework OpenGLES -framework CoreText -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework OpenGLES /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lz -lm -lm -lz -lqtpcre2_debug /Users/john/Qt/5.11.1/ios/lib/libQt5Gui_debug.a -lz -lm /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lm -lz -lqtpcre2_debug -lqtlibpng_debug -lqtharfbuzz_debug -lz /Users/john/Qt/5.11.1/ios/lib/libQt5Network_debug.a -lz -lm /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lm -lz -lqtpcre2_debug -lz /Users/john/Qt/5.11.1/ios/lib/libQt5Qml_debug.a @/Users/john/build-Test-Qt_5_11_1_for_iOS_Simulator-Debug/qtc_Qt_5_11_1_for_iOS_Simulator_Debug/Test.eyJhcmNoaXRlY3R1cmUiOiJ4ODZfNjQiLCJidWlsZFZhcmlhbnQiOiJkZWJ1ZyJ9.260986be/plugins.list.d -lz -lm /Users/john/Qt/5.11.1/ios/lib/libQt5Network_debug.a /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lm -lz -lqtpcre2_debug /Users/john/Qt/5.11.1/ios/lib/libQt5Quick_debug.a -lz -lm /Users/john/Qt/5.11.1/ios/lib/libQt5Qml_debug.a /Users/john/Qt/5.11.1/ios/lib/libQt5Gui_debug.a -lqtlibpng_debug -lqtharfbuzz_debug /Users/john/Qt/5.11.1/ios/lib/libQt5Network_debug.a /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lm -lz -lqtpcre2_debug /Users/john/Qt/5.11.1/ios/lib/libQt5Network_debug.a /Users/john/Qt/5.11.1/ios/lib/libQt5Core_debug.a -lm -lz -lqtpcre2_debug -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Foundation -framework CoreFoundation -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework CoreGraphics -framework Foundation -framework OpenGLES -framework CoreText -framework UIKit -framework QuartzCore -framework CoreText -framework CoreGraphics -framework Foundation -framework CoreFoundation -framework AudioToolbox -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework CoreFoundation -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework CoreGraphics -framework OpenGLES -framework CoreText -framework MobileCoreServices -framework Foundation -framework UIKit -framework CoreFoundation -framework Security -framework OpenGLES
Undefined symbols for architecture x86_64:
  "_qt_main_wrapper", referenced from:
     implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Process failed with exit code 1.
The following products could not be built for configuration qtc_Qt_5_11_1_for_iOS_Simulator_Debug:
Test {"architecture":"x86_64","buildVariant":"debug"}
Error while building/deploying project Test (kit: Qt 5.11.1 for iOS Simulator)
When executing step "Qbs Build"
19:12:57: Elapsed time: 00:02.

我安装了Xcode 9.4.1,然后为macos和ios安装了QT5.11。

EDIT2

它在桌面上构建得很好,但是当我切换到ios或ios模拟器时,我会在我的.qbs文件中得到以下警告:

EDIT3

以下是我对相关工具包的qbs设置:

EN

回答 1

Stack Overflow用户

发布于 2018-07-18 14:36:23

AFAIK,_qt_main_wrapper符号是通过平台插件输入的。因此,您可以自己添加依赖项:

代码语言:javascript
复制
Depends { name: "Qt.qios" } // I think that's the name...

或者您可以使用QtGuiApplication项(而不是Product或CppApplication或您现在使用的任何东西),它会自动处理这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51368595

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档