我目前正在尝试编译基于IOS的基于QT的项目。 我正在使用cmake创建和配置.xcodeproject和xcode以在设备上运行应用程序。QT IOS链接器错误入口点(_main)undefined
我成功地删除了所有以前的链接器错误,现在我正在处理入口点。
我的main.cpp看起来像
这让我以下错误:
Error: You are creating QApplication before calling UIApplicationMain. If you are writing a native iOS application, and only want to use Qt for parts of the application, a good place to create QApplication is from within 'applicationDidFinishLaunching' inside your UIApplication delegate.
我对这个职位发现,您应该重命名主要和Qt将做的工作你并启动应用程序生命周期
Run-time error for Qt application on ios built via CMake
#if defined(Q_OS_IOS)
extern "C" int qtmn(int argc, char** argv) {
#else
int main(int argc, char **argv) {
#endif
QApplication app(argc, argv);
return app.exec();
}
,但现在我处理这个错误
ld: entry point (_main) undefined. for architecture arm64
在第一篇文章,他们说我应该有一个 你的/ QT /根/路径/ mkspecs/MACX-IOS -clang/rename_main.sh脚本
我得到了没有,在其他职位的答案说给:
重命名主 - > qtmn(在qt sourced),重建QT,并从我的main()调用qt_main_wrapper。
,但我不知道要高度重视我做的“重建,并呼吁qt_main_wrapper”
我从来没有听说过替换你的main()让iOS工作。我有一个在iTunes Store上发布的应用程序,在没有任何特殊处理的情况下工作得很好(即,对于iOS,android和win32,main()不需要#ifdefs)。我主要看起来像这样:int main(...){return my_singleton :: run(args)}; 我的my_singleton :: run()是静态函数,它看起来像这样: int my_singleton :: run(){singleton_ = new myQApplication(args)} myQApplication是QApplication的直接后代。 –
@ markus-nm谢谢,我在这里更新我的问题https://forum.qt.io/topic/82102/can-t-create-qapplication-for-ios-using-cmake-build,它看起来像Qt不是将我的QApplication封装在ObjectiveC等效的 –