當前位置:首頁 » 編程軟體 » 蘋果編譯環境搭建

蘋果編譯環境搭建

發布時間: 2023-02-13 16:24:13

『壹』 MAC OSX用Xcode編譯webkit,有詳細的步驟嗎

1.使用Xcode軟體。Xcode是一個蘋果系統上的集成開發環境(IDE),就是說用Xcode就能編寫c語言程序,並編譯運行。也能開發ios程序等,是一種軟體。在windows上類似這種能編c語言的還有微軟出的visual studio,和其他免費的一些如codeblocks,c-free等。
在Xcode中編譯運行C/C++的操作步驟:
1)打開Xcode,在歡迎界面點擊Create a new Xcode project。
2)彈出一個對話框,在左側欄選擇Mac OS X分類的Application,右側選擇Command Line Tool,點擊Next。
3)在Proct Name填寫項目名稱,如HelloMac,其餘默認即可(type里也可以選擇C或C++),點擊Next後選擇路徑並點擊Create完成項目創建。
4)在Xcode主界面左側點擊main.m,把代碼替換成C/C++的代碼,點擊左上角的Run按鈕即可編譯運行,界面下方會彈出控制台顯示運行結果。

『貳』 M1晶元Mac搭建前端開發環境

M1晶元出來了有一段時間了,各類軟體的兼容性已經跟進的差不多了,迫於 M1 實在太香,我的 M1 Macbook 也於本周到達了我的手上。在花費了兩三個小時搭建完開發環境後,立馬用它開始幹活了。這幾天的感受只有寥寥一語可以概括:太 TM 香了!太強了

作為一個前端開發者,我可以負責任的說前端開發的場景 M1 已經可以完全覆蓋,並且體驗非常好。目前我依賴的開發環境,並且已經跑在 M1 Mac 上的如下:適配 m1 的 Vscode Insiders 版本 + Node v15(on arm) + Node v14 (on intel) + Nvm + Cocoapods + Xcode + Flutter。可以看到,大前端這一套是完全能夠覆蓋的。

我在 github 的 issue 中經常看到有關於 m1 安裝環境的問題,為了幫助不願意翻 issue 的開發者,遂決定寫下這篇文章記錄前端環境的搭建問題。

我會從以下幾個步驟來記錄:

Xcode 是蘋果開發者工具,是一個功能非常強大的 IDE,可以用來開發蘋果應用,並且自帶了 git 環境, 並且有咱們後續依賴的 Xcode Command line tool , 先進入 app store 中安裝 Xcode。安裝好之後再進入後續步驟

如果你是一個 mac 老用戶,那自然不用我介紹什麼是 Homebrew 。若是你是一個新用戶,那麼請你一定要安裝 Homebrew ,並使用它來管理 Mac 中的各類環境依賴。通過👇的命令即可安裝 Homebrew

在終端中執行如下命令安裝 Homebrew,安裝 Homebrew 的時候,常常會因為網路問題導致安裝失敗,這個問題只能依賴大家自行解決科學上網了。

Nvm 是一個管理 Node 版本的工具,當項目多了以後,總會碰到需要切換 Node 環境的時候,所以推薦大家使用 Nvm 來安裝 Node。

若是你已經按上述步驟安裝好了 Homebrew,那麼你可以直接通過 Homebrew 的命令輕松安裝 Nvm

若是你不想使用 Homebrew 管理依賴,那麼用 👇 的 curl 直接安裝 Nvm 也是可以的

安裝好 nvm 後,需要將環境變數寫入我們的 shell 配置文件中。

如果你的默認 shell 的 zsh,那麼將環境變數命令復制進 .zshrc :

如果不使用 zsh,那麼將環境變數復制進 bash 中,通過如下命令創建 bash_profile,並且編輯 bash_profile。

最後將以下環境變數腳本 進 shell 配置文件中:

至此 Nvm 已經安裝好,可以嘗試在命令行中輸入 nvm,你可以看到 nvm 已經正常工作了。

接下來我們通過 nvm 來安裝 Node,我們先安裝適配了 M1 的 node 版本。

該命令運行完後,會執行很久,編譯 node ,大家耐心等就好了,大概需要 5-10 分鍾,就會提示安裝成功。再提醒一句,報任何錯誤,首先先檢查是不是網路問題,例如 443 、 connect timeout 等,如果是網路問題,建議科學上網。

安裝 Node 的部分寫的很簡單,因為按這個步驟,一般不會出問題。而當你用 nvm 嘗試去安裝 v14 及以下的 Node 版本時,大概率會報錯,而我們在工作中恰恰又可能依賴 v14 及以下的 lts 版本。那麼為什麼會報錯呢?究其原因還是因為低版本的 node 並不是基於 arm64 架構的,所以不適配 M1 晶元。在這里教大家兩個方法,就能成功安裝上低版本 Node。

在終端中,輸入:

通過這個命令可以讓 shell 運行在Rosetta2下。
之後你可以通過 nvm install v12 來安裝低版本 Node。
在此之後,您可以不用在 Rosetta2 中就可以使用安裝的可執行文件,也就是說,您可以將 Node v15與其他節點版本互換使用。

方法二就是通過 Rosetta2 來啟動終端,這樣通過 Rosetta2 轉譯到 x86 架構中執行安裝,也一樣可以安裝成功。

至此,我們的 M1 就已經完成了 git + 各版本 Node + npm 的搭建,完成這部分工作後,前端項目已經可以正常運行,各位買了 M1 Mac 的前端小夥伴又能愉快的幹活了。希望本文能夠幫助被 M1 的開發環境困擾過的您。

『叄』 如何在蘋果系統上安裝PyQt4

安裝PtQt4前你需准備:

  1. Xcode(10.6.1 自帶Xcode)

  2. Qt

  3. SIP

  4. PyQt4

創建了一個pyqt文件夾在硬碟根目錄下,並將sip-4.12.1.tar.gz和PyQt-mac-gpl-snapshot-4.8.4.tar.gz放到其中並解壓

1、先安裝qt,默認安裝,這一步大部分人不會有問題,跳過。

2、接下來,打開終端(Terminal,在 Applications(應用程序)/Utilities(實用工具)/ 下),在終端輸入:export VERSIONER_python_PREFER_32_BIT=yes。

3、使用"cd 路徑"命令將當前目錄設為sip-4.12.1,如: cd /pyqt/sip-4.12.1/, 然後進行配置(configure)【Re-build SIP in 32bit】在終端中執行

python configure.py --arch i386
配置(configure)完成後就開始編譯,在終端中執行引用make clean(清除以前的安裝信息)make
編譯完成後就安裝,在終端中執行引用sudo make install


在這個過程中沒出現錯誤就是安裝成功了

編譯安裝PyQt4,過程和上面的一樣。 【Build PyQt4 in 32bit 】
在終端中使用"cd 路徑"命令將當前目錄設為PyQt-mac-gpl-snapshot-4.8.4,如

引用cd /Users/schi/pyqt/PyQt-mac-gpl-snapshot-4.8.4

然後進行配置(configure),在終端中執行引用python configure.py --use-arch i386
配置時會遇到引用Determining the layout of your Qt installation...
This is the GPL version of PyQt 4.6 (licensed under the GNU General Public
License) for Python 2.6.2 on darwin.

Type '2' to view the GPL v2 license.
Type '3' to view the GPL v3 license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.

Do you accept the terms of the license?


輸入yes,再按回車就行

配置(configure)完成後就開始編譯,在終端中執行

引用make cleanmake


編譯比較花時間,請耐心等待。

編譯完成後就安裝,在終端中執行

引用sudo make install


在這個過程中沒出現錯誤就是安裝成功了

也可以在IDLE中導入PyQt4的模塊,能成功導入就說明安裝成功

Python代碼

fromPyQt4importQtCore,QtGui

下面分析一下安裝過程中可能遇到的問題:

1.問題如下

##############

ld: warning: in /Library/Frameworks/Python.framework/Python, missing required architecture x86_64 in file
Undefined symbols:
"_Py_Initialize", referenced from:
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyLong_AsVoidPtr", referenced from:
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyErr_Print", referenced from:
PyCustomWidgets::getMoleAttr(char const*, char const*)in pluginloader.o
PyCustomWidgets::getMoleAttr(char const*, char const*)in pluginloader.o
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyString_FromString", referenced from:
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyType_IsSubtype", referenced from:
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyMole_GetDict", referenced from:
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyObject_CallObject", referenced from:
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyObject_CallFunctionObjArgs", referenced from:
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyList_Append", referenced from:
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_Py_IsInitialized", referenced from:
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyDict_Next", referenced from:
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyImport_ImportMole", referenced from:
PyCustomWidgets::getMoleAttr(char const*, char const*)in pluginloader.o
PyCustomWidgets::PyCustomWidgets(QObject*)in pluginloader.o
"_PyObject_GetAttrString", referenced from:
PyCustomWidgets::getMoleAttr(char const*, char const*)in pluginloader.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[1]: *** [libpythonplugin.dylib] Error 1
make: *** [all] Error 2
這個問題的原因就是:qt是在32位mac上編譯的,但pyqt默認是在64位機子上編譯的,所以我們在編譯的時候要制定編譯環境:是i386 還是x86_64.

請參考如下的信息:

The problem is that the Qt library is 32bit while, by default, python builds PyQt4 in 64bit. That caused problem when it tried to link 64bit object files with 32bit Qt library. To fix this issue, we need to force python to build PyQt4 in 32bit, and we also need to re-build SIP in 32bit mode.If you use the python version that comes with Mac OS (2.5 for Snow Leopard), make sure that it runs in 32bit mode by issuing the command

2.個問題如下:


>>> from PyQt4 import QtGui

Traceback (most recent call last):

File "<stdin>", line 1, in <mole>

ImportError: dlopen(/Library/Python/2.6/site-packages/PyQt4/QtGui.so, 2): Symbol not found: __

Referenced from: /Library/Python/2.6/site-packages/PyQt4/QtGui.so

Expected in: flat namespace

in /Library/Python/2.6/site-packages/PyQt4/QtGui.so


這個問題是所有的包安裝都沒有問題但是當導入QtGui或其他包時,總報這個問題,這個問題的原因是,當前pyqt release的包本身帶的一個bug,PyQt-mac-gpl-snapshot-4.8.3,所以你下載下個要release的包就可以了。如我下的是:PyQt-mac-gpl-snapshot-4.8.4。

下面給大家介紹一下我寫的自動安裝這些程序的python源碼

#!/usr/bin/env python
"""
Automated installer for Python 2.6 (final)

This installer is able to handle any previous
versions of Python.

NOTE: This file *must* be copied to
//nssgsvr/tools/pyInstall_OSXwhen modified!

"""

import os
import sys
import re
import shutil
import platform
import tarfile

# Constants
PYTHON_PKGS = {"dmgFile" : "python-2.6.1-macosx2008-12-06.dmg",
"mpkgList": ["MacPython.mpkg"] }
#WXPYTHON_PKGS = {"dmgFile" : "wxPython2.8-osx-unicode-2.8.9.2-universal-py2.6.dmg",
# "mpkgList": ["wxPython2.8-osx-unicode-universal-py2.6.pkg"] }
#ANGELIA
XCODE_PKGS = {"dmgFile" : None, "mpkgList": ["Xcode.mpkg"]}

QT_PKGS = {"dmgFile" : "qt-mac-cocoa-opensource-4.6.2.dmg",
"mpkgList": ["Qt.mpkg"] }

THIRD_PARTY_INSTALL = ["sip-4.12.1", "PyQt-mac-gpl-snapshot-4.8.4","Pyro-3.9.1", "pyserial-2.4"]

# Environment constants
TCSH_ENV_FILE = '/etc/csh.login'
BASH_ENV_FILE = '/etc/profile'
SCRIPTS_ROOT_ENV = "TEST_SCRIPTS_ROOT"

TARGET_VER = "2.6"
IS_POSIX = (os.name == 'posix')
IS_MAC = (sys.version.find('Apple') != -1)
IS_OSX = (IS_MAC and IS_POSIX)
IS_OSX_LEOPARD = (IS_OSX and platform.mac_ver()[0].startswith('10.5'))
IS_OSX_SNOWLEOPARD = (IS_OSX and platform.mac_ver()[0].startswith('10.6'))

# NSSGSVR Constants
MOUNT_POINT = "/Volumes/Test"
HOSTSERVER = "NSSGSVR.global.avidww.com" # Server that contains SQA scripts
SHARE = "TEST" # NSSGSVR share that contains the Python scripts directory
USER = "qatest"
PASSWD = "Cmqat/$/$/$" # slashes needed to escape special character '$'

##################################################################################

class InstallerError(Exception):
""" Installer Exception class """
def __init__(self, description):
self.desc = description

def __str__(self):
return self.desc

class PkgInstaller:
""" Installer class for pkg files."""
def __init__(self, packageName, mpkgList, dmgFile = None ):
"""
packageName (str) Name of "package" to be installed
dmgFile (str) Path to dmg file to mount
mpkgList (list) List of mpkg files to launch when dmg file is mounted
"""
self.dmgFile = dmgFile
self.packageName = packageName
self.mpkgList = mpkgList

self.mountpoint = os.path.join(os.getcwd(), self.packageName)
self.removeMountPoint = False

if not type(self.mpkgList) == list:
raise InstallerError("Expected list for parameter mpkgList received %s" % /
type(self.mpkgList))

# Mountroot must exist for hdiutil to succeed.
if not os.path.exists(self.mountpoint):
print "Creating mountroot %s" % (self.mountpoint)
os.makedirs(self.mountpoint)
self.removeMountPoint = True

def _cleanup(self):
"""
## Performs cleanup
"""
unmount_cmd = "hdiutil unmount %s" % (self.mountpoint)

if self.dmgFile:
print "Unmounting %s" % (self.mountpoint)
ret = os.system(unmount_cmd)
if ret:
raise InstallerError("hdiutil unmount of %s failed: errno %d" % /
(self.mountpoint, ret))

if self.removeMountPoint:
print "Removing directory %s" % (self.mountpoint)
os.rmdir(self.mountpoint)

def _mount_dmg(self):
""" Mounts the dmg file. """
hdiutil_mount = "hdiutil mount %s -mountpoint %s" % (self.dmgFile,
self.mountpoint)

if os.path.exists(self.dmgFile):
print "Mounting %s" % (self.dmgFile)
ret = os.system(hdiutil_mount)
if ret:
raise InstallerError("hdiutil mount of %s failed: errno %d" % (self.dmgFile, ret))
else:
raise InstallerError("DMG file %s does not exist" % (self.dmgFile))

def _launch_pkgs(self):
""" Launches the pkg installers. """
for install_file in self.mpkgList:
if install_file.endswith('pkg'):
install_path = os.path.join(self.mountpoint, install_file)
if not os.path.exists(install_path):
raise InstallerError("File %s does not exist" % (install_path))
# 'installer' is Apple's package installer tool.
# -pkg specifies the package to be installed
# -target specifies the destination install volume
# -allow allows the installer to automatically upgrade any previous packages
# see 'man installer' for more details.
cmd = 'installer -pkg "%s" -target / -verbose -allow' % (install_path)
ret = os.system(cmd)
if ret:
msg = "Package %s failed to install: err %d" % (install_file, ret)
raise InstallerError(msg)
else:
raise InstallerError("File %s is not a valid package file" % install_file)

def install(self):
""" Main installer method. """

print "Installing package %s" % (self.packageName)
if self.dmgFile:
self._mount_dmg()
self._launch_pkgs()
self._cleanup()
print "Finished installing package %s" % (self.packageName)

def set_all_test_scripts_root(path):
"""
## Sets TEST_SCRIPTS_ROOT to <path> for
## both Bash and Tcsh shells if needed.
"""
bash_line = 'export TEST_SCRIPTS_ROOT="%s"' % (path)
tcsh_line = 'setenv TEST_SCRIPTS_ROOT "%s"' % (path)

『肆』 如何使用xcodebuild在命令行編譯iOS工程

、准備工作 1、jenkins環境。搭建jenkins環境可以參考jenkins平台搭建和配置一節。需要注意的是,雖然涉及iOS開發,但是jenkins平台卻不必搭建在mac機器上,只要在jenkins上添加mac節點就可以了。 2、iOS開發環境。iOS開發環境主要是指Xcode開發環境,Xcode是免費的,只要在蘋果應用商店裡下載一個就可以了。當然,還有重要的一點兒---開發者證書,現在個人也已經有免費的證書了,沒有證書的話,只能打模擬器用的包了。 3、git項目。強烈建議把代碼放在git上,這樣便於團隊開發。當然,不放git上也可以。 4、jenkins Xcode持續集成插件。常用的插件Xcode integration,這個插件能夠快速的幫助我們進行Xcode打包配置,當然,只用純shell腳本也是可以的。 在jenkins上打包之前,我們最好手工測試一下可以打包成功,首先用Xcode圖形界面進行測試,然後用命令行測試,如果都能打包成功就可以掛在jenkins上運行了,畢竟jenkins的原理也是通過執行一系列命令來完成的。 三、jenkins配置 1、創建一個任務,創建任務的時候最好選自由風格的軟體項目,這樣配置起來比較方便,如果有需要,也可以選擇其他的風格。 2、描述

『伍』 用蘋果系統終端編寫c語言之後怎麼運行

若要在 Mac 的終端中編譯並運行 C 源代碼,你首先需要安裝 Command Line Tools,裡麵包含有 GCC 編譯器。安裝方法為:

打開終端,輸入 gcc。
如果你沒有安裝 Command Line Tools,會彈出一個窗口提示你安裝,如圖所示,點擊安裝即可。如果出現提示「clang_error: no input files」,說明你已經安裝了 gcc 編譯器,可以直接開始編譯程序。

在終端中輸入 ./可執行文件的名稱 即可執行你的程序。例如,我輸入

. est1

後,就可以執行程序了。如果提示你 Permission Denied,則是因為你沒有賦予這個文件執行許可權,需要在終端里輸入

chmod u+x test //(最後參數為你的文件名,來使其可在你的賬戶下執行)1

如果運行時出現 Segmentation Fault,則說明你的代碼里有 bug 導致程序崩潰。

『陸』 蘋果電腦怎麼寫代碼

1、使用Xcode軟體。Xcode是一個蘋果系統上的集成開發環境(IDE),就是說用Xcode就能編寫C語言程序,並編譯運行。也能開發ios程序等,是一種軟體。2、在windows上類似這種能編

1、使用Xcode軟體。
Xcode是一個蘋果系統上的集成開發環境(IDE),就是說用Xcode就能編寫C語言程序,並編譯運行。也能開發ios程序等,是一種軟體。
2、在windows上類似這種能編c語言的還有微軟出的visualstudio,和其他免費的一些如codeblocks,c-free等。
您好,蘋果電腦可以下載蘋果開發工具應用來編寫代碼。可以到蘋果應用商店裡去搜索查詢,並安裝開發工具就可以開始編寫代碼了

『柒』 蘋果MAC系統怎麼編譯C語言

在 Mac OS X 下學習C語言使用 Xcode。

在 Xcode 上運行C語言程序需要先創建工程,再在工程中添加源代碼。

1、 打開 Xcode,選擇「Create a new Xcode project」創建一個新工程,如下圖所示:

左側是工程目錄,主要包含了工程所用到的文件和資源。單擊「main.c」,即可進入代碼編輯模
式,這里 Xcode 已經為我們創建好了一個「Hello World」小程序。點擊上方的「運行」按鈕,即
可在右下角的選項卡中看到輸出結果。

拓展資料

Xcode是由Apple官方開發的IDE,支持C、C 、 Objective-C、Swift等,可以用來開發 Mac OS X 和 iOS上的應用程序。Xcode最初使用GCC作為 編譯器,後來由於GCC的不配合,改用LLVM。

『捌』 蘋果電腦上可以裝c語言編譯器嗎

在蘋果電腦上可以裝c語言編譯器,因為Mac系統本質上是一個Unix系統,是一個開放系統,Unix系統的編寫語言就是C語,兼容C語言編譯器是肯定的了。

目前蘋果的操作系統Mac OS X的開發工具為Xcode,支持C和標准C++程序的編寫。並且Mac平台有很多支持C語言編程的IDE,像NetBeans和Eclipse。

Mac OS X沒有默認安裝C語言編譯器,你需要安裝Xcode,Xcode包含了GCC編譯器。

如果你只是用Mac來學習C語言,安裝一個Xcode即可。Xcode的安裝文件在系統盤的Optional文件夾里。

熱點內容
怎樣刪除小視頻文件夾 發布:2024-05-19 05:49:29 瀏覽:589
開啟php短標簽 發布:2024-05-19 05:44:12 瀏覽:473
android各國語言 發布:2024-05-19 05:42:54 瀏覽:247
微信什麼資料都沒怎麼找回密碼 發布:2024-05-19 05:35:34 瀏覽:907
填志願密碼是什麼 發布:2024-05-19 05:30:23 瀏覽:318
城堡爭霸自動掠奪腳本 發布:2024-05-19 05:22:06 瀏覽:204
asp編程工具 發布:2024-05-19 05:20:36 瀏覽:143
insertpython 發布:2024-05-19 05:12:26 瀏覽:244
androidant編譯 發布:2024-05-19 05:04:11 瀏覽:988
按鍵腳本優化 發布:2024-05-19 04:59:57 瀏覽:752