Archive:Getting Started/Build/KDE4 (zh TW): Difference between revisions

    From KDE TechBase
    m (Text replace - "<code>" to "<syntaxhighlight lang="text">")
    m (Text replace - "</code>" to "</syntaxhighlight>")
    Line 41: Line 41:
    useradd -m kde-devel -s /bin/bash
    useradd -m kde-devel -s /bin/bash
    passwd kde-devel
    passwd kde-devel
    </code>
    </syntaxhighlight>




    Line 59: Line 59:
    <syntaxhighlight lang="bash">
    <syntaxhighlight lang="bash">
    source ~/.bashrc
    source ~/.bashrc
    </code>
    </syntaxhighlight>


    這樣就可以使用本教學中所使用的指令如 <tt>cmakekde</tt>,同時確保 Qt、KDE、CMake 二進位檔的正確路徑。
    這樣就可以使用本教學中所使用的指令如 <tt>cmakekde</tt>,同時確保 Qt、KDE、CMake 二進位檔的正確路徑。
    Line 70: Line 70:
    <syntaxhighlight lang="bash">
    <syntaxhighlight lang="bash">
    ssh -X kde-devel@localhost
    ssh -X kde-devel@localhost
    </code>
    </syntaxhighlight>


    {{Note (zh TW)|
    {{Note (zh TW)|
    Line 165: Line 165:


    你可以一次建構 kdebase 的所有部分,這在下面的方法有所描述。如果您只想要建構 kdebase-runtime,您可以替換下面的方法的
    你可以一次建構 kdebase 的所有部分,這在下面的方法有所描述。如果您只想要建構 kdebase-runtime,您可以替換下面的方法的
    <syntaxhighlight lang="bash">cd kdebase</code>
    <syntaxhighlight lang="bash">cd kdebase</syntaxhighlight>
    <syntaxhighlight lang="bash">cd kdebase/runtime</code>  
    <syntaxhighlight lang="bash">cd kdebase/runtime</syntaxhighlight>  


    === 方法 ===
    === 方法 ===
    Line 220: Line 220:
    cb # cb is not a typo
    cb # cb is not a typo
    make install
    make install
    </code>
    </syntaxhighlight>


    Note: it is not necessary to run cmakekde for updates.
    Note: it is not necessary to run cmakekde for updates.
    Line 235: Line 235:
    macro_optional_add_subdirectory(lskat)
    macro_optional_add_subdirectory(lskat)
    macro_optional_add_subdirectory(katomic)
    macro_optional_add_subdirectory(katomic)
    </code>
    </syntaxhighlight>


    So, the libkdegames and libkmahjongg directories are required to build any of kdegames. The cmake directory will also usually be required. All the other directories (doc, katomic etc) are optional. They will be built if present on your machine. In this example, we build kmahjongg and kbattleship:
    So, the libkdegames and libkmahjongg directories are required to build any of kdegames. The cmake directory will also usually be required. All the other directories (doc, katomic etc) are optional. They will be built if present on your machine. In this example, we build kmahjongg and kbattleship:
    Line 249: Line 249:
    svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames/kmahjongg
    svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames/kmahjongg
    cmakekde  
    cmakekde  
    </code>
    </syntaxhighlight>


    == 成功囉! ==
    == 成功囉! ==

    Revision as of 20:57, 29 June 2011

    Template:I18n/Language Navigation Bar (zh TW)

    Template:TutorialBrowser (zh TW)

    摘要

    這份教學介紹從 trunk 獲取 KDE 在 Linux/BSD 系統上運行的方法。也有其他教學如 FreeBSD、[[../KDE4/Windows (zh TW)|Windows]]、[[../KDE4/Mac OS X|Mac OS X]] 和 Solaris。本教學將創建一個特殊的使用者:kde-devel,用來執行 KDE trunk。一方面,這使得其他使用者可以繼續使用其他 KDE 版本。另一方面,測試特殊的全系統程式碼,如 KDE 顯示管理員是不可能的。這裡有一個教學在 virtual machine 上建立 KDE 4 trunk

    在整份教學中皆使用 bash shell。

    Template:Warning (zh TW)

    為 KDE4 開發建立一個使用者賬戶

    Template:Note (zh TW)


    選項1:命令列

    Template:Note (zh TW)

    useradd -m kde-devel -s /bin/bash
    passwd kde-devel
    


    Template:Warning (zh TW)

    選項2:使用KControl

    Instead of using the commands above, you can also use the User module in the KDE Control Center if you already have KDE3 installed.

    建立環境

    從你的普通使用者下複製 ~/.bashrc 到新的 kde-devel 賬戶下。然後,把 .bashrc 範例的內容複製到 ~kde-devel/.bashrc。如果你不能使用 makeobj 指令,請把範例中的 alias make=makeobj 這一行註釋掉。此外,您可以下載 kde-sdk 套件(或執行 subversion checkout)和含入 kde-sdk/scripts/目錄在您的 path。您可能還需要修改 path,以確保它不包括您的KDE3 的路徑。另外,如果你想使用 KDevelop 開發 KDE 4 應用程式您可能要給 cmake 指令加入 -GKDevelop3 參數(以讓 CMake 生成 KDevelop 的專案檔,這將有助於避免在未來的重建,請見這裡)。

    為了讓他執行,你必須開啟一個新的bash或執行

    source ~/.bashrc
    

    這樣就可以使用本教學中所使用的指令如 cmakekde,同時確保 Qt、KDE、CMake 二進位檔的正確路徑。

    更多的資訊,請閱讀在 KDE4 中使用腳本提高生產力教學。

    切換到新使用者

    切換到使用者 kde-devel:

    ssh -X kde-devel@localhost
    

    Template:Note (zh TW)

    發行版的必需套件包

    從原始碼建構 kde4 的必需套件包在不同的發行版也不同。您的發行版指示如下:

    您的下一個編譯步驟取決於發行版提供的套件包。

    編譯 kde-qt 等

    如果您不希望使用由發行版提供的套件包,您可以自己編譯,如 Qt。建構包括 CMake、Qt4(kde-qt)和 kdesupport 依賴的指示在建構的事前需求頁面。請注意,automoc、phonon、strigi、soprano 以及其他一些 kdesupport 中的東西,如果您有這些東西缺失的錯誤,你需要取得 kdesupport。

    建構 KDE 給開發或穩定使用

    下面的命令用於從 trunk 建構最新版的不穩定 KDE。這不應該用在生產環境,但推薦給開發者。

    想要建構穩定版本,請訪問:

    建構 KDE 4.x

    kdelibs

    現在,我們要來建構 KDE 的基礎函式庫。

    方法

    cd   
    cs # 'cs' 是一個 bash 函式,請點擊這裡了解更多
    mkdir KDE && cd KDE
    svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs
    cd kdelibs
    cmakekde
    

    發生什麼事

    我們修改原始碼的基礎目錄(第1行),然後建立 KDE 目錄並進入(第3行)。我們使用 subversion 下載 kdelibs 的原始碼(第4行),進入新的 ~/kde/src/KDE/kdelibs 目錄(第5行),並開始建構(第6行)。這將使我們在建構完成後仍留在 kdelibs 構建目錄裡。

    Template:Tip (zh TW)

    附加的 KDE 特有 CMake 竅門

    kdelibs/cmake/modules/ 中有一些構建 KDE4 應用程式所需的附加 CMake 模塊。它們會隨 kdelibs 同時安裝。

    想要建立非除錯版本(例如,關閉所有 kDebug() 訊息),使用如:

    cmake -DCMAKE_BUILD_TYPE=Release . && make && make install
    

    疑難排解

    疑難排解相關資訊,請見kdelibs 疑難排解章節

    kdepimlibs

    目前的 kdebase 依賴於 kdepimlibs,所以需要先安裝。這些函式庫還分享給其他的套件包,比如kdepim、kdeutils 和 kdenetwork。

    libical

    Download libical from http://sourceforge.net/project/showfiles.php?group_id=16077, compile, link and install it.

    tar xvzf libical-0.41.tar.gz
    cd libical-0.41
    ./configure && make && make install
    

    方法

    cs KDE # 'cs' 是一個 bash 函式,請點擊這裡了解更多
    svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdepimlibs
    cd kdepimlibs
    cmakekde
    

    發生什麼事

    We go into the KDE source directory (line 1), download the source code for kdepimlibs using subversion (line 2) and then go into the new ~/kde/src/KDE/kdepimlibs directory (line 3). We then commence the build (line 4). This will leave us in the kdepimlibs build directory after the build is completed.

    疑難排解

    疑難排解相關資訊,請見kdepimlibs 疑難排解章節

    kdebase

    kdebase 分為三個部分:

    • apps
    它包含應用程式,如 Dolphin 或 KWrite。
    • runtime
    它包含所有應用程式在運行時需要的東西,如圖示。這是每個 KDE 應用程式的必需依賴,所以你必須編譯和安裝它。
    • workspace
    它包含具體的 KDE 桌面,如 Plasma 或視窗管理員。這裡大多數的東西依賴於 X11。你只在想建構一個完整的 KDE 桌面時需要它。

    你可以一次建構 kdebase 的所有部分,這在下面的方法有所描述。如果您只想要建構 kdebase-runtime,您可以替換下面的方法的

    cd kdebase
    

    cd kdebase/runtime
    

    方法

    cs KDE # 'cs' 是一個 bash 函式,請點擊這裡了解更多
    svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdebase
    cd kdebase
    cmakekde
    

    疑難排解

    疑難排解相關資訊,請見kdebase 疑難排解章節

    翻譯

    大多數 KDE 使用者需要安裝翻譯,然後才能正確地使用他們的桌面。完整的資料載於Development/Tutorials/Localization/Building_KDE's_l10n_Module

    以下方法用於單一的言語,安裝訊息和翻譯文件:

    方法

    cs KDE # 'cs' 是一個 bash 函式,請點擊這裡了解更多
    svn checkout -N svn://anonsvn.kde.org/home/kde/trunk/l10n-kde4
    cd l10n-kde4
    svn checkout scripts <language>
    ./scripts/autogen.sh <language>
    cd <language>
    cmakekde
    


    執行 KDE 4 程式

    現在您可以執行 KDE 4 程式(例如 kwrite),輸入:

    ssh -X kde-devel@localhost
    kwrite 
    

    疑難排解

    疑難排解問題,請見troubleshooting running programs

    生成本地 API 文件

    請見生成 apidox 頁面。

    保持更新

    In order to keep the kde4 installation up to date, each of the modules installed should be updated periodically. As Monday is the day for big changes in kdelibs, Tuesday may be the best day to do this. For each module checked out, run svn up and make.

    For example:

    cs kdesupport # cs is not a typo
    svn up
    cb # cb is not a typo
    make install
    

    Note: it is not necessary to run cmakekde for updates.

    安裝模塊的一個子集

    Many modules in KDE contain a large number of programs which could take a long time to download and compile. In cases where you want to work only on a particular program or programs in a module, it is possible to download and compile particular folders. In some cases, certain folders are required for any build of the module. This is determined in the CMakeLists.txt file of the module. For example the kdegames CMakeLists.txt file lists:

    add_subdirectory(libkdegames)
    add_subdirectory(libkmahjongg)
    
    macro_optional_add_subdirectory(doc)
    macro_optional_add_subdirectory(lskat)
    macro_optional_add_subdirectory(katomic)
    

    So, the libkdegames and libkmahjongg directories are required to build any of kdegames. The cmake directory will also usually be required. All the other directories (doc, katomic etc) are optional. They will be built if present on your machine. In this example, we build kmahjongg and kbattleship:

    cs KDE
    svn co -N svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames # The -N switch performs a non-recursive checkout
    cd kdegames
    svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames/libkdegames # Get required directories
    svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames/libkmahjongg
    svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames/cmake
    svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames/kbattleship # Get optional directories
    svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdegames/kmahjongg
    cmakekde
    

    成功囉!

    你現在可以使用建構 kdebase 一樣的方法建構其他 svn 模塊,執行並測試 KDE4 或者編寫你自己的補丁和應用程式。

    For further isolation of your development environment change symbolic links, which you will see after executing ls -lh $(kde4-config --localprefix), assuming newly installed kde4-config is called.

    關於如何啟動 KDE 4 應用程式,以及如何使用 KDevelop 工作,請參閱建立開發用的 KDE 4教學。

    想要了解更多有關補丁的東西,請見提交補丁