QT开发iMac下环境搭建

先来讲讲windows下的:

windows下直接下载安装就行了,要注意系统位数,本人范的错误,因安装QT时,win7 64位系统我下到了qt-opensource-mac-x64-clang-5.3.2.dmg这个是32位的QT,结果引入ffmpeg库时总是undefined reference to `av_register_all'   找不到ffmpeg的库。最后,实际上QT版本没错,可能64 -32位通用,但ffmpeg应该用32位的版本。


以下是mac下的环境搭建:

第一部分:下载地址(参考:http://blog.csdn.net/friendan/article/details/44873347

上Qt官网http://www.qt.io/download/想下载Qt,速度很慢,在这里记录下在Qt官网看到的镜像下载地址:

1. 所有Qt版本下载地址:

http://download.qt.io/archive/qt/


2. 所有Qt Creator下载地址:

http://download.qt.io/archive/qtcreator/


3. 所有Qt VS开发插件下载地址:

http://download.qt.io/archive/vsaddin/


第二部分:配制(参考:http://blog.csdn.net/libaineu2004/article/details/46234079

1. 下载时 creator 下 qt-creator-mac-opensource-2.5.2.dmg 版本的 和 

2. QT下 Clang 版本的(我下了QT5.3.2里面包含了 qtcreator下,所以可以不用再下qtcreator)


第三部分:Hello word (参考:http://blog.csdn.net/qq_21792169/article/details/53142072)



第四部分:问题

第一个问题Project ERROR: Xcode not set up properly. You may need to confirm the license agreement by running /usr/bin/xcodebuild. 

  解决:(参考:http://stackoverflow.com/questions/33728905/qt-creator-project-error-xcode-not-set-up-properly-you-may-need-to-confirm-t)


In Xcode 8, as Bruce said, this happens when Qt tries to find xcrun when it should be looking for xcodebuild.

Open the file:

Qt_install_folder/5.7/clang_64/mkspecs/features/mac/default_pre.prf

Replace:

isEmpty($$list($$system("/usr/bin/xcrun -find xcrun 2>/dev/null")))

With:

isEmpty($$list($$system("/usr/bin/xcrun -find xcodebuild 2>/dev/null")))

第二个问题::-1: error: Could not resolve SDK path for 'macosx10.8' (参考:http://stackoverflow.com/questions/26320677/error-could-not-resolve-sdk-path-for-macosx10-8%60)


注:此问题可能表现为QTCreator运行按钮为灰色

 

The problem is that the online installer for Qt currently supports OSX 10.8 (Mountain Lion) by default, and I'm guessing you are on 10.9 (Mavericks) or greater.

There is a workaround:

  • Navigate to where you installed Qt (default /Users/your username/Qt) using finder
  • Go to the subdirectory 5.3/clang_64/mkspecs directory
  • Open the file called qdevice.pri with a text editor
  • Change the line !host_build:QMAKE_MAC_SDK = macosx10.8 to:
    • !host_build:QMAKE_MAC_SDK = macosx10.9 if you are on OS X 10.9 (Mavericks), or
    • !host_build:QMAKE_MAC_SDK = macosx if you are on OS X 10.10 (Yosemite)
  • Save the file and restart Qt Creator

解决办法:我的OS X 10.11.6   我改的是:10.11 还是不行,改成10.12就ok了 


第三个问题: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9

(参考1:http://blog.csdn.net/skylin19840101/article/details/45242947    参考2: https://www.zhihu.com/question/23507141)

在项目中的.pro中加

CONFIG += c++11


第四个问题: openssl更新

将新接手的项目打开,出现/Users/....../rsa_ssl/crsa.h:4: error: 'openssl/rsa.h' file not found
#include <openssl/rsa.h>

iMac是自带了openssl但版本过低要升级,过程请看(参考:http://blog.csdn.net/pz0605/article/details/51954868)

升级完后:sudo ln -s /usr/local/Cellar/openssl/1.0.2k/bin/openssl /usr/bin/openssl

注意:1. 重启cmd+r进Recovery模式的目的是csrutil disable打开权限,操作完成后,注意再次进Recovery模式关闭权限csrutil enable

     2. 进Recovery模式前请将输入法切到英文状态,否则进不了Recovery模式


       

第五个问题: 库的引用 (例:openssl)

由于我是新新手项目,也是新开始学QT , 并复习C/C++语法,最后发现,实际上,第四个问题 openssl更新,并不是问题并没有给我带来愉快,运行时总是出现

error: symbol(s) not found for architecture x86_64error: linker command failed with exit code 1 (use -v to see invocation)


最后终于发现我对openssl库的引用只做了一半:

INCLUDEPATH += ../3rdparty/openssl/rel_mac_10.5_64/include


改为:

INCLUDEPATH += ../3rdparty/openssl/rel_mac_10.5_64/include
 
LIBS            +=  -L../3rdparty/openssl/rel_mac_10.5_64/lib -lcrypto \
                -L../3rdparty/openssl/rel_mac_10.5_64/lib -lssl \

程序终于成功运行。(参考:https://yq.aliyun.com/articles/47412


附:QT资料大全

       QT使用第三方库 


QT程序发布:http://blog.csdn.net/liuyez123/article/details/50462637


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值