<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://techbase.kde.org/skins/common/feed.css?0.2"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://techbase.kde.org/api.php?action=feedcontributions&amp;user=Liangqi&amp;feedformat=atom</id>
		<title>KDE TechBase - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://techbase.kde.org/api.php?action=feedcontributions&amp;user=Liangqi&amp;feedformat=atom"/>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Special:Contributions/Liangqi"/>
		<updated>2013-05-23T00:30:50Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.20.2</generator>

	<entry>
		<id>http://techbase.kde.org/Projects/KDE_on_Windows/Installation</id>
		<title>Projects/KDE on Windows/Installation</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Projects/KDE_on_Windows/Installation"/>
				<updated>2008-02-14T13:32:51Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:I18n/Language Navigation Bar|Projects/KDE_on_Windows/Installation}}&lt;br /&gt;
&lt;br /&gt;
{{note|Perhaps actual developers should summarize status of KDE4 on Windows here, while we encourage users to describe their experiences on the [[Talk:{{PAGENAME}}|Talk page?]]}}&lt;br /&gt;
&lt;br /&gt;
== KDE Installer for Windows ==&lt;br /&gt;
You can use this installer to download and install the&lt;br /&gt;
various binary packages that you need to run KDE applications on MS Windows.&lt;br /&gt;
KDE is free and open source so you can build all the applications &amp;quot;from scratch&amp;quot; from their source code;&lt;br /&gt;
but as a convenience for others,&lt;br /&gt;
volunteers create these precompiled packages and make them available on the Internet.&lt;br /&gt;
&lt;br /&gt;
'''Disclaimer''' These are early days for KDE4 on Windows,&lt;br /&gt;
some programs work better than others and some fail to run altogether.&lt;br /&gt;
&lt;br /&gt;
'''If you experience any problems please have a look into our [http://lists.kde.org/?l=kde-windows&amp;amp;r=1&amp;amp;w=2| mailing list].'''&lt;br /&gt;
&lt;br /&gt;
You can also use the KDE Installer for Windows to install source code and the packages that you need to ''build'' KDE4 on Windows&lt;br /&gt;
(although if you are building KDE4 on Windows you may prefer to use the emerge system to build KDE and its requirements from latest source);&lt;br /&gt;
see [[Getting Started/Build/KDE4/Windows]].&lt;br /&gt;
&lt;br /&gt;
=== Summary of Steps ===&lt;br /&gt;
* Visit http://download.cegit.de/kde-windows/installer/&lt;br /&gt;
* Download and save the latest version to a directory, e.g. &amp;lt;tt&amp;gt;C:\KDE4&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Run the installer, download what you need (see [[#Download needed packages]] below).&lt;br /&gt;
* Add your lib directory, e.g. &amp;lt;tt&amp;gt;C:\KDE4\lib&amp;lt;/tt&amp;gt; to your Windows %PATH%.  (Start &amp;gt; Control Panel &amp;gt; System &amp;gt; Advanced &amp;gt; Environment Variables, double-click the Path System Variable and add this to your path separated by semicolon.)&lt;br /&gt;
* Add a KDEDIRS environment variable (Start &amp;gt; Control Panel &amp;gt; System &amp;gt; Advanced &amp;gt; Environment Variables, click [New] User variable and create Variable name &amp;lt;tt&amp;gt;KDEDIRS&amp;lt;/tt&amp;gt; with Variable value the directory where you installed KDE4, e.g. &amp;lt;tt&amp;gt;C:\KDE4&amp;lt;/tt&amp;gt;).&lt;br /&gt;
* [TEMPORARILY] Follow the instructions at [[#post-install steps]]&lt;br /&gt;
* Try running a Qt application in the &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory, such as linguist.exe&lt;br /&gt;
* If that works, try running a KDE application such as &amp;lt;tt&amp;gt;kwrite.exe&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Download needed packages ===&lt;br /&gt;
A single program in the The K Desktop Environment depends on many other libraries and packages; that is why each .exe is comparatively small.&lt;br /&gt;
The KDE Installer for Windows has some awareness of dependencies,&lt;br /&gt;
but not complete.&lt;br /&gt;
So, the first few times you try to run an application you may see alerts about missing DLLs.&lt;br /&gt;
&lt;br /&gt;
If you do not intend to build from source, do not click &amp;quot;all&amp;quot; and do not click &amp;quot;src&amp;quot;, as you do not need to download the source for each package. ''Unclear whether you need lib for each''.&lt;br /&gt;
&lt;br /&gt;
There are two development systems for KDE on Windows,&lt;br /&gt;
Microsoft's Visual C and [http://en.wikipedia.org/wiki/MinGW MinGW].&lt;br /&gt;
Even if you are only running binaries and do not intend to build KDE4 yourself,&lt;br /&gt;
you need to choose between these because of the provided runtime environments.&lt;br /&gt;
You're free to decide which to take.&lt;br /&gt;
&lt;br /&gt;
The KDE programs themselves are organized into several groups: kdeedu, kdegames, and kdegraphics.&lt;br /&gt;
&lt;br /&gt;
Here are some of the minimal packages you need to run a KDE application:&lt;br /&gt;
: dbus-msvc, kdebase-msvc, kdewin32-msvc, qt-msvc, vcredist, ??&lt;br /&gt;
&lt;br /&gt;
The Dependencies tab for a particular package lists some of the additional packages it needs.&lt;br /&gt;
However, the dependency checking currently only works for first-level dependencies&lt;br /&gt;
Other dependencies are not easy to determine in advance.&lt;br /&gt;
For example, if you install kdegames only with its dependencies,&lt;br /&gt;
you will not be able to start it because you also need libstreamanalyze&lt;br /&gt;
(for which you have to install the strigi package).&lt;br /&gt;
rhabacker: This is fixed in installer version &amp;gt; 0.8.4. &lt;br /&gt;
&lt;br /&gt;
[[Getting_Started/Build/KDE4/Windows/3rd-party_libraries]] is a more complete list of libraries that a full installation needs.&lt;br /&gt;
&lt;br /&gt;
=== Issues with KDE Installer for Windows ===&lt;br /&gt;
Currently no issues known. If you found an issue, please report to [mailto:kde-windows@kde.org].&lt;br /&gt;
&lt;br /&gt;
== post-install steps ==&lt;br /&gt;
You currently need to run a number of command-line programs to set up KDE.  Here are the steps.&lt;br /&gt;
&lt;br /&gt;
===Run update-mime-database===&lt;br /&gt;
Be sure that you have no KDE-related applications: run the Windows Task Manager (taskmgr.exe), switch to its Processes tab, and kill all occurences of dbus-daemon.exe, kded4.exe, kioslave.exe and klauncher.exe (and all other KDE apps).&lt;br /&gt;
&lt;br /&gt;
Open a Windows command prompt (cmd.exe) and navigate to the directory where you installed KDE. Say you installed KDE to C:\KDE4, then run from the cmd.exe window:&lt;br /&gt;
  C:\KDE4&amp;gt; '''bin\update-mime-database C:\KDE4\share\mime'''&lt;br /&gt;
This will give you a lot of warning message. Most of them you can easily ignore; even if you should set [[KDE_System_Administration/Environment_Variables#XDG_DATA_HOME|XDG_DATA_HOME]] or [[KDE_System_Administration/Environment_Variables#XDG_DATA_DIRS|XDG_DATA_DIRS]] it worked perfectly. If it says you should rerun update-mime-database as root then you're not within your installation directory.&lt;br /&gt;
&lt;br /&gt;
===Run kbuildsyscoca4===&lt;br /&gt;
After finishing the previous step, run&lt;br /&gt;
  C:\KDE4&amp;gt; '''bin\kbuildsycoca4 --noincremental'''&lt;br /&gt;
If this tells you that your disk is full (which is most probably not the case) you have still some executables from KDE running. Please close them and try again.&lt;br /&gt;
&lt;br /&gt;
Excuse us for the inconvenience &amp;amp;mdash; we hope for a better solution in the next release.&lt;br /&gt;
&lt;br /&gt;
== Testing your installation ==&lt;br /&gt;
Navigate to the &amp;lt;tt&amp;gt;bin&amp;lt;/tt&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
See if you can run the Qt program assistant.exe.&lt;br /&gt;
Qt programs have fewer dependencies than a full-blown KDE application.&lt;br /&gt;
&lt;br /&gt;
If that works, try running a simple KDE application, such as kruler.exe from the kdegraphics package.&lt;br /&gt;
&lt;br /&gt;
The first KDE application you run will start a console window in order to run the [http://en.wikipedia.org/wiki/D-Bus D-Bus daemon].&lt;br /&gt;
&lt;br /&gt;
== Fine-tuning ==&lt;br /&gt;
===Set Oxygen style for widgets===&lt;br /&gt;
The default KDE widget style on Windows is the native one. You already have Oxygen style installed (which is a plugin library %KDEROOT%\lib\kde4\plugins\styles\oxygen.dll), so it can be used as well. To set it for a single user:&lt;br /&gt;
#edit &amp;lt;tt&amp;gt;%UserPROFILE%\.kde\share\config\kdeglobals&amp;lt;/tt&amp;gt; with any text editor (e.g. kwrite)&lt;br /&gt;
#locate line containing &amp;quot;[General]&amp;quot; text, what is a section, if there is no such line, add one&lt;br /&gt;
#replace or add &amp;lt;tt&amp;gt;widgetStyle=....&amp;lt;/tt&amp;gt; line with &amp;lt;tt&amp;gt;widgetStyle=oxygen&amp;lt;/tt&amp;gt;.&lt;br /&gt;
Newly started applications should be displayed with Oxygen style now.&lt;br /&gt;
&lt;br /&gt;
== Status ==&lt;br /&gt;
Using kdewin-installer-gui-0.8.6.exe to install 4.00.60 packages:&lt;br /&gt;
* starting a KDE program correctly starts dbus-daemon.exe&lt;br /&gt;
* many games run&lt;br /&gt;
* choosing File &amp;gt; Open correctly starts klauncher.exe, kioslave.exe and kded4.exe, and runs kbuildsycoca4.exe as needed.&lt;br /&gt;
* Help &amp;gt; ''Program'' Handbook (often mapped to the [F1] key) does not work because the KDE Help Center is not available on Windows.  This is due to its use of the K3Process interface and external dependencies not ported such as perl scripts, htdig, and other libraries.&lt;br /&gt;
** khelpcenter will be included in the next unstable release. The K3Process issues are fixed now. Perl scripts are disabled, which means there is no fulltext search. -- rhabacker&lt;br /&gt;
* Applications that try to play sounds might display an alert about &amp;quot;Multimedia Backend&amp;quot; problems. This requires the Windows backend for [http://phonon.kde.org/ Phonon].&lt;br /&gt;
&lt;br /&gt;
General notes:&lt;br /&gt;
* There are many other KDE programs that are not part of KDE 4.0.0 and are not currently packaged for Windows, such as KOffice 2.&lt;br /&gt;
* By design, KDE-windows does not provide the full-blown KDE desktop, thus no KWin composite manager, KDE-specific &amp;quot;start&amp;quot; menus, Plasma desktop, etc.&lt;br /&gt;
&lt;br /&gt;
=== Package status and contents ===&lt;br /&gt;
{| border=&amp;quot;0&amp;quot; cellpadding=&amp;quot;2&amp;quot;&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
!package&lt;br /&gt;
!status&lt;br /&gt;
!contains applications&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|kdebase&lt;br /&gt;
|packaged&lt;br /&gt;
|Konqueror, Dolphin, KWrite, etc.&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|kdegames&lt;br /&gt;
|packaged&lt;br /&gt;
|Kgoldrunner, Kpat, KMahjongg, etc.&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|kdesdk&lt;br /&gt;
|packaged&lt;br /&gt;
|Kate, Umbrello, etc.&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|kdetoys&lt;br /&gt;
|packaged&lt;br /&gt;
|KTeatime, etc.&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|kdeedu&lt;br /&gt;
|packaged&lt;br /&gt;
|Marble, Parley, KStars, KHangman, etc.&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|kdegraphics&lt;br /&gt;
|not packaged&lt;br /&gt;
|Okular, kolourpaint, etc.&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|amarok&lt;br /&gt;
|packaged&lt;br /&gt;
|Amarok&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|koffice&lt;br /&gt;
|not packaged&lt;br /&gt;
|KWord, Krita, Karbon, etc.&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|kdepim&lt;br /&gt;
|not building&lt;br /&gt;
|KMail, AKregator, etc.&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|kdenetwork&lt;br /&gt;
|not building&lt;br /&gt;
|Kopete, KGet, etc.&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|kdeutils&lt;br /&gt;
|not packaged&lt;br /&gt;
|KGpg, KWallet, etc.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category: MS Windows]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Projects/Plasma/FAQ</id>
		<title>Projects/Plasma/FAQ</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Projects/Plasma/FAQ"/>
				<updated>2008-02-03T10:05:45Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add an i18n bar&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:I18n/Language Navigation Bar|Projects/Plasma/FAQ}}&lt;br /&gt;
&lt;br /&gt;
{{improve|}}&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
Plasma is one of the key technologies of KDE 4 (also known as the &amp;quot;Pillars of KDE&amp;quot;), and one of the most visible to users. As Plasma treats the user interface differently than a traditional desktop, there may be confusion on what Plasma is, what it does, and how to perform common tasks. &lt;br /&gt;
&lt;br /&gt;
This document attempts to address these problems by providing answers to the most common questions.&lt;br /&gt;
&lt;br /&gt;
=== General Questions ===&lt;br /&gt;
&lt;br /&gt;
====What does Plasma do?====&lt;br /&gt;
&lt;br /&gt;
Plasma is the component that is &amp;quot;in charge&amp;quot; of the desktop interface; the desktop,  panel (often referred simply as the task bar), and related elements. However, Plasma goes a bit further than these common pieces to the interface puzzle. The &amp;quot;Desktop&amp;quot; has not changed much since originally conceived; it typically consists of shortcuts, a panel, and icons for currently running applications.  Plasma aims to change that, incorporating semantic application elements, and bringing cooperating technologies to the user's fingertips in a way that is visually appealing while easing work flow.&lt;br /&gt;
&lt;br /&gt;
====What is wrong with the current desktop technology?====&lt;br /&gt;
&lt;br /&gt;
Today's desktops are static. Typically they are tied to a folder in which one can find icons (application launchers), or user-placed documents and folders. Along with pictures and images as backgrounds, the current desktop doesn't go any further, or work for the user. Plasma takes a different approach, engaging the user by creating a dynamic and highly customizable environment.&lt;br /&gt;
&lt;br /&gt;
====I don't think it's such a good idea...====&lt;br /&gt;
&lt;br /&gt;
With Plasma, you can let your desktop (and accompanying support elements) act like it always did.  You can have a task bar, a background image, shortcuts, etc.  If you want to, however, you can use tools provided by Plasma to take your experience further, letting your desktop take shape based on what you want and need.&lt;br /&gt;
&lt;br /&gt;
====How does Plasma work?====&lt;br /&gt;
&lt;br /&gt;
Plasma's components are widgets called ''Plasmoids''. Plasmoids can take on a variety of functions, ranging from displaying your desktop and associated wallpaper, showing your laptop's battery level, displaying your plugged in devices, and drawing the taskbar. Widgets can be grouped together in &amp;quot;containers&amp;quot; called containments. &lt;br /&gt;
&lt;br /&gt;
====It doesn't sound too new... other operating systems have done that.====&lt;br /&gt;
&lt;br /&gt;
The key difference here is that plasmoids can ''interact'' together. You want a better view of your laptop battery in order to find out when you are running low? You just drag it away from the taskbar and put it on the desktop. Also, applets can be resized and rotated at will, thanks to the use of Scalable Vector Graphics (SVGs). As you can see, the desktop not only interacts with you, as the user, but also with itself in new and interesting ways. You are now able to control how your workspace behaves and what it displays, in a visually pleasing and user-friendly manner. Since Plasma is the sum of its plasmoids, every element, even the desktop itself, is a widget.  This allows you to move your desktop anywhere with respect to the windows (back and forward). It is no longer rooted behind everything and becomes instead another element of real interaction. &lt;br /&gt;
&lt;br /&gt;
====Kicker and Kdesktop were working fine in KDE 3! Why did you have to change that?====&lt;br /&gt;
&lt;br /&gt;
Especially regarding kicker, there was the important issue of maintainability. The code was in place since the KDE 2 days, and it was difficult to add new features without breaking others. In the end, to proceed forward the only viable option was to start anew from scratch. &lt;br /&gt;
&lt;br /&gt;
====I can't find my favorite &amp;lt;insert feature here&amp;gt;!====&lt;br /&gt;
&lt;br /&gt;
Don't forget that Plasma is still in its infancy (it's brand new, after all) and that KDE 3 was an extremely polished codebase: it took seven years to get to that, while Plasma had about 18 months to get to its current status. With time, the Plasma developers plan on reintroducing features that are missing and fix regressions. As KDE progresses through the KDE4 cycle, Plasma will improve with it.&lt;br /&gt;
&lt;br /&gt;
====Why on earth did you decide to change the way the desktop operates?====&lt;br /&gt;
&lt;br /&gt;
The idea of a Desktop folder is fundamentally a broken concept. It assumes that everything you will access there resides on a single physical directory on your disk. It may be convenient, but at the same time it greatly limits what you can do. For example, you can't use custom layouts for different desktops, as everything would be read from the directory. Also, quite often a desktop structured like that becomes a dumping ground for files and folders, without any other function. That said, you can have icons on the desktop in Plasma.&lt;br /&gt;
&lt;br /&gt;
====What's the deal with the K menu? It's big and ugly!====&lt;br /&gt;
&lt;br /&gt;
During the development of KDE 4.0, different approaches for a K menu (application launcher) were tried. Some projects, like Raptor, were ambitious but there was no way they could be completed on time. At the time, one developer ported SUSE Linux's application launcher (Kickoff) to the new KDE architecture. As it was the most ready and feature complete (not to mention the product of usability testing) it was chosen to be the default menu in KDE 4.0. However, this does not mean that there aren't alternatives: projects such as the aforementioned Raptor or Lancelot are being actively developed. There is also a &amp;quot;traditional&amp;quot; K-menu available. &lt;br /&gt;
&lt;br /&gt;
====What is the Zooming User Interface (ZUI)?====&lt;br /&gt;
&lt;br /&gt;
The Zooming User Interface, or ZUI, is another component of Plasma. It enables the user to group different groups of plasmoids together, and to quickly switch between one and another using a zoom-and-pan approach. Notice that at the time of writing this feature is still under heavy development and may be fully functional only with later KDE 4.x releases.&lt;br /&gt;
&lt;br /&gt;
====How does the ZUI work?====&lt;br /&gt;
&lt;br /&gt;
Suppose you have three groups of plasmoids (such as widgets, application launchers, etc.) which you want arranged in specific combinations depending on what you want to do. You first group them according to your tastes, then you can switch between them by zooming out (getting a preview of all the groups) and then back in on the specific group you want to use.&lt;br /&gt;
Notice that it is different from traditional X11 virtual desktop switching, as there is a higher degree of flexibility by using this approach, as the groups can be totally different from each other.&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
&lt;br /&gt;
====Can I place icons on the desktop?====&lt;br /&gt;
&lt;br /&gt;
Of course you can. Dragging an icon from Dolphin or Konqueror to the desktop will work. There is also legacy support for the existing Desktop folders, which means that the contents of your existing Desktop folder will be automatically displayed.&lt;br /&gt;
&lt;br /&gt;
====I am using two screens, and I used to have kicker over the two displays. Can I do that with Plasma?====&lt;br /&gt;
&lt;br /&gt;
No. The reason is that having a panel over two displays adds a great deal of complexity, especially when the two displays have different resolution. As a result of this added complexity, this feature would not be guaranteed to work in all cases. As a result it was not implemented. &lt;br /&gt;
&lt;br /&gt;
====How can I add applets to the panel?====&lt;br /&gt;
&lt;br /&gt;
Open the Add Widgets dialog in the Plasma toolbox (upper right corner of the screen) then select the widget of your liking and '''drag it directly''' (don't double click or use the Add Widget button) to the panel. It should embed gracefully. If it doesn't, there is probably some bug in the widget itself.&lt;br /&gt;
&lt;br /&gt;
====I heard that you can use OS X's widgets with Plasma. Is this true? ====	 &lt;br /&gt;
There is some code in place already, however as widgets rely on WebKit, it won't be available until Qt 4.4 (which incorporates it), and therefore unlikely before KDE 4.1.&lt;br /&gt;
&lt;br /&gt;
====My widgets are hidden under the windows. How can I show them?====&lt;br /&gt;
&lt;br /&gt;
You can bring all the widgets to the front by pushing Ctrl-F12, which will bring the Plasma Dashboard to the front.&lt;br /&gt;
&lt;br /&gt;
====How can I lock the positions of the widgets?====&lt;br /&gt;
&lt;br /&gt;
Right click on an empty area of the desktop and select &amp;quot;Lock Widgets&amp;quot; from the contextual menu. If you want to reverse that, right click again and select &amp;quot;Unlock Widgets&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====How do I remove widgets?====&lt;br /&gt;
&lt;br /&gt;
If they're on the panel, right click on the widget and select &amp;quot;Remove this...&amp;quot;. If the widgets are on the desktop, you have different options:&lt;br /&gt;
&lt;br /&gt;
* If you hover over them, clicking the red X will remove them;&lt;br /&gt;
* If you use the Add Widget dialog, you can click on the minus symbol icon next to the widget name to remove it.&lt;br /&gt;
&lt;br /&gt;
====How can I change the height of the panel?====&lt;br /&gt;
&lt;br /&gt;
In KDE 4.1 and later you just need to right-click on the Panel, select &amp;quot;Configure Panel...&amp;quot; and then choose whatever size you would like to have.&lt;br /&gt;
&lt;br /&gt;
In KDE 4.0.2 you are able to change the height by editing a configuration file by hand. A graphical option could not be introduced due to some restrictions in effect for 4.0.x releases (namely, the feature freeze and the string freeze, the latter not allowing new translatable strings to be added). &lt;br /&gt;
&lt;br /&gt;
''Notice'': Plasma must not be running when you attempt this, otherwise it will overwrite your settings. So, first of all, quit plasma:&lt;br /&gt;
&lt;br /&gt;
 kquitapp plasma&lt;br /&gt;
&lt;br /&gt;
As a second step, open $KDEHOME/share/config/plasma-appletsrc with a text editor of your choice. Locate the line which says &amp;quot;plugin=panel&amp;quot; and add a line with the preferred height of the panel in pixels (e.g., size=24 will give a panel 24 pixels high). Save the modified file and start Plasma again.&lt;br /&gt;
&lt;br /&gt;
===Theming===&lt;br /&gt;
&lt;br /&gt;
====I don't like the default look of the panel and other Plasma components. Can I change that?====&lt;br /&gt;
&lt;br /&gt;
Yes, the ability to change the look of Plasma was planned since the beginning. Plasma can use &amp;quot;themes&amp;quot;, which are essentially a number of SVG images and files specifying the colors, to change its appearance. Some themes have already appeared on popular sites like kde-look.org.&lt;br /&gt;
&lt;br /&gt;
====Is there a GUI option available to change the theme?====&lt;br /&gt;
&lt;br /&gt;
Not yet, but it is planned for the future.&lt;br /&gt;
&lt;br /&gt;
====I still want to change the theme! What do I do?====&lt;br /&gt;
&lt;br /&gt;
First of all, obtain a theme (kde-look.org is a good place to look). Then, create the $KDEHOME/share/apps/desktoptheme (where $KDEHOME is the name of your .kde or .kde4 directory, depending on your installation) directory and unpack the theme there. After that is done, edit $KDEHOME/share/config/plasmarc (make a backup copy just in case) and locate the section named &amp;quot;[Theme]&amp;quot;. Change &amp;quot;default&amp;quot; to the name of your downloaded theme (see instructions from the theme's author) and then restart Plasma:&lt;br /&gt;
&lt;br /&gt;
 kquitapp plasma; plasma&lt;br /&gt;
&lt;br /&gt;
===Troubleshooting===&lt;br /&gt;
&lt;br /&gt;
====My panel is gone, how do I get it back?====&lt;br /&gt;
 kquitapp plasma; rm $KDEHOME/share/config/plasma-appletsrc; plasma&lt;br /&gt;
&lt;br /&gt;
This deletes your plasma settings, so you'll get the default configuration back. The panel-vanishing-on-crash issue was fixed just after 4.0.0's release.&lt;br /&gt;
If running all the 3 commands at once doesn't work, try typing them in manually and wait a few seconds before running the next command.&lt;br /&gt;
&lt;br /&gt;
====Some GTK+ applications (such as the IM client Pidgin) do not behave well in Plasma.====&lt;br /&gt;
&lt;br /&gt;
That is unfortunately a bug in the GTK+ graphics toolkit which is exposed by the way Plasma operates. A [http://bugzilla.gnome.org/show_bug.cgi?id=501842 bug report] has been opened in the GTK+ bug tracker. Recently, a patch for Plasma (KDE 4.0.0) has been posted in [http://bugs.kde.org/show_bug.cgi?id=153193 KDE bug tracker] and it has also been incorporated in the 4.0 branch (meaning it will be present in KDE 4.0.1).&lt;br /&gt;
&lt;br /&gt;
====I use the NVIDIA binary driver on Linux and scrolling is really slow! Is it a fault of Plasma?====&lt;br /&gt;
&lt;br /&gt;
No, it is a bug in the NVIDIA binary driver. Update the driver to version 169.07 or newer and the problem should be solved.&lt;br /&gt;
&lt;br /&gt;
=== Glossary ===&lt;br /&gt;
&lt;br /&gt;
* '''Containment''': A container for different plasmoids. The desktop and the panel are examples of containments.&lt;br /&gt;
* '''Panel''': The place where the K-menu, taskbar, system tray and other componenents reside. Often called taskbar.&lt;br /&gt;
* '''Plasmoid''': A component of Plasma. Often referred as widget, or applet.&lt;br /&gt;
&lt;br /&gt;
=== Thanks ===&lt;br /&gt;
&lt;br /&gt;
Daniel Laidig &amp;amp; Simon St.James - thanks for the umeet IRC logs!&lt;br /&gt;
&lt;br /&gt;
=== Contributors ===&lt;br /&gt;
&lt;br /&gt;
* [[User:Einar|Luca Beltrame]]&lt;br /&gt;
* [[User:JosephMGaffney|Joseph M. Gaffney]]&lt;br /&gt;
* [[User:Chani|Chani]]&lt;br /&gt;
* [[User:Dipesh|Dipesh]]&lt;br /&gt;
* All the anyonymous contributors&lt;br /&gt;
&lt;br /&gt;
=== TODO ===&lt;br /&gt;
&lt;br /&gt;
* Write a glossary&lt;br /&gt;
* Better grouping for the questions&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/KDE_TechBase:Contributors</id>
		<title>KDE TechBase:Contributors</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/KDE_TechBase:Contributors"/>
				<updated>2007-12-21T13:04:47Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the contributors page.&lt;br /&gt;
&lt;br /&gt;
'''This site contains a list of ''active'' contributors. It should help to build teams which maintain KDE TechBase's content. If you have questions about KDE TechBase you can ask/email the corresponding person.'''&lt;br /&gt;
&lt;br /&gt;
Please add yourself to the list where appropriate. If you are inactive, please remove yourself again.&lt;br /&gt;
&lt;br /&gt;
== Administrators ==&lt;br /&gt;
&lt;br /&gt;
This is a list of KDE TechBase administrators.&lt;br /&gt;
&lt;br /&gt;
* [[User:Danimo|Danimo]]&lt;br /&gt;
* [[User:Dhaumann|Dhaumann]], &amp;lt;dhaumann at kde dot org&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reviewers and Article Writers ==&lt;br /&gt;
&lt;br /&gt;
If you are continuously reviewing KDE TechBase changes or writing articles add yourself to the list.&lt;br /&gt;
&lt;br /&gt;
* [[User:Dhaumann|Dhaumann]], &amp;lt;dhaumann at kde dot org&amp;gt;&lt;br /&gt;
* name, &amp;lt;email&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Translation Teams ==&lt;br /&gt;
&lt;br /&gt;
KDE TechBase is [[Help:Wiki Translation|translated]] into many languages. If you translate pages please add yourself to the right translation team.&lt;br /&gt;
&lt;br /&gt;
=== Chinese(simplified) Team ===&lt;br /&gt;
* [[User:Liangqi|Liangqi]], cavendish.qi at gmail dot com&lt;br /&gt;
* name, &amp;lt;email&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== German Team ===&lt;br /&gt;
* DrSlowDecay, kde at metalhorde dot de&lt;br /&gt;
* name, &amp;lt;email&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ... Team ===&lt;br /&gt;
* name, &amp;lt;email&amp;gt;&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/KDE_TechBase:Contributors</id>
		<title>KDE TechBase:Contributors</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/KDE_TechBase:Contributors"/>
				<updated>2007-12-21T13:04:01Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the contributors page.&lt;br /&gt;
&lt;br /&gt;
'''This site contains a list of ''active'' contributors. It should help to build teams which maintain KDE TechBase's content. If you have questions about KDE TechBase you can ask/email the corresponding person.'''&lt;br /&gt;
&lt;br /&gt;
Please add yourself to the list where appropriate. If you are inactive, please remove yourself again.&lt;br /&gt;
&lt;br /&gt;
== Administrators ==&lt;br /&gt;
&lt;br /&gt;
This is a list of KDE TechBase administrators.&lt;br /&gt;
&lt;br /&gt;
* [[User:Danimo|Danimo]]&lt;br /&gt;
* [[User:Dhaumann|Dhaumann]], &amp;lt;dhaumann at kde dot org&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reviewers and Article Writers ==&lt;br /&gt;
&lt;br /&gt;
If you are continuously reviewing KDE TechBase changes or writing articles add yourself to the list.&lt;br /&gt;
&lt;br /&gt;
* [[User:Dhaumann|Dhaumann]], &amp;lt;dhaumann at kde dot org&amp;gt;&lt;br /&gt;
* name, &amp;lt;email&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Translation Teams ==&lt;br /&gt;
&lt;br /&gt;
KDE TechBase is [[Help:Wiki Translation|translated]] into many languages. If you translate pages please add yourself to the right translation team.&lt;br /&gt;
&lt;br /&gt;
=== Chinese(simplified) Team ===&lt;br /&gt;
* Liangqi, cavendish.qi at gmail dot com&lt;br /&gt;
* name, &amp;lt;email&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== German Team ===&lt;br /&gt;
* DrSlowDecay, kde at metalhorde dot de&lt;br /&gt;
* name, &amp;lt;email&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== ... Team ===&lt;br /&gt;
* name, &amp;lt;email&amp;gt;&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/User_talk:Dhaumann</id>
		<title>User talk:Dhaumann</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/User_talk:Dhaumann"/>
				<updated>2007-06-20T11:02:06Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: /* Title Translation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Title Translation ==&lt;br /&gt;
&lt;br /&gt;
Hi guy !!!&lt;br /&gt;
I would like to know if menu bar translation is possible... If true, how could I do this?&lt;br /&gt;
Thank you...&lt;br /&gt;
&lt;br /&gt;
:You can use the template &amp;lt;nowiki&amp;gt;{{DISPLAYTITLE:foo}}&amp;lt;/nowiki&amp;gt;, where 'foo' is the translation. However, the display title reflects the wiki link, that's why a text &amp;quot;link to this page as &amp;lt;nowiki&amp;gt;[[...]]&amp;lt;/nowiki&amp;gt;&amp;quot; will appear then. --[[User:Dhaumann|Dhaumann]] 15:40, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
::Actually not, I have hidden that text with display:none for on-screen printing. One bug though: When using DISPLAYTITLE, the &amp;lt;title&amp;gt; tag is not filled for some reason... --[[User:Danimo|Danimo]] 16:33, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
:::Damn... If you need help with this, you can ask me as you want for help... ;) --[[User:Fatalerrors|Fatalerrors]] 10:52, 20 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Hi, Dhaumann, can you read and write Chinese? Cool! --[[User:Liangqi|Liangqi]] 23:00, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
: Unfortunately no. I can't read nor write it. But I still try my best to fix links in a language where I mostly see squares :-) --[[User:Dhaumann|Dhaumann]] 23:22, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
:: I see, I had found it in the diff. Thanks. I had mentioned this link problem in our mailing list. --[[User:Liangqi|Liangqi]] 11:36, 20 June 2007 (CEST)&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Development_(zh_CN)</id>
		<title>Development (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Development_(zh_CN)"/>
				<updated>2007-06-20T09:44:11Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOEDITSECTION__ __NOTOC__ {{Template:I18n/Language Navigation Bar|Development}}&lt;br /&gt;
{| style=&amp;quot;margin: 1em 2.5% 0 2.5%; padding: 0 5px;&amp;quot; cellpadding=&amp;quot;5&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|colspan=2|[[Image:Discover.png|发现]]&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding-left: 50px;&amp;quot; |[[Image:Action_launch.svg|noframe|left|40px]] ||&lt;br /&gt;
;[[Development/Architecture (zh CN)|KDE架构]]&lt;br /&gt;
:说明KDE技术的架构设计文档。&lt;br /&gt;
:''相关：'' [http://api.kde.org API文档]&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding-left: 50px;&amp;quot;|[[Image:Action_configure.svg|noframe|left|40px]] ||&lt;br /&gt;
;[[Development/Tutorials|编程教程]]&lt;br /&gt;
:关于KDE开发的渐进教程。&lt;br /&gt;
:''相关：'' [[Development/Tools|开发工具]] | [[Development/FAQs|FAQ]]&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding-left: 50px;&amp;quot;|[[Image:Action_rebuild.svg|noframe|left|40px]] ||&lt;br /&gt;
;[[Development/Languages|语言绑定]]&lt;br /&gt;
:支持的语言。&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;padding-left: 50px;&amp;quot; |[[Image:Action_note.svg|noframe|left|40px]] ||&lt;br /&gt;
;[[Development/Guidelines|标准和指导方针]]&lt;br /&gt;
:KDE中使用的开发人员的指导方针和技术标准。&lt;br /&gt;
:''相关：'' [[Development/Further Information|更多信息]] (链接、书籍、博客等等。)&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/User_talk:Dhaumann</id>
		<title>User talk:Dhaumann</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/User_talk:Dhaumann"/>
				<updated>2007-06-20T09:37:23Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Title Translation ==&lt;br /&gt;
&lt;br /&gt;
Hi guy !!!&lt;br /&gt;
I would like to know if menu bar translation is possible... If true, how could I do this?&lt;br /&gt;
Thank you...&lt;br /&gt;
&lt;br /&gt;
:You can use the template &amp;lt;nowiki&amp;gt;{{DISPLAYTITLE:foo}}&amp;lt;/nowiki&amp;gt;, where 'foo' is the translation. However, the display title reflects the wiki link, that's why a text &amp;quot;link to this page as &amp;lt;nowiki&amp;gt;[[...]]&amp;lt;/nowiki&amp;gt;&amp;quot; will appear then. --[[User:Dhaumann|Dhaumann]] 15:40, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
::Actually not, I have hidden that text with display:none for on-screen printing. One bug though: When using DISPLAYTITLE, the &amp;lt;title&amp;gt; tag is not filled for some reason... --[[User:Danimo|Danimo]] 16:33, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
:::Damn... If you need help with this, you can ask me as you want for help... ;) --[[User:Fatalerrors|Fatalerrors]] 10:52, 20 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Hi, Dhaumann, can you read and write Chinese? Cool! --[[User:Liangqi|Liangqi]] 23:00, 19 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
: Unfortunately no. I can't read nor write it. But I still try my best to fix links in a language where I mostly see squares :-) --[[User:Dhaumann|Dhaumann]] 23:22, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
:: I see, I had found it in the diff. Thanks. I had mentioned this link problem in our mailing list. --[[User:Liangqi|Liangqi]] 11:36, 20 June 2007 (CEST)&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/User_talk:Dhaumann</id>
		<title>User talk:Dhaumann</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/User_talk:Dhaumann"/>
				<updated>2007-06-20T09:37:00Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Title Translation ==&lt;br /&gt;
&lt;br /&gt;
Hi guy !!!&lt;br /&gt;
I would like to know if menu bar translation is possible... If true, how could I do this?&lt;br /&gt;
Thank you...&lt;br /&gt;
&lt;br /&gt;
:You can use the template &amp;lt;nowiki&amp;gt;{{DISPLAYTITLE:foo}}&amp;lt;/nowiki&amp;gt;, where 'foo' is the translation. However, the display title reflects the wiki link, that's why a text &amp;quot;link to this page as &amp;lt;nowiki&amp;gt;[[...]]&amp;lt;/nowiki&amp;gt;&amp;quot; will appear then. --[[User:Dhaumann|Dhaumann]] 15:40, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
::Actually not, I have hidden that text with display:none for on-screen printing. One bug though: When using DISPLAYTITLE, the &amp;lt;title&amp;gt; tag is not filled for some reason... --[[User:Danimo|Danimo]] 16:33, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
:::Damn... If you need help with this, you can ask me as you want for help... ;) --[[User:Fatalerrors|Fatalerrors]] 10:52, 20 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Hi, Dhaumann, can you read and write Chinese? Cool!&lt;br /&gt;
--[[User:Liangqi|Liangqi]] 23:00, 19 June 2007 (CEST)&lt;br /&gt;
: Unfortunately no. I can't read nor write it. But I still try my best to fix links in a language where I mostly see squares :-) --[[User:Dhaumann|Dhaumann]] 23:22, 18 June 2007 (CEST)&lt;br /&gt;
:: I see, I had found it in the diff. Thanks. I had mentioned this link problem in our mailing list. --[[User:Liangqi|Liangqi]] 11:36, 20 June 2007 (CEST)&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/User:Liangqi</id>
		<title>User:Liangqi</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/User:Liangqi"/>
				<updated>2007-06-18T21:01:33Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;todo: help other friends to post their translation in here ;)&lt;br /&gt;
* check translation files and post them here&lt;br /&gt;
* experience how to develop kde4 apps and how to i18n in kde4&lt;br /&gt;
&lt;br /&gt;
Welcome to [http://www.kdecn.org KDE China]!&lt;br /&gt;
&lt;br /&gt;
--[[User:Liangqi|Liangqi]] 13:55, 12 April 2007&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/User_talk:Dhaumann</id>
		<title>User talk:Dhaumann</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/User_talk:Dhaumann"/>
				<updated>2007-06-18T21:00:56Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Title Translation ==&lt;br /&gt;
&lt;br /&gt;
Hi guy !!!&lt;br /&gt;
I would like to know if menu bar translation is possible... If true, how could I do this?&lt;br /&gt;
Thank you...&lt;br /&gt;
&lt;br /&gt;
:You can use the template &amp;lt;nowiki&amp;gt;{{DISPLAYTITLE:foo}}&amp;lt;/nowiki&amp;gt;, where 'foo' is the translation. However, the display title reflects the wiki link, that's why a text &amp;quot;link to this page as &amp;lt;nowiki&amp;gt;[[...]]&amp;lt;/nowiki&amp;gt;&amp;quot; will appear then. --[[User:Dhaumann|Dhaumann]] 15:40, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
::Actually not, I have hidden that text with display:none for on-screen printing. One bug though: When using DISPLAYTITLE, the &amp;lt;title&amp;gt; tag is not filled for some reason... --[[User:Danimo|Danimo]] 16:33, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
Hi, Dhaumann, can you read and write Chinese? Cool!&lt;br /&gt;
--[[User:Liangqi|Liangqi]] 23:00, 19 June 2007 (CEST)&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/User_talk:Dhaumann</id>
		<title>User talk:Dhaumann</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/User_talk:Dhaumann"/>
				<updated>2007-06-18T21:00:13Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: ask a question&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Title Translation ==&lt;br /&gt;
&lt;br /&gt;
Hi guy !!!&lt;br /&gt;
I would like to know if menu bar translation is possible... If true, how could I do this?&lt;br /&gt;
Thank you...&lt;br /&gt;
&lt;br /&gt;
:You can use the template &amp;lt;nowiki&amp;gt;{{DISPLAYTITLE:foo}}&amp;lt;/nowiki&amp;gt;, where 'foo' is the translation. However, the display title reflects the wiki link, that's why a text &amp;quot;link to this page as &amp;lt;nowiki&amp;gt;[[...]]&amp;lt;/nowiki&amp;gt;&amp;quot; will appear then. --[[User:Dhaumann|Dhaumann]] 15:40, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
::Actually not, I have hidden that text with display:none for on-screen printing. One bug though: When using DISPLAYTITLE, the &amp;lt;title&amp;gt; tag is not filled for some reason... --[[User:Danimo|Danimo]] 16:33, 18 June 2007 (CEST)&lt;br /&gt;
&lt;br /&gt;
:Hi, Dhaumann, can you read and write Chinese? Cool!&lt;br /&gt;
--[[User:Liangqi|Liangqi]] 23:00, 19 June 2007 (CEST)&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/User:Liangqi</id>
		<title>User:Liangqi</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/User:Liangqi"/>
				<updated>2007-04-12T11:55:39Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add some description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;todo: help other friends to post their translation in here ;)&lt;br /&gt;
* check translation files and post them here&lt;br /&gt;
* experience how to develop kde4 apps and how to i18n in kde4&lt;br /&gt;
&lt;br /&gt;
Welcome to [http://www.kdecn.org KDE China]!&lt;br /&gt;
&lt;br /&gt;
--[[User:Liangqi|Liang Qi]] 13:55, 12 April 2007&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Getting_Started/Build/Distributions/FreeBSD</id>
		<title>Getting Started/Build/Distributions/FreeBSD</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Getting_Started/Build/Distributions/FreeBSD"/>
				<updated>2007-04-12T11:29:03Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: a typo for Qt, not QT&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:I18n_Getting_Started_Build_KDE4_FreeBSD}}&lt;br /&gt;
{{KDE4}}&lt;br /&gt;
&lt;br /&gt;
==Required Ports==&lt;br /&gt;
* devel/dbus (version 1.0.2 adequate as of Apr 19)&lt;br /&gt;
* devel/cmake (version 2.4p6 adequate as of Apr 19)&lt;br /&gt;
* devel/subversion&lt;br /&gt;
* (expand as needed, this is a wiki :)&lt;br /&gt;
&lt;br /&gt;
==Differences from the normal build process==&lt;br /&gt;
The page on [[Getting_Started/Build/KDE4|building KDE4]] trunk makes a few assumptions about your environment. Note that FreeBSD's dbus and cmake ports will work (so those sections can be skipped).&lt;br /&gt;
&lt;br /&gt;
==Using kdesvn-build==&lt;br /&gt;
The [http://kdesvn-build.kde.org/ kdesvn-build] script can be used on FreeBSD with one change. qt-copy is going to fail to build dbus support due to reasons described below, so you can either run &amp;quot;kdesvn-build qt-copy&amp;quot; once... apply the fix below, then run &amp;quot;kdesvn-build&amp;quot;. Alternatively, you can add &amp;quot;-lpthread&amp;quot; to the configure-flags in the qt-copy section of your .kdesvn-buildrc .&lt;br /&gt;
&lt;br /&gt;
==Errors compiling qt-copy==&lt;br /&gt;
; Even when I tell it to, qt-copy is not compiling with dbus support&lt;br /&gt;
This is related to the test app for dbus in qt-copy not linking due to a pthreads dependency in libdbus on FreeBSD. To fix it go to: (builddir)/qt-copy/config.tests/unix/dbus . Then manually run&lt;br /&gt;
 g++ dbus.o -lpthread -ldbus-1 -L/usr/local/lib -o dbus&lt;br /&gt;
That should generate the &amp;quot;dbus&amp;quot; file, and you should be able to continue your qt build as you left off, building dbus this time&lt;br /&gt;
&lt;br /&gt;
==Errors compiling kdelibs==&lt;br /&gt;
; kdelibs wont compile, complaining that it can't find qdbus&lt;br /&gt;
See the above question on dbus not compiling (even if you told it to compile). If Qt can't find the dbus libs, it silently fails and will continue to build without dbus.&lt;br /&gt;
&lt;br /&gt;
==Errors compiling kdesupport==&lt;br /&gt;
Strigi is a prereq for building kdelibs at the moment. As of now (Apr 5), there appears to be an issue with building kdesupport/strigi/src/streams/tests/InputStreamReaderTest.cpp on systems where iconv.h does not live in /usr/include. Use &amp;quot;VERBOSE=1 make&amp;quot; to view the offending command, and then run it, modifying it by adding &amp;quot;-I/usr/local/include&amp;quot; to the big list of -I directives (you may also have to fix a few paths... be sure to put it in the right place!). At this point, the rest of the compile should go smoothly.&lt;br /&gt;
&lt;br /&gt;
Note that a few other parts of kdesupport may or may not build on FreeBSD at the moment, but the only part that is actually required to get libs up and running is kdesupport/strigi.&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Getting_Started/Build</id>
		<title>Getting Started/Build</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Getting_Started/Build"/>
				<updated>2007-04-12T11:27:01Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add a link for chinese version of kde4 on freebsd&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you will find instructions for compiling and installing KDE from source and suggestions for when compilation doesn't go so smoothly.&lt;br /&gt;
&lt;br /&gt;
== Building The Source ==&lt;br /&gt;
&lt;br /&gt;
; [[/Stable Version|KDE 3.5 (Stable version)]]: Instructions for installing the latest stable KDE 3.5 release.&lt;br /&gt;
&lt;br /&gt;
; [[/KDE4|KDE 4 (Unstable version, trunk)]][[/KDE4_(zh_CN)|(Simplified Chinese version)]]: Instructions for installing the latest and greatest KDE development source code.&lt;br /&gt;
&lt;br /&gt;
; [[/Older KDE Versions|Old Versions]]: Instructions for building older KDE versions.&lt;br /&gt;
&lt;br /&gt;
; [[/Coexisting Versions|Coexisting Versions]]: Directions to build multiple KDE versions on the same machine simultaneously.&lt;br /&gt;
&lt;br /&gt;
; [[/FAQ|FAQ]]: Help with errors and other questions you might have.&lt;br /&gt;
&lt;br /&gt;
== Further Links ==&lt;br /&gt;
* Build [http://solaris.kde.org/ KDE on Solaris]&lt;br /&gt;
* Build [http://www.kdelibs.com/ KDE on Windows]&lt;br /&gt;
* Build [[/KDE4/Mac_OS_X|KDE on Mac OS X]]&lt;br /&gt;
* Build [[/KDE4/FreeBSD|KDE on FreeBSD]][[/KDE4/FreeBSD_(zh_CN)|(Simplified Chinese version)]]&lt;br /&gt;
[[Category:Build KDE]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Getting_Started/Build/Distributions/FreeBSD</id>
		<title>Getting Started/Build/Distributions/FreeBSD</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Getting_Started/Build/Distributions/FreeBSD"/>
				<updated>2007-04-11T21:55:50Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add i18n template&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:I18n_Getting_Started_Build_KDE4_FreeBSD}}&lt;br /&gt;
{{KDE4}}&lt;br /&gt;
&lt;br /&gt;
==Required Ports==&lt;br /&gt;
* devel/dbus (version 1.0.2 adequate as of Apr 19)&lt;br /&gt;
* devel/cmake (version 2.4p6 adequate as of Apr 19)&lt;br /&gt;
* devel/subversion&lt;br /&gt;
* (expand as needed, this is a wiki :)&lt;br /&gt;
&lt;br /&gt;
==Differences from the normal build process==&lt;br /&gt;
The page on [[Getting_Started/Build/KDE4|building KDE4]] trunk makes a few assumptions about your environment. Note that FreeBSD's dbus and cmake ports will work (so those sections can be skipped).&lt;br /&gt;
&lt;br /&gt;
==Using kdesvn-build==&lt;br /&gt;
The [http://kdesvn-build.kde.org/ kdesvn-build] script can be used on FreeBSD with one change. qt-copy is going to fail to build dbus support due to reasons described below, so you can either run &amp;quot;kdesvn-build qt-copy&amp;quot; once... apply the fix below, then run &amp;quot;kdesvn-build&amp;quot;. Alternatively, you can add &amp;quot;-lpthread&amp;quot; to the configure-flags in the qt-copy section of your .kdesvn-buildrc .&lt;br /&gt;
&lt;br /&gt;
==Errors compiling qt-copy==&lt;br /&gt;
; Even when I tell it to, qt-copy is not compiling with dbus support&lt;br /&gt;
This is related to the test app for dbus in qt-copy not linking due to a pthreads dependency in libdbus on FreeBSD. To fix it go to: (builddir)/qt-copy/config.tests/unix/dbus . Then manually run&lt;br /&gt;
 g++ dbus.o -lpthread -ldbus-1 -L/usr/local/lib -o dbus&lt;br /&gt;
That should generate the &amp;quot;dbus&amp;quot; file, and you should be able to continue your qt build as you left off, building dbus this time&lt;br /&gt;
&lt;br /&gt;
==Errors compiling kdelibs==&lt;br /&gt;
; kdelibs wont compile, complaining that it can't find qdbus&lt;br /&gt;
See the above question on dbus not compiling (even if you told it to compile). If QT can't find the dbus libs, it silently fails and will continue to build without dbus.&lt;br /&gt;
&lt;br /&gt;
==Errors compiling kdesupport==&lt;br /&gt;
Strigi is a prereq for building kdelibs at the moment. As of now (Apr 5), there appears to be an issue with building kdesupport/strigi/src/streams/tests/InputStreamReaderTest.cpp on systems where iconv.h does not live in /usr/include. Use &amp;quot;VERBOSE=1 make&amp;quot; to view the offending command, and then run it, modifying it by adding &amp;quot;-I/usr/local/include&amp;quot; to the big list of -I directives (you may also have to fix a few paths... be sure to put it in the right place!). At this point, the rest of the compile should go smoothly.&lt;br /&gt;
&lt;br /&gt;
Note that a few other parts of kdesupport may or may not build on FreeBSD at the moment, but the only part that is actually required to get libs up and running is kdesupport/strigi.&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Getting_Started/Build/KDE4/FreeBSD_(zh_CN)</id>
		<title>Getting Started/Build/KDE4/FreeBSD (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Getting_Started/Build/KDE4/FreeBSD_(zh_CN)"/>
				<updated>2007-04-11T21:45:41Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add chinese kde4 on freebsd from Huanzhou Zhu&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--Huanzhou Zhu初稿，Liang Qi整理!--&amp;gt;&lt;br /&gt;
{{Template:I18n_Getting_Started_Build_KDE4_FreeBSD}}&lt;br /&gt;
{{KDE4}}&lt;br /&gt;
&lt;br /&gt;
==所需Ports==&lt;br /&gt;
* devel/dbus （version 1.0.2，4月19日的版本就可以）&lt;br /&gt;
* devel/cmake （version 2.4p6，4月19日的版本就可以）&lt;br /&gt;
* devel/subversion&lt;br /&gt;
* 如有需要请添加，这里是wiki :)&lt;br /&gt;
&lt;br /&gt;
==和一般构建过程的不同之处==&lt;br /&gt;
在[[Getting_Started/Build/KDE4_(zh_CN)|构建KDE4]]中对你的环境做了一些假设。这里要说明的是FreeBSD下的dbus和cmake的ports都可以工作（所以这些部分可以跳过）。（译者注：也就是说你直接从ports安装cmake就可以了。）&lt;br /&gt;
&lt;br /&gt;
==使用kdesvn-build==&lt;br /&gt;
[http://kdesvn-build.kde.org/ kdesvn-build]脚本通过修改一个地方就可以直接在FreeBSD上使用。qt-copy的构建会在编译dbus支持时失败，失败原因会在下面介绍，所以，你可以运行“kdesvn-build qt-copy”一次……应用以下的修改，然后运行“kdesvn-build”。或者，在你的.kdesvn-buildrc里的qt-copy一节的configure-flags中添加“-lpthread”。&lt;br /&gt;
&lt;br /&gt;
==编译qt-copy的错误==&lt;br /&gt;
; 就算按我说得这么做，qt-copy其实并没有将dbus的支持编译进去。（译者注：FreeBSD默认情况下不编译qt-copy的dbus支持）&lt;br /&gt;
这是因为FreeBSD中libdbus有pthreads的依赖关系，当编译qt-copy中的dbus测试程序就会无法正确链接而出错。要修正这个问题：进入(builddir)/qt-copy/config.tests/unix/dbus。然后手工运行&lt;br /&gt;
 g++ dbus.o -lpthread -ldbus-1 -L/usr/local/lib -o dbus&lt;br /&gt;
这样就会生成“dbus”文件，你现在应该可以从你停下的地方继续构建qt了，这回可以编译dbus。&lt;br /&gt;
&lt;br /&gt;
==编译kdelibs的错误==&lt;br /&gt;
; kdelibs将无法编译，它会抱怨找不到qdbus&lt;br /&gt;
请阅读上面关于dbus没有被编译的问题（就算你告诉它去编译了）。如果Qt没有找到dbus库，编译过程不会报错，而是继续在没有dbus支持的情况下进行构建。&lt;br /&gt;
&lt;br /&gt;
==编译kdesupport的错误==&lt;br /&gt;
就目前来说，Strigi是构建kdelibs所必须的包。到现在为止（4月5号），在iconv.h文件不在/usr/include下的系统中编译kdesupport/strigi/src/streams/tests/InputStreamReaderTest.cpp会有问题发生。使用“VERBOSE=1 make”查看错误输出，然后运行它，把“-I/usr/local/include”添加到一个-I的大的目录列表中（你可能还需要修改一些路径……请确认这些路径的位置都是正确的！）。从这里开始, 剩下的编译应该都很顺利。&lt;br /&gt;
 &lt;br /&gt;
要说明的是kdesupport的一些部分现在可能还不能在FreeBSD上编译，不过实际上只有kdesupport/strigi这一部分是库构建和运行所必需的。&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Getting_Started/Build/KDE4_(zh_CN)</id>
		<title>Getting Started/Build/KDE4 (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Getting_Started/Build/KDE4_(zh_CN)"/>
				<updated>2007-04-11T21:02:55Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add new entry for chinese(kde4 on freebsd)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--Huanzhou Zhu初稿，Liang Qi整理!--&amp;gt;&lt;br /&gt;
{{Template:I18n_Getting_Started_Build_KDE4}}&lt;br /&gt;
{{TutorialBrowser|&lt;br /&gt;
&lt;br /&gt;
series=开始|&lt;br /&gt;
&lt;br /&gt;
name=从源代码构建KDE4|&lt;br /&gt;
&lt;br /&gt;
pre=[[../../Sources/Anonymous_SVN|Anonymous SVN Quickstart Guide]]|&lt;br /&gt;
&lt;br /&gt;
next=[[../../Set_up_KDE_4_for_development|Starting a KDE4 Environment and Applications]]|&lt;br /&gt;
&lt;br /&gt;
reading=[http://kdesvn-build.kde.org/ kdesvn-build: The KDE From Subversion Build Tool]&amp;lt;br&amp;gt;[[../../Increased_Productivity_in_KDE4_with_Scripts|Increased Productivity in KDE4 with Scripts]]&amp;lt;br&amp;gt;[[Development/Tutorials/CMake_(zh_CN) |CMake介绍]]&amp;lt;br&amp;gt;[[../KDE4/FreeBSD_(zh_CN)|FreeBSD备注]]&amp;lt;br&amp;gt;[[../KDE4/Mac OS X|Instructions for Mac OS X]]|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== 摘要 ==&lt;br /&gt;
&lt;br /&gt;
这份教程介绍了一种使KDE运行于Linux/BSD系统的方法。这份教程通篇使用了bash shell。如果你对在其他系统（如：Solaris、MacOS或Microsoft Windows）上构建KDE有兴趣, 请访问[[../|构建]]页面并在最下方的链接处选择相应的操作系统。&lt;br /&gt;
&lt;br /&gt;
{{note|当周一提交了重大的修改时，构建错误的风险会很大。可以通过[http://developer.kde.org/~dirk/dashboard/ Dashboard]报告意料之外的破坏。非常欢迎大家修复失败的模块。&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== 所需软件 ==&lt;br /&gt;
&lt;br /&gt;
首先你必须安装以下软件，你才能成功完成这份教程：&lt;br /&gt;
* 来自gcc项目的gcc和g++, 最好是4.1或更高的版本。&lt;br /&gt;
* svn（Subversion客户端）&lt;br /&gt;
* pkg-config&lt;br /&gt;
* X11和OpenGL的开发库及头文件&lt;br /&gt;
* libjpeg、libpng、libungif、libxml2和libxslt的开发库及头文件&lt;br /&gt;
* makeobj脚本。可以做为kdesdk-scripts(debian)或类似的软件包的部件来安装，或者直接从[http://websvn.kde.org/trunk/KDE/kdesdk/scripts/makeobj?revision=600932&amp;amp;view=markup WebSVN]下载该软件本身。&lt;br /&gt;
* shared-mime-info软件包，是KDE现在使用的freedesktop MIME标准。&lt;br /&gt;
&lt;br /&gt;
你也许还需要安装以下软件：&lt;br /&gt;
* bash&lt;br /&gt;
&lt;br /&gt;
== 为KDE4开发创建一个用户账户 ==&lt;br /&gt;
&lt;br /&gt;
{{Note|&lt;br /&gt;
一些人喜欢为KDE 4使用一个单独的用户帐户（例如一个旧的bug可能会误删除文件），并且后面的这些指令都是以这种方式进行的。&lt;br /&gt;
&lt;br /&gt;
使用一个单独的用户帐户做任何事情都是很有效率的，有关细节请参考[[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts|Increased Productivity in KDE4 with Scripts]]。&lt;br /&gt;
&lt;br /&gt;
你还可以遵循下面的指令，但并不把这些环境变量保存到你的&amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt;中，请把他们放到一个单独的文件中，以备你在切换到KDE 4环境时使用。&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== 选项1：命令行 ===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
useradd -m kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
或者：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
useradd kde-devel&lt;br /&gt;
mkdir /home/kde-devel&lt;br /&gt;
passwd kde-devel&lt;br /&gt;
chown kde-devel:kde-devel /home/kde-devel 2&amp;gt;/dev/null || \&lt;br /&gt;
chown kde-devel:users /home/kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 选项2：使用KControl ===&lt;br /&gt;
&lt;br /&gt;
如果你已经安装了KDE3，你可以使用KDE控制中心里的用户管理模块来替代上述的命令添加用户。&lt;br /&gt;
&lt;br /&gt;
=== 设置环境 ===&lt;br /&gt;
&lt;br /&gt;
从你的普通账户下拷贝{{path|~/.bashrc}}到新的kde-devel账户下。然后，把[[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|.bashrc示例]]的内容复制并且粘贴到{{path|~kde-devel/.bashrc}}。如果你不能使用&amp;lt;tt&amp;gt;makeobj&amp;lt;/tt&amp;gt;命令，请把例子中的&amp;lt;tt&amp;gt;alias make=makeobj&amp;lt;/tt&amp;gt;这一行注释掉，这一行命令来自于KDE SDK脚本。&lt;br /&gt;
&lt;br /&gt;
这样就可以访问本教程中所使用的如&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;这类命令，同时保证了Qt、KDE、CMake文件的正确的路径。&lt;br /&gt;
&lt;br /&gt;
更多的信息，请阅读[[Getting Started/Increased Productivity in KDE4 with Scripts]]。&lt;br /&gt;
&lt;br /&gt;
=== 切换到新用户 ===&lt;br /&gt;
切换到用户kde-devel：（不要忘了输入横线）&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
su - kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在以下教程中将假定你使用&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户。&lt;br /&gt;
&lt;br /&gt;
== 开发用户的shell ==&lt;br /&gt;
&lt;br /&gt;
在有些系统上，新用户被默认配置使用{{path|/bin/sh}}。如果你的系统不是这样，请跳过这一节。使用{{path|/bin/sh}}非常不方便，你可能希望转换到{{path|/bin/bash}}或其他的shell。&lt;br /&gt;
&lt;br /&gt;
=== 选项1：作为kde-devel用户 ===&lt;br /&gt;
&lt;br /&gt;
如果你没有root特权，同时你的系统支持使用&amp;lt;tt&amp;gt;chsh&amp;lt;/tt&amp;gt;程序来转换你自己的shell，那你可以尝试使用这条命令来把你的shell转换到{{path|/bin/bash}}：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
chsh -s /bin/bash kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 选项2：作为root用户 ===&lt;br /&gt;
&lt;br /&gt;
如果你的系统带有&amp;lt;tt&amp;gt;usermod&amp;lt;/tt&amp;gt;程序，你可以以root身份运行以下命令：&amp;lt;tt&amp;gt;usermod -s /bin/bash&amp;lt;/tt&amp;gt;。另一个选择是以root身份使用&amp;lt;tt&amp;gt;vipw&amp;lt;/tt&amp;gt;程序安全的编辑你的{{path|/etc/passwd}}。在文件中找到“kde-devel”，将行尾的“{{path|/bin/sh}}”改为“{{path|/bin/bash}}”。保存你的修改并退出。&lt;br /&gt;
&lt;br /&gt;
新的shell将在你再次使用kde-devel用户登录时自动启动。&lt;br /&gt;
&lt;br /&gt;
== D-Bus ==&lt;br /&gt;
QtDBus和KDE使用的D-Bus版本为0.62、0.92或更高的版本。0.60和0.61版可能也行但未经测试。0.90和0.91版不能工作。我们建议使用1.0版（最低0.94），所以如果你还没有该版本，请考虑升级。&lt;br /&gt;
&lt;br /&gt;
如果你已经使用了最新的D-Bus版本或者根本不想升级，可以跳过这一节。&lt;br /&gt;
&lt;br /&gt;
在运行秘诀中的步骤之前，请确认你有X11的头文件和库文件。配置脚本的第五行应该输出：&lt;br /&gt;
 Building X11 code:        yes&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&lt;br /&gt;
{{tip|请确认你的环境已按照[[Getting_Started/Build/KDE4#Setting_up_the_environment|上面]]的叙述正确配置。这对&amp;lt;tt&amp;gt;cs&amp;lt;/tt&amp;gt;和&amp;lt;tt&amp;gt;cb&amp;lt;/tt&amp;gt;函数的正确运行是必须的。}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
wget http://dbus.freedesktop.org/releases/dbus/dbus-1.0.2.tar.gz&lt;br /&gt;
tar -xvzf dbus-1.0.2.tar.gz&lt;br /&gt;
cd dbus-1.0.2/&lt;br /&gt;
./configure --prefix=$DBUSDIR --localstatedir=$KDEDIR/var&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
dbus-uuidgen --ensure&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 === &lt;br /&gt;
在切换到源码目录后（第1行），从freedesktop.org下载D-Bus的源代码（第2行）并解压缩（第3行）。在进入新创建的D-Bus目录后（第4行），通过提供的{{path|configure}}脚本准备构建（第5行）。在完成D-Bus的构建（第5行）和安装（第7行）后，使用&amp;lt;tt&amp;gt;dbus-uuidgen&amp;lt;/tt&amp;gt;工具来安装机器识别文件，该文件使得D-Bus在桌面启动时自动运行（第8行）。&lt;br /&gt;
&lt;br /&gt;
注意，最后两步，你需要有对{{path|/var}}的写入权限，如果你的系统不支持sudo，你可以使用&amp;lt;tt&amp;gt;su&amp;lt;/tt&amp;gt;命令代替。例如：&amp;lt;tt&amp;gt;su -c &amp;quot;make install&amp;quot;&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
== CMake ==&lt;br /&gt;
如果你的[http://cmake.org/ CMake]&amp;gt;=2.4.5，那请跳过这一节。你可以直接使用[http://www.cmake.org/HTML/Download.html CMake网站]提供的二进制包。这里有针对一些发行版特定的安装包。针对openSUSE的CMake二进制包是由[http://software.opensuse.org/download/devel:/tools:/building/ openSUSE构建服务]提供的。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
wget http://www.cmake.org/files/v2.4/cmake-2.4.6.tar.gz&lt;br /&gt;
tar zxf cmake-2.4.6.tar.gz&lt;br /&gt;
mkdir cmake-build&lt;br /&gt;
cd cmake-build&lt;br /&gt;
../cmake-2.4.6/bootstrap&lt;br /&gt;
make&lt;br /&gt;
sudo make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
首先，我们回到&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户的源码目录（第1行），获取CMake的源码（第2行）并解压（第3行）。然后创建一个CMake的构建目录（第4行）并进入该目录（第5行）。通过运行CMake的boostrap脚本来准备CMake的构建（第6行），然后以root身份编译(第7行）并安装（第8行）CMake。&lt;br /&gt;
&lt;br /&gt;
如果你的系统没有&amp;lt;tt&amp;gt;sudo&amp;lt;/tt&amp;gt;命令,可以使用&amp;lt;tt&amp;gt;su -c &amp;quot;make install&amp;quot;&amp;lt;/tt&amp;gt;命令代替。&lt;br /&gt;
&lt;br /&gt;
== Qt ==&lt;br /&gt;
下一步，我们需要从KDE的代码仓库获得Qt4。KDE保证可以依赖任何版本的Qt 4.3来构建。Qt 4.2和之前的版本将不被支持且无法工作。Qt 4.3尚未发行，因此不一定有针对你的发行版的预编译包。你应该使用KDE Subversion服务器提供的代码副本。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/qt-copy&lt;br /&gt;
cd qt-copy&lt;br /&gt;
./apply_patches&lt;br /&gt;
./configure -qt-gif -no-exceptions -debug -fast \&lt;br /&gt;
 -prefix $QTDIR -qdbus -pch -nomake examples \&lt;br /&gt;
 -nomake demos&lt;br /&gt;
make sub-src sub-tools&lt;br /&gt;
# make install: only if QTDIR is not the current directory!&lt;br /&gt;
make install   &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们切换回&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户的主目录（第1行），然后使用subversion（svn）从KDE的代码仓库下载源代码（第2行）。在切换进入{{path|qt-copy}}目录后（第3行），我们运行{{path|qt-copy}}下脚本来管理补丁（第4行）。&lt;br /&gt;
&lt;br /&gt;
当这些补丁被应用后，我们使用&amp;lt;tt&amp;gt;configure&amp;lt;/tt&amp;gt;脚本准备构建环境（第5-7行），这里使用的几行命令和选项在{{path|qt-copy/README.qt-copy}}文件里有解释。最后，编译我们构建KDE所需的最少需求组件（第8行）并安装Qt（第9-10行）。如果想要全部的例子和demo应用，你可以单独构建他们或直接在{{path|qt-copy}}目录下运行&amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
注意这次安装并不需要root，因为它把Qt安装到了本地的{{path|$QTDIR}}。所以，这次安装只要{{path|$QTDIR}}和{{path|$HOME/qt-copy}}不同即可，如果你已经遵循并执行了上面的指令，就不会出现这种情况。&lt;br /&gt;
&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你得到了“error: X11/Xlib.h: No such file or directory”，请安装&amp;lt;tt&amp;gt;xorg&amp;lt;/tt&amp;gt;（实际的名称可能根据操作系统的不同而改变，例如在基于Ubuntu的系统Kubuntu上，这个包叫&amp;lt;tt&amp;gt;xorg-dev&amp;lt;/tt&amp;gt;）的开发包。&lt;br /&gt;
&lt;br /&gt;
如果你在configure时获得缺失定义的错误，请检查&amp;lt;tt&amp;gt;$QMAKESPEC&amp;lt;/tt&amp;gt;的值。一些发行版将这个值设置为系统安装的Qt，如果&amp;lt;tt&amp;gt;unset QMAKESPEC&amp;lt;/tt&amp;gt;可以解决这个问题，你可能希望把它添加到&amp;lt;tt&amp;gt;~/.bashrc&amp;lt;/tt&amp;gt;脚本中。&lt;br /&gt;
&lt;br /&gt;
如果你得到错误“.pch/debug-shared/QtCore”，这是因为Qt 4.3激活了你的gcc所支持的一些预编译头文件，但因为一些原因它不能为你工作。如果你使用distcc，使用-no-pch来配置Qt。如果你使用icecream，请从其svn主分支升级到最新版本。&lt;br /&gt;
&lt;br /&gt;
如果你的gcc支持，Qt4.3允许使用预编译的头文件，但因为某些原因它不工作。如果你使用distcc,使用 -no-pch来configure Qt.如果你使用icecream，从svn上升级到最新的版本。&lt;br /&gt;
&lt;br /&gt;
尝试运行一些Qt程序，比如{{program|assistant}}。如果它在QSpanData::adjustSpanMethods崩溃，那你可能使用了oxygen风格。尝试删除{{path|/lib/kde4/plugins/styles/kstyle-oxygen.so}}和{{path|/lib/kde4/plugins/styles/oxygen.so}}。当然，如果它们存在的话。&lt;br /&gt;
&lt;br /&gt;
== Strigi ==&lt;br /&gt;
&lt;br /&gt;
{{warning|如果你没有阅读[[Getting_Started/Build/KDE4_(zh_CN)#设置环境|设置环境]]而直接跳到这里的话，'''那下面提供的秘诀将无法工作'''。&lt;br /&gt;
&lt;br /&gt;
秘诀没有错误，&amp;lt;tt&amp;gt;cs&amp;lt;/tt&amp;gt;和&amp;lt;tt&amp;gt;cb&amp;lt;/tt&amp;gt;也没有排版错误。为了这份教程可以正确的工作，你'''需要'''根据这些指令正确设置你的环境。}}&lt;br /&gt;
&lt;br /&gt;
获取文件元数据（file metadata）的代码现在依赖于Strigi。要安装Strigi，你需要libz、libbz2、openssl（libcrypto或者libssl）、libclucene（&amp;gt;=0.9.16）以及libxml2或libexpat的库和头文件。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/kdesupport/strigi&lt;br /&gt;
cd strigi&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
先切换到源码的根目录下（第1行）。使用subversion下载Strigi的源代码（第2行），进入新的{{path|~/src/strigi}}目录（第3行），开始构建（第4行）。这将使我们在构建完成后仍留在Strigi的构建目录里。&lt;br /&gt;
&lt;br /&gt;
== kdelibs ==&lt;br /&gt;
&lt;br /&gt;
构建好Qt4和Strigi之后，我们现在可以开始构建KDE的基础库了，如果你使用了上述的[[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|.bashrc]]，里面就会有那些新的功能。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd $KDE_SRC&lt;br /&gt;
mkdir KDE &amp;amp;&amp;amp; cd KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs&lt;br /&gt;
cd kdelibs&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{tip|如果命令失败，并提示“CMake requires an out of source build directory”，请移除~/src/KDE/kdelibs/CMakeCache.txt，然后再次尝试。}}&lt;br /&gt;
&lt;br /&gt;
{{tip|如果&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;还输出同样的错误，那试试这个：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=$KDEDIR \&lt;br /&gt;
-DCMAKE_BUILD_TYPE=debugfull DKDE4_BUILD_TESTS=ON \&lt;br /&gt;
~/src/KDE/kdelibs&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们先进入源文件的根目录（第1行），然后执行make并进入KDE目录（第2行）。使用subversion下载kdelibs的源码（第3行），进入新的{{path|~/src/KDE/kdelibs}}目录（第4行），并开始构建（第5行）。这将使我们在构建完成后仍留在kdelibs的构建目录里。&lt;br /&gt;
&lt;br /&gt;
{{tip|在这里你的系统上可能会缺少某些依赖关系！可以通过&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;的输出观察到这些缺少的依赖关系。你可能希望先执行&amp;lt;tt&amp;gt;cmake ~/src/KDE/MODULE_NAME&amp;lt;/tt&amp;gt;来编译一些kde模块（比如kdelibs、kdepimlibs等）}}&lt;br /&gt;
&lt;br /&gt;
=== 附加的KDE特有CMake模块 ===&lt;br /&gt;
在{{path|kdelibs/cmake/modules/}}中有一些构建KDE4应用所需的附加CMake模块，它们会随kdelibs同时安装。&lt;br /&gt;
&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你在编译kdelibs时遇到问题，请先确认[[Getting_Started/Build/KDE4_(zh_CN)#所需软件|所需软件]]中提到的软件是否已能正确安装运行。其他的可能包括：&lt;br /&gt;
* 如果你得到错误信息说“Please create a separate build directory and run 'cmake path_to_kdelibs [options]' there.”，那么你需要在运行cmakekde之前改变你的构建目录（例：&amp;lt;tt&amp;gt;cs KDE/kdelibs &amp;amp;&amp;amp; cb &amp;amp;&amp;amp; cmakekde&amp;lt;/tt&amp;gt;）&lt;br /&gt;
* 如果找不到Qt或者找到了错误版本的Qt，请确认路径中的第一个qmake就是你需要的qmake。&lt;br /&gt;
* 如果还是有问题，尝试CMake make-option &amp;lt;tt&amp;gt;--keep-going&amp;lt;/tt&amp;gt;。&lt;br /&gt;
* 这里你需要libungif库，不然你将得到象这样的错误信息“&amp;lt;tt&amp;gt;Could NOT find GIF&amp;lt;/tt&amp;gt;”。&lt;br /&gt;
* Qt-4.3升级：如果你在kjsembed中得到关于QScriptEngine的链接错误，编辑kdelibs中的CMakeCache.txt并移除关于QT_QTUITOOLS_LIBRARY的那些行，然后再次输入make（这个静态库有新的依赖关系，需要运行cmake的代码添加它运行所需要的依赖）。&lt;br /&gt;
&lt;br /&gt;
== kdepimlibs ==&lt;br /&gt;
在&amp;lt;tt&amp;gt;kdelibs&amp;lt;/tt&amp;gt;之后，''kdebase''之前，你需要构建和安装''kdepimlibs''。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdepimlibs&lt;br /&gt;
cd kdepimlibs&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们先进入KDE源码目录（第1行）。使用subversion下载kdepimlibs的源码（第2行），进入新的{{path|~/src/KDE/kdepimlibs}}目录（第3行），并开始构建（第4行）。这将使我们在构建完成后仍留在&amp;lt;tt&amp;gt;kdepimlibs&amp;lt;/tt&amp;gt;的构建目录里。&lt;br /&gt;
&lt;br /&gt;
== kdebase ==&lt;br /&gt;
一些kioslaves需要kdebase。&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdebase&lt;br /&gt;
cd kdebase&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你在编译kdebase时遇到问题：&lt;br /&gt;
* 请确认你安装了&amp;lt;tt&amp;gt;libxss的头文件&amp;lt;/tt&amp;gt;。（如果你没有这些头文件，通常你会得到“undefined references on xscreensaver objects”）&lt;br /&gt;
* 那个&amp;lt;tt&amp;gt;meinproc&amp;lt;/tt&amp;gt;必须放到{{path|/home/kde-devel/kde/bin/meinproc}}&lt;br /&gt;
* 如果cmakekde无法找到kdepimlibs的路径，请编辑{{path|$KDE_BUILD/kdebase/CMakeCache.txt}}并手工设置&amp;lt;tt&amp;gt;KDEPIMLIBS_INCLUDE_DIR:PATH=$KDE_BUILD/kdepimlibs&amp;lt;/tt&amp;gt;&lt;br /&gt;
* 如果你得到错误说“Please set the following variables: X11_XTest_LIB(ADVANCED)”， 请安装&amp;lt;tt&amp;gt;Xtst&amp;lt;/tt&amp;gt;的开发包。有些系统上，这个包独立于&amp;lt;tt&amp;gt;xext&amp;lt;/tt&amp;gt;，并取名为&amp;lt;tt&amp;gt;x11proto-xext-dev&amp;lt;/tt&amp;gt;或者&amp;lt;tt&amp;gt;libxtst-dev&amp;lt;/tt&amp;gt;。在安装完软件包后，你可能需要移除构建目录下的CMakeCache.txt。&lt;br /&gt;
* 和“X11_Xinerama_LIB (ADVANCED)”一样，你需要安装&amp;lt;tt&amp;gt;xinerama&amp;lt;/tt&amp;gt;的开发包&lt;br /&gt;
* 如果你得到错误说“Please set the following variables: FONTCONFIG_INCLUDE_DIR, FONTCONFIG_LIBRARIES (ADVANCED)”，那么你需要安装libfontconfig。&lt;br /&gt;
	&lt;br /&gt;
== 生成本地API文档 ==&lt;br /&gt;
尽管我们在[http://api.kde.org api.kde.org]上提供了KDE的API文档，在你的硬盘上保存一份副本往往也是有必要的，例如你想要通过[[Getting_Started/Set_up_KDE_4_for_development#KDevelop|KDevelop]]浏览这些文档或你无法上网时。&lt;br /&gt;
&lt;br /&gt;
注意，生成API文档需要几个小时并占用差不多500M的磁盘空间。文档的生成通过{{path|kdelibs/doc/api}}下的一个脚本完成，运行这个脚本你需要&amp;lt;tt&amp;gt;doxygen&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
为了构建kdelibs的API文档，请输入下列命令：&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
mkdir apidox&lt;br /&gt;
cd apidox&lt;br /&gt;
../kdelibs/doc/api/doxygen.sh ../kdelibs/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 成功了！ ==&lt;br /&gt;
你现在可以使用构建kdebase一样的方法构建其他svn模块，运行并测试KDE4或者编写你自己的补丁和应用程序。&lt;br /&gt;
&lt;br /&gt;
关于如何在你的新的KDE4环境下开始工作，请阅读[[Getting Started/Set up KDE 4 for development#Nested_KDE_4_session|Starting a KDE4 Environment and Applications]]。&lt;br /&gt;
&lt;br /&gt;
[[Category:Build KDE]]&lt;br /&gt;
[[Category:KDE4]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Getting_Started/Build/KDE4_(zh_CN)</id>
		<title>Getting Started/Build/KDE4 (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Getting_Started/Build/KDE4_(zh_CN)"/>
				<updated>2007-04-03T14:40:01Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--Huanzhou Zhu初稿，Liang Qi整理!--&amp;gt;&lt;br /&gt;
{{Template:I18n/Getting_Started/Build/KDE4}}&lt;br /&gt;
{{TutorialBrowser|&lt;br /&gt;
&lt;br /&gt;
series=开始|&lt;br /&gt;
&lt;br /&gt;
name=从源代码构建KDE4|&lt;br /&gt;
&lt;br /&gt;
pre=[[../../Sources/Anonymous_SVN|Anonymous SVN Quickstart Guide]]|&lt;br /&gt;
&lt;br /&gt;
next=[[../../Set_up_KDE_4_for_development|Starting a KDE4 Environment and Applications]]|&lt;br /&gt;
&lt;br /&gt;
reading=[http://kdesvn-build.kde.org/ kdesvn-build: The KDE From Subversion Build Tool]&amp;lt;br&amp;gt;[[../../Increased_Productivity_in_KDE4_with_Scripts|Increased Productivity in KDE4 with Scripts]]&amp;lt;br&amp;gt;[[Development/Tutorials/CMake_(zh_CN) |CMake介绍]]&amp;lt;br&amp;gt;[[../KDE4/FreeBSD|FreeBSD notes]]&amp;lt;br&amp;gt;[[../KDE4/Mac OS X|Instructions for Mac OS X]]|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== 摘要 ==&lt;br /&gt;
&lt;br /&gt;
这份教程介绍了一种使KDE运行于Linux/BSD系统的方法。这份教程通篇使用了bash shell。如果你对在其他系统（如：Solaris、MacOS或Microsoft Windows）上构建KDE有兴趣, 请访问[[../|构建]]页面 并在最下方的链接处选择相应的操作系统。&lt;br /&gt;
&lt;br /&gt;
{{note|当周一提交了重大的修改时，构建错误的风险会很大。可以通过[http://developer.kde.org/~dirk/dashboard/ Dashboard]报告意料之外的破坏。非常欢迎大家修复失败的模块。&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== 所需软件 ==&lt;br /&gt;
&lt;br /&gt;
首先你必须安装以下软件，你才能成功完成这份教程：&lt;br /&gt;
* 来自gcc项目的gcc和g++, 最好是4.1或更高的版本。&lt;br /&gt;
* svn（Subversion客户端）&lt;br /&gt;
* pkg-config&lt;br /&gt;
* X11和OpenGL的开发库及头文件&lt;br /&gt;
* libjpeg、libpng、libungif、libxml2和libxslt的开发库及头文件&lt;br /&gt;
* makeobj脚本。可以做为kdesdk-scripts(debian)或类似的软件包的部件来安装，或者直接从[http://websvn.kde.org/trunk/KDE/kdesdk/scripts/makeobj?revision=600932&amp;amp;view=markup WebSVN]下载该软件本身。&lt;br /&gt;
* shared-mime-info软件包，是KDE现在使用的freedesktop MIME标准。&lt;br /&gt;
&lt;br /&gt;
你也许还需要安装以下软件：&lt;br /&gt;
* bash&lt;br /&gt;
&lt;br /&gt;
== 为KDE4开发创建一个用户账户 ==&lt;br /&gt;
&lt;br /&gt;
{{Note|&lt;br /&gt;
一些人喜欢为KDE 4使用一个单独的用户帐户（例如一个旧的bug可能因为错误很删除了一些文件），并且后面的这些指令都是使用这种方式进行的。&lt;br /&gt;
&lt;br /&gt;
使用一个单独的用户帐户做任何事情都是很有效率的，有关细节请参考[[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts|Increased Productivity in KDE4 with Scripts]]。&lt;br /&gt;
&lt;br /&gt;
你还可以遵循下面的指令，但并不把这些环境变量保存到你的&amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt;中，请把他们放到一个单独的文件中，以备你在切换到KDE 4环境中使用。&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== 选项1：命令行 ===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
useradd -m kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
或者：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
useradd kde-devel&lt;br /&gt;
mkdir /home/kde-devel&lt;br /&gt;
passwd kde-devel&lt;br /&gt;
chown kde-devel:kde-devel /home/kde-devel 2&amp;gt;/dev/null || \&lt;br /&gt;
chown kde-devel:users /home/kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 选项2：使用KControl ===&lt;br /&gt;
&lt;br /&gt;
如果你已经安装了KDE3，你可以使用KDE控制中心里的用户模块来替代上述的命令以添加用户。&lt;br /&gt;
&lt;br /&gt;
=== 设置环境 ===&lt;br /&gt;
&lt;br /&gt;
Copy the {{path|~/.bashrc}} from your normal user account to the new kde-devel account. Next, copy and paste the contents of the [[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|example .bashrc]] into {{path|~kde-devel/.bashrc}}. Be sure to comment out the line &amp;lt;tt&amp;gt;alias make=makeobj&amp;lt;/tt&amp;gt; if you do not have the &amp;lt;tt&amp;gt;makeobj&amp;lt;/tt&amp;gt; command available, this command comes with the KDE SDK scripts.&lt;br /&gt;
从你的普通账户下拷贝{{path|~/.bashrc}}到新的kde-devel账户下。然后，把[[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|.bashrc实例]]的内容复制并且粘贴到{{path|~kde-devel/.bashrc}}。如果你不能使用&amp;lt;tt&amp;gt;makeobj&amp;lt;/tt&amp;gt;命令，请把例子中的&amp;lt;tt&amp;gt;alias make=makeobj&amp;lt;/tt&amp;gt;这一行注释掉，这一行命令来自于KDE SDK脚本。&lt;br /&gt;
&lt;br /&gt;
这样就可以访问本教程中所使用的如&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;这类命令，同时保证了Qt、KDE、CMake文件的正确的路径。&lt;br /&gt;
&lt;br /&gt;
更多的信息，请阅读[[Getting Started/Increased Productivity in KDE4 with Scripts]]。&lt;br /&gt;
&lt;br /&gt;
=== 切换到新用户 ===&lt;br /&gt;
切换到用户kde-devel：（不要忘了破折号）&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
su - kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在以下教程中将假定你使用&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户。&lt;br /&gt;
&lt;br /&gt;
== 开发用户的shell ==&lt;br /&gt;
&lt;br /&gt;
有些系统上，新用户被默认配置使用{{path|/bin/sh}}。如果你得系统不是这样，请跳过这一节。使用{{path|/bin/sh}}非常的不方便，你可能希望转换到{{path|/bin/bash}}或其他的shell。&lt;br /&gt;
&lt;br /&gt;
=== 选项1：作为kde-devel用户 ===&lt;br /&gt;
&lt;br /&gt;
如果你没有root特权，同时你的系统支持使用&amp;lt;tt&amp;gt;chsh&amp;lt;/tt&amp;gt;程序来转换你自己的shell，那你可以尝试使用这条命令来把你的shell转换到{{path|/bin/bash}}：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
chsh -s /bin/bash kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 选项2：作为root用户 ===&lt;br /&gt;
&lt;br /&gt;
如果你得系统带有&amp;lt;tt&amp;gt;usermod&amp;lt;/tt&amp;gt;程序，你可以以root身份运行以下命令：&amp;lt;tt&amp;gt;usermod -s /bin/bash&amp;lt;/tt&amp;gt;。另一个选择是以root身份使用&amp;lt;tt&amp;gt;vipw&amp;lt;/tt&amp;gt;程序安全的编辑你的{{path|/etc/passwd}}。在文件中找到“kde-devel”，将行尾的“{{path|/bin/sh}}”改为“{{path|/bin/bash}}”。保存你的修改并退出。&lt;br /&gt;
&lt;br /&gt;
新的shell将在你再次使用kde-devel用户登录时自动启动。&lt;br /&gt;
&lt;br /&gt;
== D-Bus ==&lt;br /&gt;
QtDBus和KDE使用D-Bus版本为0.62、0.92或更高的版本。0.60和0.61版也可能工作但未经测试。0.90和0.91版不能工作。我们建议使用1.0版（最低0.94），所以如果你还没有该版本，请考虑升级。&lt;br /&gt;
&lt;br /&gt;
你可以跳过这一节如果你已经使用了最新的D-Bus版本或者你不想升级。&lt;br /&gt;
&lt;br /&gt;
在运行秘诀中的步骤之前，请确认你有X11的头文件和库文件。配置脚本的第五行应该输出：&lt;br /&gt;
 Building X11 code:        yes&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&lt;br /&gt;
{{tip|请确认你的环境已按照[[Getting_Started/Build/KDE4#Setting_up_the_environment|上面]]叙述正确配置。这对&amp;lt;tt&amp;gt;cs&amp;lt;/tt&amp;gt;和&amp;lt;tt&amp;gt;cb&amp;lt;/tt&amp;gt;函数的正确运行是必须的。}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
wget http://dbus.freedesktop.org/releases/dbus/dbus-1.0.2.tar.gz&lt;br /&gt;
tar -xvzf dbus-1.0.2.tar.gz&lt;br /&gt;
cd dbus-1.0.2/&lt;br /&gt;
./configure --prefix=$DBUSDIR --localstatedir=$KDEDIR/var&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
dbus-uuidgen --ensure&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 === &lt;br /&gt;
在切换到源码目录后（第1行），从freedesktop.org下载了D-Bus的源代码（第2行）并解压缩（第3行）。在进入新创建的D-Bus目录后（第4行），通过提供的{{path|configure}}脚本准备构建（第5行）。在完成D-Bus的构建（第5行）和安装（第7行）后，使用&amp;lt;tt&amp;gt;dbus-uuidgen&amp;lt;/tt&amp;gt;工具来安装机器识别文件，该文件使得bus在桌面启动时自动运行（第8行）。&lt;br /&gt;
&lt;br /&gt;
注意，最后两步，你需要有对{{path|/var}}的写入权限，如果你的系统不支持sudo，你可以使用&amp;lt;tt&amp;gt;su&amp;lt;/tt&amp;gt;命令代替。例如：&amp;lt;tt&amp;gt;su -c &amp;quot;make install&amp;quot;&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
== CMake ==&lt;br /&gt;
如果你的[http://cmake.org/ CMake]&amp;gt;=2.4.5，那请跳过这一节。你可以直接使用[http://www.cmake.org/HTML/Download.html CMake网站]提供的二进制包。这里有针对一些发行版特定的软件包。针对openSUSE的CMake二进制包通过[http://software.opensuse.org/download/devel:/tools:/building/ openSUSE构建服务]提供。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
wget http://www.cmake.org/files/v2.4/cmake-2.4.6.tar.gz&lt;br /&gt;
tar zxf cmake-2.4.6.tar.gz&lt;br /&gt;
mkdir cmake-build&lt;br /&gt;
cd cmake-build&lt;br /&gt;
../cmake-2.4.6/bootstrap&lt;br /&gt;
make&lt;br /&gt;
sudo make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
首先，我们回到&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户的源码目录（第1行），获取CMake的源码（第2行）并解压（第3行）。然后创建一个CMake的构建目录（第4行）并进入该目录（第5行）。通过运行CMake的boostrap脚本来准备Cmake的构建（第6行），然后以root身份make(第7行）安装（第8行）CMake。&lt;br /&gt;
&lt;br /&gt;
如果你的系统没有&amp;lt;tt&amp;gt;sudo&amp;lt;/tt&amp;gt;命令,你可以使用&amp;lt;tt&amp;gt;su -c &amp;quot;make install&amp;quot;&amp;lt;/tt&amp;gt;命令代替。&lt;br /&gt;
&lt;br /&gt;
== Qt ==&lt;br /&gt;
下一步，我们需要从KDE的代码仓库获得Qt4。KDE保证可以依赖任何版本的Qt 4.3来构建。Qt 4.2和之前的版本不被支持并且将不能工作。这是一个未发行的版本，因此你的发行版不一定有打包好的软件包。你应该使用KDE Subversion服务器提供的拷贝。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/qt-copy&lt;br /&gt;
cd qt-copy&lt;br /&gt;
./apply_patches&lt;br /&gt;
./configure -qt-gif -no-exceptions -debug -fast \&lt;br /&gt;
 -prefix $QTDIR -qdbus -pch -nomake examples \&lt;br /&gt;
 -nomake demos&lt;br /&gt;
make sub-src sub-tools&lt;br /&gt;
# make install: only if QTDIR is not the current directory!&lt;br /&gt;
make install   &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们切换回&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户的主目录（第1行），然后使用subversion（svn）从KDE的代码仓库下载源代码（第2行）。在切换进入{{path|qt-copy}}目录后（第3行），我们运行{{path|qt-copy}}下脚本来管理补丁（第4行）。&lt;br /&gt;
&lt;br /&gt;
当这些补丁被应用后，我们使用&amp;lt;tt&amp;gt;configure&amp;lt;/tt&amp;gt;脚本准备构建环境（第5-7行）。这里使用的这几行命令和选项在{{path|qt-copy/README.qt-copy}}文件里有解释。最后，我们构建KDE所需的最少需求（第8行）并安装Qt（第9-10行）。如果想要全部的例子和demo应用，你可以单独构建他们或直接在{{path|qt-copy}}目录下运行&amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
注意这次安装并不需要root，因为它把Qt安装到了本地的{{path|$QTDIR}}。所以，这次安装只需要{{path|$QTDIR}}和{{path|$HOME/qt-copy}}不同即可，如果你已经遵循这些指令执行了，就不会出现这种情况。&lt;br /&gt;
&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你得到了“error: X11/Xlib.h: No such file or directory”，请安装&amp;lt;tt&amp;gt;xorg&amp;lt;/tt&amp;gt;（实际的名称可能根据操作系统的不同而改变，例如在基于Ubuntu的系统Kubuntu上，这个包叫&amp;lt;tt&amp;gt;xorg-dev&amp;lt;/tt&amp;gt;）的开发包。&lt;br /&gt;
&lt;br /&gt;
如果你在configure时获得缺失定义的错误，请检查&amp;lt;tt&amp;gt;$QMAKESPEC&amp;lt;/tt&amp;gt;的值。一些发行版将这个值设置为系统安装的Qt，如果&amp;lt;tt&amp;gt;unset QMAKESPEC&amp;lt;/tt&amp;gt;可以解决这个问题，你可能希望把它添加到&amp;lt;tt&amp;gt;~/.bashrc&amp;lt;/tt&amp;gt;脚本中。&lt;br /&gt;
&lt;br /&gt;
如果你得到错误“.pch/debug-shared/QtCore”，这是因为Qt 4.3激活了你的gcc所支持的一些预编译头文件，但因为一些原因它不能为你工作。如果你使用distcc，使用-no-pch来配置Qt。如果你使用icecream，从svn主线上升级到最新的版本。&lt;br /&gt;
&lt;br /&gt;
如果你的gcc支持，Qt4.3允许使用预编译的头文件，但因为某些原因它不工作。如果你使用distcc,使用 -no-pch来configure Qt.如果你使用icecream，从svn上升级到最新的版本。&lt;br /&gt;
&lt;br /&gt;
尝试运行一些Qt程序，比如{{program|assistant}}。如果它在QSpanData::adjustSpanMethods崩溃，那你可能使用了oxygen风格。尝试删除{{path|/lib/kde4/plugins/styles/kstyle-oxygen.so}}和{{path|/lib/kde4/plugins/styles/oxygen.so}}。当然，如果它们存在的话。&lt;br /&gt;
&lt;br /&gt;
== Strigi ==&lt;br /&gt;
&lt;br /&gt;
{{warning|如果你没有阅读[[Getting_Started/Build/KDE4_(zh_CN)#设置环境|设置环境]]而直接跳到这里的话，'''那下面提供的秘诀将无法工作'''。&lt;br /&gt;
&lt;br /&gt;
秘诀没有错误，&amp;lt;tt&amp;gt;cs&amp;lt;/tt&amp;gt;和&amp;lt;tt&amp;gt;cb&amp;lt;/tt&amp;gt;也没有排版错误。为了这份教程可以正确的工作，你'''需要'''根据这些指令正确设置你的环境。}}&lt;br /&gt;
&lt;br /&gt;
获取文件元数据（file metadata）的代码现在依赖于Strigi。要安装Strigi，你需要libz、libbz2、openssl（libcrypto或者libssl）、libclucene（&amp;gt;=0.9.16）以及libxml2或libexpat的库和头文件。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/kdesupport/strigi&lt;br /&gt;
cd strigi&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
先切换到源码的根目录下（第1行）。使用subversion下载Strigi的源代码（第2行），进入新的{{path|~/src/strigi}}目录（第3行），开始构建（第4行）。这将使我们在构建完成后仍留在Strigi的构建目录里。&lt;br /&gt;
&lt;br /&gt;
== kdelibs ==&lt;br /&gt;
&lt;br /&gt;
构建好Qt4和Strigi之后，我们现在可以开始构建KDE的基础库了，如果你使用了上述的[[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|.bashrc]，里面就会有那些新的功能了。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd $KDE_SRC&lt;br /&gt;
mkdir KDE &amp;amp;&amp;amp; cd KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs&lt;br /&gt;
cd kdelibs&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{tip|如果命令失败，并提示“CMake requires an out of source build directory”，请移除~/src/KDE/kdelibs/CMakeCache.txt，然后再次尝试。}}&lt;br /&gt;
&lt;br /&gt;
{{tip|如果&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;还输出同样的错误，那试试这个：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=$KDEDIR \&lt;br /&gt;
-DCMAKE_BUILD_TYPE=debugfull DKDE4_BUILD_TESTS=ON \&lt;br /&gt;
~/src/KDE/kdelibs&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们先进入源文件的根目录（第1行），然后执行make并进入KDE目录（第2行）。使用subversion下载kdelibs的源码（第3行），进入新的{{path|~/src/KDE/kdelibs}}目录（第4行），并开始构建（第5行）。这将使我们在构建完成后仍留在kdelibs的构建目录里。&lt;br /&gt;
&lt;br /&gt;
{{tip|这里你的系统上可能会缺少某些依赖关系！可以通过&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;的输出观察到这些缺少的依赖关系。你可能希望先执行&amp;lt;tt&amp;gt;cmake ~/src/KDE/MODULE_NAME&amp;lt;/tt&amp;gt;来编译一些kde模块（比如kdelibs、kdepimlibs等）}}&lt;br /&gt;
&lt;br /&gt;
=== 附加的KDE特定的CMake模块 ===&lt;br /&gt;
在{{path|kdelibs/cmake/modules/}}中有一些构建KDE4应用所需的附加的CMake模块。它们在kdelibs安装时会被安装。&lt;br /&gt;
&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你在编译kdelibs时遇到问题，请先确认[[Getting_Started/Build/KDE4_(zh_CN)#所需软件|所需软件]]中提到的软件是否正确的安装并且工作。其他的可能包括：&lt;br /&gt;
* 如果你得到错误信息说“Please create a separate build directory and run 'cmake path_to_kdelibs [options]' there.”，那么你需要在运行cmakekde之前改变你的构建目录（例：&amp;lt;tt&amp;gt;cs KDE/kdelibs &amp;amp;&amp;amp; cb &amp;amp;&amp;amp; cmakekde&amp;lt;/tt&amp;gt;）&lt;br /&gt;
* 如果Qt没有被找到或者找到了Qt的错误版本，请确认路径中的第一个qmake就是你需要的qmake。&lt;br /&gt;
* 如果还是有问题，尝试CMake make-option &amp;lt;tt&amp;gt;--keep-going&amp;lt;/tt&amp;gt;。&lt;br /&gt;
* 这里你需要libungif库，不然你将得到象这样的错误信息“&amp;lt;tt&amp;gt;Could NOT find GIF&amp;lt;/tt&amp;gt;”。&lt;br /&gt;
* Qt-4.3升级：如果你在kjsembed中得到关于QScriptEngine的链接错误，编辑kdelibs中的CMakeCache.txt并移除关于QT_QTUITOOLS_LIBRARY的那些行，然后再次输入make.（这个静态库有新的依赖关系，需要运行cmake的代码添加它运行所需要的）&lt;br /&gt;
&lt;br /&gt;
== kdepimlibs ==&lt;br /&gt;
在&amp;lt;tt&amp;gt;kdelibs&amp;lt;/tt&amp;gt;之后，''kdebase''之前，你需要构建和安装''kdepimlibs''。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdepimlibs&lt;br /&gt;
cd kdepimlibs&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们先进入KDE源码目录（第1行）。使用subversion下载kdepimlibs的源码（第2行），进入新的{{path|~/src/KDE/kdepimlibs}}目录（第3行），并开始构建（第4行）。这将使我们在构建完成后仍留在&amp;lt;tt&amp;gt;kdepimlibs&amp;lt;/tt&amp;gt;的构建目录里。&lt;br /&gt;
&lt;br /&gt;
== kdebase ==&lt;br /&gt;
一些kioslaves需要kdebase。&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdebase&lt;br /&gt;
cd kdebase&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你在编译kdebase时遇到问题：&lt;br /&gt;
* 请确认你安装了&amp;lt;tt&amp;gt;libxss的头文件&amp;lt;/tt&amp;gt;。（如果你没有这些头文件，通常你会得到“undefined references on xscreensaver objects”）&lt;br /&gt;
* 那个&amp;lt;tt&amp;gt;meinproc&amp;lt;/tt&amp;gt;必须放到{{path|/home/kde-devel/kde/bin/meinproc}}&lt;br /&gt;
* 如果cmakekde无法找到kdepimlibs的路径，请编辑{{path|$KDE_BUILD/kdebase/CMakeCache.txt}}并手工设置&amp;lt;tt&amp;gt;KDEPIMLIBS_INCLUDE_DIR:PATH=$KDE_BUILD/kdepimlibs&amp;lt;/tt&amp;gt;&lt;br /&gt;
* 如果你得到错误说“Please set the following variables: X11_XTest_LIB(ADVANCED)”， 请安装&amp;lt;tt&amp;gt;Xtst&amp;lt;/tt&amp;gt;的开发包。有些系统上，这个包独立于&amp;lt;tt&amp;gt;xext&amp;lt;/tt&amp;gt;，并取名为&amp;lt;tt&amp;gt;x11proto-xext-dev&amp;lt;/tt&amp;gt;或者&amp;lt;tt&amp;gt;libxtst-dev&amp;lt;/tt&amp;gt;。在安装完软件包后，你可能需要移除构建目录下的CMakeCache.txt。&lt;br /&gt;
* 和“X11_Xinerama_LIB (ADVANCED)”一样，你需要安装&amp;lt;tt&amp;gt;xinerama&amp;lt;/tt&amp;gt;的开发包&lt;br /&gt;
* 如果你得到错误说“Please set the following variables: FONTCONFIG_INCLUDE_DIR, FONTCONFIG_LIBRARIES (ADVANCED)”，那么你需要安装libfontconfig。&lt;br /&gt;
	&lt;br /&gt;
== 生成本地API文档 ==&lt;br /&gt;
虽然KDE的API文档在[http://api.kde.org api.kde.org]上提供，有时在你的硬盘上有一份拷贝也是有用的，例如你想要通过[[Getting_Started/Set_up_KDE_4_for_development#KDevelop|KDevelop]]浏览这些文档或你无法上网时。&lt;br /&gt;
&lt;br /&gt;
注意，生成API文档需要几个小时并占用差不多500M的磁盘空间。文档的生成通过{{path|kdelibs/doc/api}}下的一个脚本完成，运行这个脚本你需要&amp;lt;tt&amp;gt;doxygen&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
为了构建kdelibs的API文档，请输入下列命令：&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
mkdir apidox&lt;br /&gt;
cd apidox&lt;br /&gt;
../kdelibs/doc/api/doxygen.sh ../kdelibs/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 成功了！ ==&lt;br /&gt;
你现在可以使用构建kdebase一样的方法构建其他svn模块，运行并测试KDE4或者编写你自己的补丁和应用程序。&lt;br /&gt;
&lt;br /&gt;
关于如何在你的新的KDE4环境下开始工作，请阅读[[Getting Started/Set up KDE 4 for development#Nested_KDE_4_session|Starting a KDE4 Environment and Applications]]。&lt;br /&gt;
&lt;br /&gt;
[[Category:Build KDE]]&lt;br /&gt;
[[Category:KDE4]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Getting_Started/Build/KDE4</id>
		<title>Getting Started/Build/KDE4</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Getting_Started/Build/KDE4"/>
				<updated>2007-04-03T14:38:47Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add a i18n link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:I18n/Getting_Started/Build/KDE4}}&lt;br /&gt;
&lt;br /&gt;
{{TutorialBrowser|&lt;br /&gt;
&lt;br /&gt;
series=Getting Started|&lt;br /&gt;
&lt;br /&gt;
name=Building KDE4 From Source|&lt;br /&gt;
&lt;br /&gt;
pre=[[../../Sources/Anonymous_SVN|Anonymous SVN Quickstart Guide]]|&lt;br /&gt;
&lt;br /&gt;
next=[[../../Set_up_KDE_4_for_development|Starting a KDE4 Environment and Applications]]|&lt;br /&gt;
&lt;br /&gt;
reading=[http://kdesvn-build.kde.org/ kdesvn-build: The KDE From Subversion Build Tool]&amp;lt;br&amp;gt;[[../../Increased_Productivity_in_KDE4_with_Scripts|Increased Productivity in KDE4 with Scripts]]&amp;lt;br&amp;gt;[[Development/Tutorials/CMake |Introduction to CMake]]&amp;lt;br&amp;gt;[[../KDE4/FreeBSD|FreeBSD notes]]&amp;lt;br&amp;gt;[[../KDE4/Mac OS X|Instructions for Mac OS X]]|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
&lt;br /&gt;
This tutorial shows one way to get KDE from trunk running on Linux/BSD systems. Throughout the tutorial the bash shell is used. If you are interested in building KDE on other systems such as Solaris, MacOS or Microsoft Windows, please visit the [[../|Build]] page and see the links at the bottom for the respective operating systems.&lt;br /&gt;
&lt;br /&gt;
{{note|Expect a higher risk of build failure on Mondays when critical changes are implemented. [http://developer.kde.org/~dirk/dashboard/ Dashboard] reports unexpected breakages. You are encouraged to fix failing modules.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Required Software ==&lt;br /&gt;
&lt;br /&gt;
The following must be installed first before you can successfully complete this tutorial:&lt;br /&gt;
* gcc and g++ from the gcc project, preferably version 4.1 or higher&lt;br /&gt;
* svn, the subversion revision control client&lt;br /&gt;
* pkg-config&lt;br /&gt;
* development libraries and headers for X11 and OpenGL&lt;br /&gt;
* development libraries and headers for libjpeg, libpng, libungif, libclucene, libxml2 and libxslt&lt;br /&gt;
* the makeobj script. You can install it as part of a kdesdk-scripts (debian) or similar package, or just download it itself from [http://websvn.kde.org/trunk/KDE/kdesdk/scripts/makeobj?revision=600932&amp;amp;view=markup WebSVN]&lt;br /&gt;
* the shared-mime-info package, which is the freedesktop MIME standard KDE is using now&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You may also want to have the following installed:&lt;br /&gt;
* bash&lt;br /&gt;
&lt;br /&gt;
== Create a user account for KDE4 development ==&lt;br /&gt;
&lt;br /&gt;
{{Note|&lt;br /&gt;
Some people like to have a separate user account for KDE 4 (for instance an old bug deleted files by mistake), and the instructions below were written with that approach.&lt;br /&gt;
&lt;br /&gt;
However it is much more efficient to do everything with a single user account, see [[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts|Increased Productivity in KDE4 with Scripts]]&lt;br /&gt;
for more details. &lt;br /&gt;
&lt;br /&gt;
You can still follow the instructions below, but don't put the environment variables in your &amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt;, put them in a separate file that you source to switch to the KDE 4 environment.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Option 1: Command Line ===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
useradd -m kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
or:&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
useradd kde-devel&lt;br /&gt;
mkdir /home/kde-devel&lt;br /&gt;
passwd kde-devel&lt;br /&gt;
chown kde-devel:kde-devel /home/kde-devel 2&amp;gt;/dev/null || \&lt;br /&gt;
chown kde-devel:users /home/kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Option 2: Using KControl ===&lt;br /&gt;
&lt;br /&gt;
Instead of using the commands above, you can also use the User module in the KDE Control Center if you already have KDE3 installed.&lt;br /&gt;
&lt;br /&gt;
=== Setting up the environment ===&lt;br /&gt;
&lt;br /&gt;
Copy the {{path|~/.bashrc}} from your normal user account to the new kde-devel account. Next, copy and paste the contents of the [[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|example .bashrc]] into {{path|~kde-devel/.bashrc}}. Be sure to comment out the line &amp;lt;tt&amp;gt;alias make=makeobj&amp;lt;/tt&amp;gt; if you do not have the &amp;lt;tt&amp;gt;makeobj&amp;lt;/tt&amp;gt; command available, this command comes with the KDE SDK scripts.&lt;br /&gt;
&lt;br /&gt;
This will provide access to commands such as &amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt; that are used in this tutorial as well as ensure that the proper paths are in place for Qt, KDE and CMake binaries.&lt;br /&gt;
&lt;br /&gt;
For more information, please read the [[Getting Started/Increased Productivity in KDE4 with Scripts]] tutorial.&lt;br /&gt;
&lt;br /&gt;
=== Switching to the New User ===&lt;br /&gt;
Switch to the user kde-devel: (don't forget the dash)&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
su - kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The rest of this tutorial assumes you are running as the &amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt; user.&lt;br /&gt;
&lt;br /&gt;
== The development user's shell ==&lt;br /&gt;
&lt;br /&gt;
On some systems a new user is configured by default to use {{path|/bin/sh}}. If this is not the case on your system, you can skip this section. Using {{path|/bin/sh}} can be very inconvenient to work with and you may want to change it to {{path|/bin/bash}} or another shell.&lt;br /&gt;
&lt;br /&gt;
=== Option 1: As the kde-devel user ===&lt;br /&gt;
&lt;br /&gt;
If you don't have root privileges and your system supports the changing of your own shell with the &amp;lt;tt&amp;gt;chsh&amp;lt;/tt&amp;gt; application, then you could try to change your shell to {{path|/bin/bash}} by using:&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
chsh -s /bin/bash kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Option 2: As the root user ===&lt;br /&gt;
&lt;br /&gt;
If your system comes with the &amp;lt;tt&amp;gt;usermod&amp;lt;/tt&amp;gt; application you can run the following command as root: &amp;lt;tt&amp;gt;usermod -s /bin/bash&amp;lt;/tt&amp;gt;.&lt;br /&gt;
s&lt;br /&gt;
Another option is to use the &amp;lt;tt&amp;gt;vipw&amp;lt;/tt&amp;gt; application as root to safely edit your {{path|/etc/passwd}}. Locate 'kde-devel' in the the file. Change '{{path|/bin/sh}}' at the end of the line to read '{{path|/bin/bash}}', save your changes and exit.&lt;br /&gt;
&lt;br /&gt;
The new shell will be started automatically when you log in as the kde-devel user again.&lt;br /&gt;
&lt;br /&gt;
== D-Bus ==&lt;br /&gt;
QtDBus and KDE are known to work with D-Bus versions 0.62, as well as 0.92 and upwards. Versions 0.60 and 0.61 may work too but are not tested. Versions 0.90 and 0.91 are known not to work. We recommend using post-1.0 release versions (at least 0.94), so consider upgrading if you haven't done so.&lt;br /&gt;
&lt;br /&gt;
You may skip this section if you have a recent D-Bus version or if you don't want to upgrade.&lt;br /&gt;
&lt;br /&gt;
Before running these steps in the recipe, make sure your X11 headers and libraries are available. The configure script run on line 5 should output:&lt;br /&gt;
 Building X11 code:        yes&lt;br /&gt;
&lt;br /&gt;
=== The Recipe ===&lt;br /&gt;
&lt;br /&gt;
{{tip|Make sure you did set up your environment correctly as described [[Getting_Started/Build/KDE4#Setting_up_the_environment|above]]. This is necessary for the &amp;lt;tt&amp;gt;cs&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cb&amp;lt;/tt&amp;gt; functions to work.}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--'cs' and 'cb' are NOT typos!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
wget http://dbus.freedesktop.org/releases/dbus/dbus-1.0.2.tar.gz&lt;br /&gt;
tar -xvzf dbus-1.0.2.tar.gz&lt;br /&gt;
cd dbus-1.0.2/&lt;br /&gt;
./configure --prefix=$DBUSDIR --localstatedir=$KDEDIR/var&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
dbus-uuidgen --ensure&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What's Happening === &lt;br /&gt;
After changing into the source directory (line 1), D-Bus source code is downloaded from freedesktop.org (line 2) and unpacked (line 3). After going into the newly created D-Bus directory (line 4), the build is set up using the supplied {{path|configure}} script (line 5). After building (line 6) and installing (line 7) D-Bus, we use the &amp;lt;tt&amp;gt;dbus-uuidgen&amp;lt;/tt&amp;gt; tool to install a machine identification file that allows the bus to start automatically when the desktop session starts (line 8).&lt;br /&gt;
&lt;br /&gt;
Note that you need write access to {{path|/var}} for the last two steps. If your system does not have the sudo command, you can use the &amp;lt;tt&amp;gt;su&amp;lt;/tt&amp;gt; command instead, e.g. &amp;lt;tt&amp;gt;su -c &amp;quot;make install&amp;quot;&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== CMake ==&lt;br /&gt;
Skip this if you have [http://cmake.org/ CMake] &amp;gt;=2.4.5 installed. &lt;br /&gt;
You should be able to directly use the binary packages available on the [http://www.cmake.org/HTML/Download.html CMake site]. There are also distribution specific packages available.&lt;br /&gt;
CMake binary packages for openSUSE are available from [http://software.opensuse.org/download/devel:/tools:/building/ openSUSE build service].&lt;br /&gt;
&lt;br /&gt;
=== The Recipe ===&lt;br /&gt;
&amp;lt;!--'cs' and 'cb' are NOT typos!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
wget http://www.cmake.org/files/v2.4/cmake-2.4.6.tar.gz&lt;br /&gt;
tar zxf cmake-2.4.6.tar.gz&lt;br /&gt;
mkdir cmake-build&lt;br /&gt;
cd cmake-build&lt;br /&gt;
../cmake-2.4.6/bootstrap&lt;br /&gt;
make&lt;br /&gt;
sudo make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What's Happening ===&lt;br /&gt;
First, we go back to the &amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt; user's source directory (line 1), get the CMake sources (line 2) and unpack them (line 3). We create a directory to build CMake in (line 4) and go into it (line 5). We then run the CMake boostrap script to set up the CMake build (line 6), then make (line 7) and install it (line 8) using the root user.&lt;br /&gt;
&lt;br /&gt;
If your system does not have the &amp;lt;tt&amp;gt;sudo&amp;lt;/tt&amp;gt; command, you can instead do &amp;lt;tt&amp;gt;su -c &amp;quot;make install&amp;quot;&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Qt ==&lt;br /&gt;
Next we need to get the Qt4 that is in KDE's source repository. KDE is guaranteed to build against any Qt 4.3. Qt 4.2 and earlier are not supported and will not work. That is still an unreleased version, so your distribution probably doesn't have packages for it. You should use the copy in the KDE Subversion servers.&lt;br /&gt;
&lt;br /&gt;
=== The Recipe ===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/qt-copy&lt;br /&gt;
cd qt-copy&lt;br /&gt;
./apply_patches&lt;br /&gt;
./configure -qt-gif -no-exceptions -debug -fast \&lt;br /&gt;
 -prefix $QTDIR -qdbus -pch -nomake examples \&lt;br /&gt;
 -nomake demos&lt;br /&gt;
make sub-src sub-tools&lt;br /&gt;
# make install: only if QTDIR is not the current directory!&lt;br /&gt;
make install   &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What's Happening ===&lt;br /&gt;
We switch back to the &amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt; user's home directory (line 1) and download the source code using subversion (svn) from KDE's repository (line 2). After changing into the resulting {{path|qt-copy}} directory (line 3), we run a script that manages the patches that come with &amp;lt;tt&amp;gt;qt-copy&amp;lt;/tt&amp;gt; (line 4). &lt;br /&gt;
&lt;br /&gt;
Once the patches have been applied, we then set up the build using the &amp;lt;tt&amp;gt;configure&amp;lt;/tt&amp;gt; script (line 5-7). The various command line options used are explained in the {{path|qt-copy/README.qt-copy}} file. Finally, we build the minimal requirements for KDE (line 8) and install (line 9-10) Qt. If you want all the example and demo applications, you can either build them individually or simply do a &amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt; from the {{path|qt-copy}} directory. &lt;br /&gt;
&lt;br /&gt;
Note that the installation does not require root as it installs Qt locally into {{path|$QTDIR}}. Anyway, installation is only needed if {{path|$QTDIR}} differs from {{path|$HOME/qt-copy}}, which is not the case if you have exactly followed the instructions.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you get &amp;quot;error: X11/Xlib.h: No such file or directory&amp;quot;, install the devel package of &amp;lt;tt&amp;gt;xorg&amp;lt;/tt&amp;gt; (the actual name may vary between operating systems, for example it is &amp;lt;tt&amp;gt;xorg-dev&amp;lt;/tt&amp;gt; on Ubuntu based systems such as Kubuntu).&lt;br /&gt;
&lt;br /&gt;
If you get an error in the configure step about missing defines, check the value of &amp;lt;tt&amp;gt;$QMAKESPEC&amp;lt;/tt&amp;gt;.  Some distributions set this to point directly to the system-installed Qt.  If &amp;lt;tt&amp;gt;unset QMAKESPEC&amp;lt;/tt&amp;gt; solves the problem, you probably want to add it to the &amp;lt;tt&amp;gt;~/.bashrc&amp;lt;/tt&amp;gt; script.&lt;br /&gt;
&lt;br /&gt;
If you get an error &amp;quot;.pch/debug-shared/QtCore&amp;quot;, this is because Qt-4.3 enables precompiled headers if your gcc supports it, but for some reason it doesn't work for you. If you use distcc, configure qt with -no-pch. If you use icecream, update to the latest icecream from svn trunk.&lt;br /&gt;
&lt;br /&gt;
Try running any Qt program, like {{program|assistant}}. If it crashes in QSpanData::adjustSpanMethods, then your problem is the oxygen style. Try removing {{path|/lib/kde4/plugins/styles/kstyle-oxygen.so}} and {{path|/lib/kde4/plugins/styles/oxygen.so}} if they exist.&lt;br /&gt;
&lt;br /&gt;
== Strigi ==&lt;br /&gt;
&lt;br /&gt;
{{warning|If you have jumped to this section without reading [[Getting_Started/Build/KDE4#Setting_up_the_environment|Setting Up The Environment]], '''the recipes provided will not work'''. &lt;br /&gt;
&lt;br /&gt;
The recipes are not in error; &amp;lt;tt&amp;gt;cs&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;cb&amp;lt;/tt&amp;gt; are not typos. Your enironment '''needs''' to be set up correctly for these instructions to work for you.}}&lt;br /&gt;
&lt;br /&gt;
The code for getting file metadata now relies on Strigi. To install Strigi you need the libraries and headers for libz, libbz2, openssl (libcrypto or libssl), libclucene (&amp;gt;=0.9.16), and either libxml2 or libexpat.&lt;br /&gt;
&lt;br /&gt;
=== The Recipe ===&lt;br /&gt;
&amp;lt;!--'cs' and 'cb' are NOT typos!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/kdesupport/strigi&lt;br /&gt;
cd strigi&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What's Happening ===&lt;br /&gt;
We change to the base source directory (line 1). We download the sources for Strigi using subversion (line 2), go into the new {{path|~/src/strigi}} directory (line 3), and commence the build (line 4). This will leave us in the strigi build directory after the build is completed.&lt;br /&gt;
&lt;br /&gt;
== kdelibs ==&lt;br /&gt;
&lt;br /&gt;
With Qt4 and Strigi built, we can now move on to building KDE's base libraries. If you use the aforementioned [[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|.bashrc]] this is where those new functions come in handy. &lt;br /&gt;
&lt;br /&gt;
=== The Recipe ===&lt;br /&gt;
&amp;lt;!--'cs' and 'cb' are NOT typos!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd $KDE_SRC&lt;br /&gt;
mkdir KDE &amp;amp;&amp;amp; cd KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs&lt;br /&gt;
cd kdelibs&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{tip|If this command fails stating that CMake requires an out of source build directory, remove ~/src/KDE/kdelibs/CMakeCache.txt, and try again.}}&lt;br /&gt;
&lt;br /&gt;
{{tip|If &amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt; still gives the same error then try this &lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=$KDEDIR \&lt;br /&gt;
-DCMAKE_BUILD_TYPE=debugfull DKDE4_BUILD_TESTS=ON \&lt;br /&gt;
~/src/KDE/kdelibs&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== What's Happening ===&lt;br /&gt;
We change to the base source directory (line 1) then make and go into the KDE directory (line 2). We download the sources for kdelibs using subversion (line 3), go into the new {{path|~/src/KDE/kdelibs}} directory (line 4), and commence the build (line 5). This will leave us in the &amp;lt;tt&amp;gt;kdelibs&amp;lt;/tt&amp;gt; build directory after the build is completed.&lt;br /&gt;
&lt;br /&gt;
{{tip|There might be missing dependencies on your system! They are easily overlooked in the output of &amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;.&lt;br /&gt;
You might want to do a &amp;lt;tt&amp;gt;cmake ~/src/KDE/MODULE_NAME&amp;lt;/tt&amp;gt; prior to compiling any kde modules (like kdelibs, kdepimlibs etc.)}}&lt;br /&gt;
&lt;br /&gt;
=== Additional KDE-specific CMake modules ===&lt;br /&gt;
There are additional CMake modules in {{path|kdelibs/cmake/modules/}} that are necessary for building KDE4 applications. These will be installed for you when  kdelibs itself is installed.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you have problems compiling kdelibs, first make sure the software in the [[Getting_Started/Build/KDE4#Required_Software|Required Software]] section above is installed and works. Other possible hints include:&lt;br /&gt;
* If you received an error stating &amp;quot;Please create a separate build directory and run 'cmake path_to_kdelibs [options]' there.&amp;quot;, then you need to change to your build directory before running cmakekde. (e.g &amp;lt;tt&amp;gt;cs KDE/kdelibs &amp;amp;&amp;amp; cb &amp;amp;&amp;amp; cmakekde&amp;lt;/tt&amp;gt;)&lt;br /&gt;
* If Qt wasn't found or the wrong version of Qt was found, make sure that the qmake from the Qt you need is the first qmake in the path.&lt;br /&gt;
* If the problems persist, try the CMake make-option &amp;lt;tt&amp;gt;--keep-going&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Here you need the libungif library, otherwise you will get an error message like &amp;quot;&amp;lt;tt&amp;gt;Could NOT find GIF&amp;lt;/tt&amp;gt;&amp;quot;.&lt;br /&gt;
* Qt-4.3 upgrade: if you get a link error in kjsembed talking about QScriptEngine, edit CMakeCache.txt in kdelibs and remove the lines that talk about QT_QTUITOOLS_LIBRARY, then type make again (that static library has a new dependency, and the cmake code that adds it needs to run).&lt;br /&gt;
&lt;br /&gt;
== kdepimlibs ==&lt;br /&gt;
After &amp;lt;tt&amp;gt;kdelibs&amp;lt;/tt&amp;gt;, but before ''kdebase'', you need to build and install ''kdepimlibs''.&lt;br /&gt;
&lt;br /&gt;
=== The Recipe ===&lt;br /&gt;
&amp;lt;!--'cs' and 'cb' are NOT typos!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdepimlibs&lt;br /&gt;
cd kdepimlibs&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What's Happening ===&lt;br /&gt;
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 {{path|~/src/KDE/kdepimlibs}} directory (line 3). We then commence the build (line 4). This will leave us in the &amp;lt;tt&amp;gt;kdepimlibs&amp;lt;/tt&amp;gt; build directory after the build is completed.&lt;br /&gt;
&lt;br /&gt;
== kdebase ==&lt;br /&gt;
You may need kdebase for some kioslaves.&lt;br /&gt;
&amp;lt;!--'cs' and 'cb' are NOT typos!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdebase&lt;br /&gt;
cd kdebase&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you have troubles compiling kdebase:&lt;br /&gt;
* Make sure you have the &amp;lt;tt&amp;gt;libxss headers&amp;lt;/tt&amp;gt; installed. (Usually you got undefined references on xscreensaver objects if you haven't those headers)&lt;br /&gt;
* &amp;lt;tt&amp;gt;which meinproc&amp;lt;/tt&amp;gt; has to deliver {{path|/home/kde-devel/kde/bin/meinproc}}&lt;br /&gt;
* if cmakekde can not find the path of kdepimlibs, edit the file {{path|$KDE_BUILD/kdebase/CMakeCache.txt}} and manually set &amp;lt;tt&amp;gt;KDEPIMLIBS_INCLUDE_DIR:PATH=$KDE_BUILD/kdepimlibs&amp;lt;/tt&amp;gt;&lt;br /&gt;
* if you get an error saying &amp;quot;Please set the following variables: X11_XTest_LIB (ADVANCED)&amp;quot;, install the devel package of &amp;lt;tt&amp;gt;Xtst&amp;lt;/tt&amp;gt;. On some systems, this is packaged separately from &amp;lt;tt&amp;gt;xext&amp;lt;/tt&amp;gt; and called &amp;lt;tt&amp;gt;x11proto-xext-dev&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;libxtst-dev&amp;lt;/tt&amp;gt;. You may also need to remove the CMakeCache.txt file in the build dir after installing the package.&lt;br /&gt;
* the same for &amp;quot;X11_Xinerama_LIB (ADVANCED)&amp;quot; where you will need the devel package for &amp;lt;tt&amp;gt;xinerama&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* if you get the error &amp;quot;Please set the following variables: FONTCONFIG_INCLUDE_DIR, FONTCONFIG_LIBRARIES (ADVANCED)&amp;quot;, then you need to install libfontconfig&lt;br /&gt;
&lt;br /&gt;
== Generating local API documentation ==&lt;br /&gt;
Although the API documentation for KDE is available online at [http://api.kde.org api.kde.org], it is sometimes useful to have it on your own disk, for example when you want to use [[Getting_Started/Set_up_KDE_4_for_development#KDevelop|KDevelop]] for browsing the documentation or when you are not able to be online all the time.&lt;br /&gt;
&lt;br /&gt;
Be aware that generating the API documentation can take several hours and takes almost half a gigabyte of diskspace.&lt;br /&gt;
The generation is handled by a script in {{path|kdelibs/doc/api}}, you need &amp;lt;tt&amp;gt;doxygen&amp;lt;/tt&amp;gt; to be able to run it. &lt;br /&gt;
&lt;br /&gt;
To build the API documentation for kdelibs, type the following:&lt;br /&gt;
&amp;lt;!--'cs' and 'cb' are NOT typos!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
mkdir apidox&lt;br /&gt;
cd apidox&lt;br /&gt;
../kdelibs/doc/api/doxygen.sh ../kdelibs/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Success! ==&lt;br /&gt;
&lt;br /&gt;
You are now ready to start building other svn modules in the same fashion as you built kdebase, running and testing KDE4 or writing your own patches and applications.&lt;br /&gt;
&lt;br /&gt;
See the [[Getting Started/Set up KDE 4 for development#Nested_KDE_4_session|Starting a KDE4 Environment and Applications]] tutorial for how to start working on your new KDE4 installation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Build KDE]]&lt;br /&gt;
[[Category:KDE4]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Template:I18n/Language_Navigation_Bar</id>
		<title>Template:I18n/Language Navigation Bar</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Template:I18n/Language_Navigation_Bar"/>
				<updated>2007-04-03T14:37:48Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add a i18n link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;MainPageBG&amp;quot; colspan=&amp;quot;4&amp;quot; width=&amp;quot;100%&amp;quot; style=&amp;quot;border: 2px solid #AAAAAA; background-color: #FFFFFF; margin: 0.3em; padding: 0.25em;&amp;quot; valign=&amp;quot;top&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;p style=&amp;quot;width:95%;margin:auto;font-size:83.3%;text-align:center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;span lang=&amp;quot;zh_CN&amp;quot;&amp;gt;[[Getting_Started/Build/KDE4_(zh_CN)|简体中文]]&amp;lt;/span&amp;gt; |&lt;br /&gt;
&amp;lt;span lang=&amp;quot;en&amp;quot;&amp;gt;[[Getting_Started/Build/KDE4|English]]&amp;lt;/span&amp;gt; &lt;br /&gt;
&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&amp;lt;br&amp;gt;&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Getting_Started/Build/KDE4_(zh_CN)</id>
		<title>Getting Started/Build/KDE4 (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Getting_Started/Build/KDE4_(zh_CN)"/>
				<updated>2007-04-03T14:36:58Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add a i18n link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--Huanzhou Zhu初稿，Liang Qi整理!--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Template:I18n/Getting_Started/Build/KDE4}}&lt;br /&gt;
&lt;br /&gt;
{{TutorialBrowser|&lt;br /&gt;
&lt;br /&gt;
series=开始|&lt;br /&gt;
&lt;br /&gt;
name=从源代码构建KDE4|&lt;br /&gt;
&lt;br /&gt;
pre=[[../../Sources/Anonymous_SVN|Anonymous SVN Quickstart Guide]]|&lt;br /&gt;
&lt;br /&gt;
next=[[../../Set_up_KDE_4_for_development|Starting a KDE4 Environment and Applications]]|&lt;br /&gt;
&lt;br /&gt;
reading=[http://kdesvn-build.kde.org/ kdesvn-build: The KDE From Subversion Build Tool]&amp;lt;br&amp;gt;[[../../Increased_Productivity_in_KDE4_with_Scripts|Increased Productivity in KDE4 with Scripts]]&amp;lt;br&amp;gt;[[Development/Tutorials/CMake_(zh_CN) |CMake介绍]]&amp;lt;br&amp;gt;[[../KDE4/FreeBSD|FreeBSD notes]]&amp;lt;br&amp;gt;[[../KDE4/Mac OS X|Instructions for Mac OS X]]|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== 摘要 ==&lt;br /&gt;
&lt;br /&gt;
这份教程介绍了一种使KDE运行于Linux/BSD系统的方法。这份教程通篇使用了bash shell。如果你对在其他系统（如：Solaris、MacOS或Microsoft Windows）上构建KDE有兴趣, 请访问[[../|构建]]页面 并在最下方的链接处选择相应的操作系统。&lt;br /&gt;
&lt;br /&gt;
{{note|当周一提交了重大的修改时，构建错误的风险会很大。可以通过[http://developer.kde.org/~dirk/dashboard/ Dashboard]报告意料之外的破坏。非常欢迎大家修复失败的模块。&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== 所需软件 ==&lt;br /&gt;
&lt;br /&gt;
首先你必须安装以下软件，你才能成功完成这份教程：&lt;br /&gt;
* 来自gcc项目的gcc和g++, 最好是4.1或更高的版本。&lt;br /&gt;
* svn（Subversion客户端）&lt;br /&gt;
* pkg-config&lt;br /&gt;
* X11和OpenGL的开发库及头文件&lt;br /&gt;
* libjpeg、libpng、libungif、libxml2和libxslt的开发库及头文件&lt;br /&gt;
* makeobj脚本。可以做为kdesdk-scripts(debian)或类似的软件包的部件来安装，或者直接从[http://websvn.kde.org/trunk/KDE/kdesdk/scripts/makeobj?revision=600932&amp;amp;view=markup WebSVN]下载该软件本身。&lt;br /&gt;
* shared-mime-info软件包，是KDE现在使用的freedesktop MIME标准。&lt;br /&gt;
&lt;br /&gt;
你也许还需要安装以下软件：&lt;br /&gt;
* bash&lt;br /&gt;
&lt;br /&gt;
== 为KDE4开发创建一个用户账户 ==&lt;br /&gt;
&lt;br /&gt;
{{Note|&lt;br /&gt;
一些人喜欢为KDE 4使用一个单独的用户帐户（例如一个旧的bug可能因为错误很删除了一些文件），并且后面的这些指令都是使用这种方式进行的。&lt;br /&gt;
&lt;br /&gt;
使用一个单独的用户帐户做任何事情都是很有效率的，有关细节请参考[[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts|Increased Productivity in KDE4 with Scripts]]。&lt;br /&gt;
&lt;br /&gt;
你还可以遵循下面的指令，但并不把这些环境变量保存到你的&amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt;中，请把他们放到一个单独的文件中，以备你在切换到KDE 4环境中使用。&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== 选项1：命令行 ===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
useradd -m kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
或者：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
useradd kde-devel&lt;br /&gt;
mkdir /home/kde-devel&lt;br /&gt;
passwd kde-devel&lt;br /&gt;
chown kde-devel:kde-devel /home/kde-devel 2&amp;gt;/dev/null || \&lt;br /&gt;
chown kde-devel:users /home/kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 选项2：使用KControl ===&lt;br /&gt;
&lt;br /&gt;
如果你已经安装了KDE3，你可以使用KDE控制中心里的用户模块来替代上述的命令以添加用户。&lt;br /&gt;
&lt;br /&gt;
=== 设置环境 ===&lt;br /&gt;
&lt;br /&gt;
Copy the {{path|~/.bashrc}} from your normal user account to the new kde-devel account. Next, copy and paste the contents of the [[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|example .bashrc]] into {{path|~kde-devel/.bashrc}}. Be sure to comment out the line &amp;lt;tt&amp;gt;alias make=makeobj&amp;lt;/tt&amp;gt; if you do not have the &amp;lt;tt&amp;gt;makeobj&amp;lt;/tt&amp;gt; command available, this command comes with the KDE SDK scripts.&lt;br /&gt;
从你的普通账户下拷贝{{path|~/.bashrc}}到新的kde-devel账户下。然后，把[[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|.bashrc实例]]的内容复制并且粘贴到{{path|~kde-devel/.bashrc}}。如果你不能使用&amp;lt;tt&amp;gt;makeobj&amp;lt;/tt&amp;gt;命令，请把例子中的&amp;lt;tt&amp;gt;alias make=makeobj&amp;lt;/tt&amp;gt;这一行注释掉，这一行命令来自于KDE SDK脚本。&lt;br /&gt;
&lt;br /&gt;
这样就可以访问本教程中所使用的如&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;这类命令，同时保证了Qt、KDE、CMake文件的正确的路径。&lt;br /&gt;
&lt;br /&gt;
更多的信息，请阅读[[Getting Started/Increased Productivity in KDE4 with Scripts]]。&lt;br /&gt;
&lt;br /&gt;
=== 切换到新用户 ===&lt;br /&gt;
切换到用户kde-devel：（不要忘了破折号）&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
su - kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在以下教程中将假定你使用&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户。&lt;br /&gt;
&lt;br /&gt;
== 开发用户的shell ==&lt;br /&gt;
&lt;br /&gt;
有些系统上，新用户被默认配置使用{{path|/bin/sh}}。如果你得系统不是这样，请跳过这一节。使用{{path|/bin/sh}}非常的不方便，你可能希望转换到{{path|/bin/bash}}或其他的shell。&lt;br /&gt;
&lt;br /&gt;
=== 选项1：作为kde-devel用户 ===&lt;br /&gt;
&lt;br /&gt;
如果你没有root特权，同时你的系统支持使用&amp;lt;tt&amp;gt;chsh&amp;lt;/tt&amp;gt;程序来转换你自己的shell，那你可以尝试使用这条命令来把你的shell转换到{{path|/bin/bash}}：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
chsh -s /bin/bash kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 选项2：作为root用户 ===&lt;br /&gt;
&lt;br /&gt;
如果你得系统带有&amp;lt;tt&amp;gt;usermod&amp;lt;/tt&amp;gt;程序，你可以以root身份运行以下命令：&amp;lt;tt&amp;gt;usermod -s /bin/bash&amp;lt;/tt&amp;gt;。另一个选择是以root身份使用&amp;lt;tt&amp;gt;vipw&amp;lt;/tt&amp;gt;程序安全的编辑你的{{path|/etc/passwd}}。在文件中找到“kde-devel”，将行尾的“{{path|/bin/sh}}”改为“{{path|/bin/bash}}”。保存你的修改并退出。&lt;br /&gt;
&lt;br /&gt;
新的shell将在你再次使用kde-devel用户登录时自动启动。&lt;br /&gt;
&lt;br /&gt;
== D-Bus ==&lt;br /&gt;
QtDBus和KDE使用D-Bus版本为0.62、0.92或更高的版本。0.60和0.61版也可能工作但未经测试。0.90和0.91版不能工作。我们建议使用1.0版（最低0.94），所以如果你还没有该版本，请考虑升级。&lt;br /&gt;
&lt;br /&gt;
你可以跳过这一节如果你已经使用了最新的D-Bus版本或者你不想升级。&lt;br /&gt;
&lt;br /&gt;
在运行秘诀中的步骤之前，请确认你有X11的头文件和库文件。配置脚本的第五行应该输出：&lt;br /&gt;
 Building X11 code:        yes&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&lt;br /&gt;
{{tip|请确认你的环境已按照[[Getting_Started/Build/KDE4#Setting_up_the_environment|上面]]叙述正确配置。这对&amp;lt;tt&amp;gt;cs&amp;lt;/tt&amp;gt;和&amp;lt;tt&amp;gt;cb&amp;lt;/tt&amp;gt;函数的正确运行是必须的。}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
wget http://dbus.freedesktop.org/releases/dbus/dbus-1.0.2.tar.gz&lt;br /&gt;
tar -xvzf dbus-1.0.2.tar.gz&lt;br /&gt;
cd dbus-1.0.2/&lt;br /&gt;
./configure --prefix=$DBUSDIR --localstatedir=$KDEDIR/var&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
dbus-uuidgen --ensure&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 === &lt;br /&gt;
在切换到源码目录后（第1行），从freedesktop.org下载了D-Bus的源代码（第2行）并解压缩（第3行）。在进入新创建的D-Bus目录后（第4行），通过提供的{{path|configure}}脚本准备构建（第5行）。在完成D-Bus的构建（第5行）和安装（第7行）后，使用&amp;lt;tt&amp;gt;dbus-uuidgen&amp;lt;/tt&amp;gt;工具来安装机器识别文件，该文件使得bus在桌面启动时自动运行（第8行）。&lt;br /&gt;
&lt;br /&gt;
注意，最后两步，你需要有对{{path|/var}}的写入权限，如果你的系统不支持sudo，你可以使用&amp;lt;tt&amp;gt;su&amp;lt;/tt&amp;gt;命令代替。例如：&amp;lt;tt&amp;gt;su -c &amp;quot;make install&amp;quot;&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
== CMake ==&lt;br /&gt;
如果你的[http://cmake.org/ CMake]&amp;gt;=2.4.5，那请跳过这一节。你可以直接使用[http://www.cmake.org/HTML/Download.html CMake网站]提供的二进制包。这里有针对一些发行版特定的软件包。针对openSUSE的CMake二进制包通过[http://software.opensuse.org/download/devel:/tools:/building/ openSUSE构建服务]提供。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
wget http://www.cmake.org/files/v2.4/cmake-2.4.6.tar.gz&lt;br /&gt;
tar zxf cmake-2.4.6.tar.gz&lt;br /&gt;
mkdir cmake-build&lt;br /&gt;
cd cmake-build&lt;br /&gt;
../cmake-2.4.6/bootstrap&lt;br /&gt;
make&lt;br /&gt;
sudo make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
首先，我们回到&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户的源码目录（第1行），获取CMake的源码（第2行）并解压（第3行）。然后创建一个CMake的构建目录（第4行）并进入该目录（第5行）。通过运行CMake的boostrap脚本来准备Cmake的构建（第6行），然后以root身份make(第7行）安装（第8行）CMake。&lt;br /&gt;
&lt;br /&gt;
如果你的系统没有&amp;lt;tt&amp;gt;sudo&amp;lt;/tt&amp;gt;命令,你可以使用&amp;lt;tt&amp;gt;su -c &amp;quot;make install&amp;quot;&amp;lt;/tt&amp;gt;命令代替。&lt;br /&gt;
&lt;br /&gt;
== Qt ==&lt;br /&gt;
下一步，我们需要从KDE的代码仓库获得Qt4。KDE保证可以依赖任何版本的Qt 4.3来构建。Qt 4.2和之前的版本不被支持并且将不能工作。这是一个未发行的版本，因此你的发行版不一定有打包好的软件包。你应该使用KDE Subversion服务器提供的拷贝。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/qt-copy&lt;br /&gt;
cd qt-copy&lt;br /&gt;
./apply_patches&lt;br /&gt;
./configure -qt-gif -no-exceptions -debug -fast \&lt;br /&gt;
 -prefix $QTDIR -qdbus -pch -nomake examples \&lt;br /&gt;
 -nomake demos&lt;br /&gt;
make sub-src sub-tools&lt;br /&gt;
# make install: only if QTDIR is not the current directory!&lt;br /&gt;
make install   &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们切换回&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户的主目录（第1行），然后使用subversion（svn）从KDE的代码仓库下载源代码（第2行）。在切换进入{{path|qt-copy}}目录后（第3行），我们运行{{path|qt-copy}}下脚本来管理补丁（第4行）。&lt;br /&gt;
&lt;br /&gt;
当这些补丁被应用后，我们使用&amp;lt;tt&amp;gt;configure&amp;lt;/tt&amp;gt;脚本准备构建环境（第5-7行）。这里使用的这几行命令和选项在{{path|qt-copy/README.qt-copy}}文件里有解释。最后，我们构建KDE所需的最少需求（第8行）并安装Qt（第9-10行）。如果想要全部的例子和demo应用，你可以单独构建他们或直接在{{path|qt-copy}}目录下运行&amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
注意这次安装并不需要root，因为它把Qt安装到了本地的{{path|$QTDIR}}。所以，这次安装只需要{{path|$QTDIR}}和{{path|$HOME/qt-copy}}不同即可，如果你已经遵循这些指令执行了，就不会出现这种情况。&lt;br /&gt;
&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你得到了“error: X11/Xlib.h: No such file or directory”，请安装&amp;lt;tt&amp;gt;xorg&amp;lt;/tt&amp;gt;（实际的名称可能根据操作系统的不同而改变，例如在基于Ubuntu的系统Kubuntu上，这个包叫&amp;lt;tt&amp;gt;xorg-dev&amp;lt;/tt&amp;gt;）的开发包。&lt;br /&gt;
&lt;br /&gt;
如果你在configure时获得缺失定义的错误，请检查&amp;lt;tt&amp;gt;$QMAKESPEC&amp;lt;/tt&amp;gt;的值。一些发行版将这个值设置为系统安装的Qt，如果&amp;lt;tt&amp;gt;unset QMAKESPEC&amp;lt;/tt&amp;gt;可以解决这个问题，你可能希望把它添加到&amp;lt;tt&amp;gt;~/.bashrc&amp;lt;/tt&amp;gt;脚本中。&lt;br /&gt;
&lt;br /&gt;
如果你得到错误“.pch/debug-shared/QtCore”，这是因为Qt 4.3激活了你的gcc所支持的一些预编译头文件，但因为一些原因它不能为你工作。如果你使用distcc，使用-no-pch来配置Qt。如果你使用icecream，从svn主线上升级到最新的版本。&lt;br /&gt;
&lt;br /&gt;
如果你的gcc支持，Qt4.3允许使用预编译的头文件，但因为某些原因它不工作。如果你使用distcc,使用 -no-pch来configure Qt.如果你使用icecream，从svn上升级到最新的版本。&lt;br /&gt;
&lt;br /&gt;
尝试运行一些Qt程序，比如{{program|assistant}}。如果它在QSpanData::adjustSpanMethods崩溃，那你可能使用了oxygen风格。尝试删除{{path|/lib/kde4/plugins/styles/kstyle-oxygen.so}}和{{path|/lib/kde4/plugins/styles/oxygen.so}}。当然，如果它们存在的话。&lt;br /&gt;
&lt;br /&gt;
== Strigi ==&lt;br /&gt;
&lt;br /&gt;
{{warning|如果你没有阅读[[Getting_Started/Build/KDE4_(zh_CN)#设置环境|设置环境]]而直接跳到这里的话，'''那下面提供的秘诀将无法工作'''。&lt;br /&gt;
&lt;br /&gt;
秘诀没有错误，&amp;lt;tt&amp;gt;cs&amp;lt;/tt&amp;gt;和&amp;lt;tt&amp;gt;cb&amp;lt;/tt&amp;gt;也没有排版错误。为了这份教程可以正确的工作，你'''需要'''根据这些指令正确设置你的环境。}}&lt;br /&gt;
&lt;br /&gt;
获取文件元数据（file metadata）的代码现在依赖于Strigi。要安装Strigi，你需要libz、libbz2、openssl（libcrypto或者libssl）、libclucene（&amp;gt;=0.9.16）以及libxml2或libexpat的库和头文件。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/kdesupport/strigi&lt;br /&gt;
cd strigi&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
先切换到源码的根目录下（第1行）。使用subversion下载Strigi的源代码（第2行），进入新的{{path|~/src/strigi}}目录（第3行），开始构建（第4行）。这将使我们在构建完成后仍留在Strigi的构建目录里。&lt;br /&gt;
&lt;br /&gt;
== kdelibs ==&lt;br /&gt;
&lt;br /&gt;
构建好Qt4和Strigi之后，我们现在可以开始构建KDE的基础库了，如果你使用了上述的[[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|.bashrc]，里面就会有那些新的功能了。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd $KDE_SRC&lt;br /&gt;
mkdir KDE &amp;amp;&amp;amp; cd KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs&lt;br /&gt;
cd kdelibs&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{tip|如果命令失败，并提示“CMake requires an out of source build directory”，请移除~/src/KDE/kdelibs/CMakeCache.txt，然后再次尝试。}}&lt;br /&gt;
&lt;br /&gt;
{{tip|如果&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;还输出同样的错误，那试试这个：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=$KDEDIR \&lt;br /&gt;
-DCMAKE_BUILD_TYPE=debugfull DKDE4_BUILD_TESTS=ON \&lt;br /&gt;
~/src/KDE/kdelibs&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们先进入源文件的根目录（第1行），然后执行make并进入KDE目录（第2行）。使用subversion下载kdelibs的源码（第3行），进入新的{{path|~/src/KDE/kdelibs}}目录（第4行），并开始构建（第5行）。这将使我们在构建完成后仍留在kdelibs的构建目录里。&lt;br /&gt;
&lt;br /&gt;
{{tip|这里你的系统上可能会缺少某些依赖关系！可以通过&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;的输出观察到这些缺少的依赖关系。你可能希望先执行&amp;lt;tt&amp;gt;cmake ~/src/KDE/MODULE_NAME&amp;lt;/tt&amp;gt;来编译一些kde模块（比如kdelibs、kdepimlibs等）}}&lt;br /&gt;
&lt;br /&gt;
=== 附加的KDE特定的CMake模块 ===&lt;br /&gt;
在{{path|kdelibs/cmake/modules/}}中有一些构建KDE4应用所需的附加的CMake模块。它们在kdelibs安装时会被安装。&lt;br /&gt;
&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你在编译kdelibs时遇到问题，请先确认[[Getting_Started/Build/KDE4_(zh_CN)#所需软件|所需软件]]中提到的软件是否正确的安装并且工作。其他的可能包括：&lt;br /&gt;
* 如果你得到错误信息说“Please create a separate build directory and run 'cmake path_to_kdelibs [options]' there.”，那么你需要在运行cmakekde之前改变你的构建目录（例：&amp;lt;tt&amp;gt;cs KDE/kdelibs &amp;amp;&amp;amp; cb &amp;amp;&amp;amp; cmakekde&amp;lt;/tt&amp;gt;）&lt;br /&gt;
* 如果Qt没有被找到或者找到了Qt的错误版本，请确认路径中的第一个qmake就是你需要的qmake。&lt;br /&gt;
* 如果还是有问题，尝试CMake make-option &amp;lt;tt&amp;gt;--keep-going&amp;lt;/tt&amp;gt;。&lt;br /&gt;
* 这里你需要libungif库，不然你将得到象这样的错误信息“&amp;lt;tt&amp;gt;Could NOT find GIF&amp;lt;/tt&amp;gt;”。&lt;br /&gt;
* Qt-4.3升级：如果你在kjsembed中得到关于QScriptEngine的链接错误，编辑kdelibs中的CMakeCache.txt并移除关于QT_QTUITOOLS_LIBRARY的那些行，然后再次输入make.（这个静态库有新的依赖关系，需要运行cmake的代码添加它运行所需要的）&lt;br /&gt;
&lt;br /&gt;
== kdepimlibs ==&lt;br /&gt;
在&amp;lt;tt&amp;gt;kdelibs&amp;lt;/tt&amp;gt;之后，''kdebase''之前，你需要构建和安装''kdepimlibs''。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdepimlibs&lt;br /&gt;
cd kdepimlibs&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们先进入KDE源码目录（第1行）。使用subversion下载kdepimlibs的源码（第2行），进入新的{{path|~/src/KDE/kdepimlibs}}目录（第3行），并开始构建（第4行）。这将使我们在构建完成后仍留在&amp;lt;tt&amp;gt;kdepimlibs&amp;lt;/tt&amp;gt;的构建目录里。&lt;br /&gt;
&lt;br /&gt;
== kdebase ==&lt;br /&gt;
一些kioslaves需要kdebase。&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdebase&lt;br /&gt;
cd kdebase&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你在编译kdebase时遇到问题：&lt;br /&gt;
* 请确认你安装了&amp;lt;tt&amp;gt;libxss的头文件&amp;lt;/tt&amp;gt;。（如果你没有这些头文件，通常你会得到“undefined references on xscreensaver objects”）&lt;br /&gt;
* 那个&amp;lt;tt&amp;gt;meinproc&amp;lt;/tt&amp;gt;必须放到{{path|/home/kde-devel/kde/bin/meinproc}}&lt;br /&gt;
* 如果cmakekde无法找到kdepimlibs的路径，请编辑{{path|$KDE_BUILD/kdebase/CMakeCache.txt}}并手工设置&amp;lt;tt&amp;gt;KDEPIMLIBS_INCLUDE_DIR:PATH=$KDE_BUILD/kdepimlibs&amp;lt;/tt&amp;gt;&lt;br /&gt;
* 如果你得到错误说“Please set the following variables: X11_XTest_LIB(ADVANCED)”， 请安装&amp;lt;tt&amp;gt;Xtst&amp;lt;/tt&amp;gt;的开发包。有些系统上，这个包独立于&amp;lt;tt&amp;gt;xext&amp;lt;/tt&amp;gt;，并取名为&amp;lt;tt&amp;gt;x11proto-xext-dev&amp;lt;/tt&amp;gt;或者&amp;lt;tt&amp;gt;libxtst-dev&amp;lt;/tt&amp;gt;。在安装完软件包后，你可能需要移除构建目录下的CMakeCache.txt。&lt;br /&gt;
* 和“X11_Xinerama_LIB (ADVANCED)”一样，你需要安装&amp;lt;tt&amp;gt;xinerama&amp;lt;/tt&amp;gt;的开发包&lt;br /&gt;
* 如果你得到错误说“Please set the following variables: FONTCONFIG_INCLUDE_DIR, FONTCONFIG_LIBRARIES (ADVANCED)”，那么你需要安装libfontconfig。&lt;br /&gt;
	&lt;br /&gt;
== 生成本地API文档 ==&lt;br /&gt;
虽然KDE的API文档在[http://api.kde.org api.kde.org]上提供，有时在你的硬盘上有一份拷贝也是有用的，例如你想要通过[[Getting_Started/Set_up_KDE_4_for_development#KDevelop|KDevelop]]浏览这些文档或你无法上网时。&lt;br /&gt;
&lt;br /&gt;
注意，生成API文档需要几个小时并占用差不多500M的磁盘空间。文档的生成通过{{path|kdelibs/doc/api}}下的一个脚本完成，运行这个脚本你需要&amp;lt;tt&amp;gt;doxygen&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
为了构建kdelibs的API文档，请输入下列命令：&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
mkdir apidox&lt;br /&gt;
cd apidox&lt;br /&gt;
../kdelibs/doc/api/doxygen.sh ../kdelibs/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 成功了！ ==&lt;br /&gt;
你现在可以使用构建kdebase一样的方法构建其他svn模块，运行并测试KDE4或者编写你自己的补丁和应用程序。&lt;br /&gt;
&lt;br /&gt;
关于如何在你的新的KDE4环境下开始工作，请阅读[[Getting Started/Set up KDE 4 for development#Nested_KDE_4_session|Starting a KDE4 Environment and Applications]]。&lt;br /&gt;
&lt;br /&gt;
[[Category:Build KDE]]&lt;br /&gt;
[[Category:KDE4]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Getting_Started/Build/KDE4_(zh_CN)</id>
		<title>Getting Started/Build/KDE4 (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Getting_Started/Build/KDE4_(zh_CN)"/>
				<updated>2007-04-03T14:34:31Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: create chinese version, based on the initial translation from Huanzhou Zhu&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!--Huanzhou Zhu初稿，Liang Qi整理!--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{TutorialBrowser|&lt;br /&gt;
&lt;br /&gt;
series=开始|&lt;br /&gt;
&lt;br /&gt;
name=从源代码构建KDE4|&lt;br /&gt;
&lt;br /&gt;
pre=[[../../Sources/Anonymous_SVN|Anonymous SVN Quickstart Guide]]|&lt;br /&gt;
&lt;br /&gt;
next=[[../../Set_up_KDE_4_for_development|Starting a KDE4 Environment and Applications]]|&lt;br /&gt;
&lt;br /&gt;
reading=[http://kdesvn-build.kde.org/ kdesvn-build: The KDE From Subversion Build Tool]&amp;lt;br&amp;gt;[[../../Increased_Productivity_in_KDE4_with_Scripts|Increased Productivity in KDE4 with Scripts]]&amp;lt;br&amp;gt;[[Development/Tutorials/CMake_(zh_CN) |CMake介绍]]&amp;lt;br&amp;gt;[[../KDE4/FreeBSD|FreeBSD notes]]&amp;lt;br&amp;gt;[[../KDE4/Mac OS X|Instructions for Mac OS X]]|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== 摘要 ==&lt;br /&gt;
&lt;br /&gt;
这份教程介绍了一种使KDE运行于Linux/BSD系统的方法。这份教程通篇使用了bash shell。如果你对在其他系统（如：Solaris、MacOS或Microsoft Windows）上构建KDE有兴趣, 请访问[[../|构建]]页面 并在最下方的链接处选择相应的操作系统。&lt;br /&gt;
&lt;br /&gt;
{{note|当周一提交了重大的修改时，构建错误的风险会很大。可以通过[http://developer.kde.org/~dirk/dashboard/ Dashboard]报告意料之外的破坏。非常欢迎大家修复失败的模块。&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== 所需软件 ==&lt;br /&gt;
&lt;br /&gt;
首先你必须安装以下软件，你才能成功完成这份教程：&lt;br /&gt;
* 来自gcc项目的gcc和g++, 最好是4.1或更高的版本。&lt;br /&gt;
* svn（Subversion客户端）&lt;br /&gt;
* pkg-config&lt;br /&gt;
* X11和OpenGL的开发库及头文件&lt;br /&gt;
* libjpeg、libpng、libungif、libxml2和libxslt的开发库及头文件&lt;br /&gt;
* makeobj脚本。可以做为kdesdk-scripts(debian)或类似的软件包的部件来安装，或者直接从[http://websvn.kde.org/trunk/KDE/kdesdk/scripts/makeobj?revision=600932&amp;amp;view=markup WebSVN]下载该软件本身。&lt;br /&gt;
* shared-mime-info软件包，是KDE现在使用的freedesktop MIME标准。&lt;br /&gt;
&lt;br /&gt;
你也许还需要安装以下软件：&lt;br /&gt;
* bash&lt;br /&gt;
&lt;br /&gt;
== 为KDE4开发创建一个用户账户 ==&lt;br /&gt;
&lt;br /&gt;
{{Note|&lt;br /&gt;
一些人喜欢为KDE 4使用一个单独的用户帐户（例如一个旧的bug可能因为错误很删除了一些文件），并且后面的这些指令都是使用这种方式进行的。&lt;br /&gt;
&lt;br /&gt;
使用一个单独的用户帐户做任何事情都是很有效率的，有关细节请参考[[Getting_Started/Increased_Productivity_in_KDE4_with_Scripts|Increased Productivity in KDE4 with Scripts]]。&lt;br /&gt;
&lt;br /&gt;
你还可以遵循下面的指令，但并不把这些环境变量保存到你的&amp;lt;tt&amp;gt;.bashrc&amp;lt;/tt&amp;gt;中，请把他们放到一个单独的文件中，以备你在切换到KDE 4环境中使用。&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== 选项1：命令行 ===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
useradd -m kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
或者：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
useradd kde-devel&lt;br /&gt;
mkdir /home/kde-devel&lt;br /&gt;
passwd kde-devel&lt;br /&gt;
chown kde-devel:kde-devel /home/kde-devel 2&amp;gt;/dev/null || \&lt;br /&gt;
chown kde-devel:users /home/kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 选项2：使用KControl ===&lt;br /&gt;
&lt;br /&gt;
如果你已经安装了KDE3，你可以使用KDE控制中心里的用户模块来替代上述的命令以添加用户。&lt;br /&gt;
&lt;br /&gt;
=== 设置环境 ===&lt;br /&gt;
&lt;br /&gt;
Copy the {{path|~/.bashrc}} from your normal user account to the new kde-devel account. Next, copy and paste the contents of the [[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|example .bashrc]] into {{path|~kde-devel/.bashrc}}. Be sure to comment out the line &amp;lt;tt&amp;gt;alias make=makeobj&amp;lt;/tt&amp;gt; if you do not have the &amp;lt;tt&amp;gt;makeobj&amp;lt;/tt&amp;gt; command available, this command comes with the KDE SDK scripts.&lt;br /&gt;
从你的普通账户下拷贝{{path|~/.bashrc}}到新的kde-devel账户下。然后，把[[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|.bashrc实例]]的内容复制并且粘贴到{{path|~kde-devel/.bashrc}}。如果你不能使用&amp;lt;tt&amp;gt;makeobj&amp;lt;/tt&amp;gt;命令，请把例子中的&amp;lt;tt&amp;gt;alias make=makeobj&amp;lt;/tt&amp;gt;这一行注释掉，这一行命令来自于KDE SDK脚本。&lt;br /&gt;
&lt;br /&gt;
这样就可以访问本教程中所使用的如&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;这类命令，同时保证了Qt、KDE、CMake文件的正确的路径。&lt;br /&gt;
&lt;br /&gt;
更多的信息，请阅读[[Getting Started/Increased Productivity in KDE4 with Scripts]]。&lt;br /&gt;
&lt;br /&gt;
=== 切换到新用户 ===&lt;br /&gt;
切换到用户kde-devel：（不要忘了破折号）&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
su - kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在以下教程中将假定你使用&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户。&lt;br /&gt;
&lt;br /&gt;
== 开发用户的shell ==&lt;br /&gt;
&lt;br /&gt;
有些系统上，新用户被默认配置使用{{path|/bin/sh}}。如果你得系统不是这样，请跳过这一节。使用{{path|/bin/sh}}非常的不方便，你可能希望转换到{{path|/bin/bash}}或其他的shell。&lt;br /&gt;
&lt;br /&gt;
=== 选项1：作为kde-devel用户 ===&lt;br /&gt;
&lt;br /&gt;
如果你没有root特权，同时你的系统支持使用&amp;lt;tt&amp;gt;chsh&amp;lt;/tt&amp;gt;程序来转换你自己的shell，那你可以尝试使用这条命令来把你的shell转换到{{path|/bin/bash}}：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
chsh -s /bin/bash kde-devel&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 选项2：作为root用户 ===&lt;br /&gt;
&lt;br /&gt;
如果你得系统带有&amp;lt;tt&amp;gt;usermod&amp;lt;/tt&amp;gt;程序，你可以以root身份运行以下命令：&amp;lt;tt&amp;gt;usermod -s /bin/bash&amp;lt;/tt&amp;gt;。另一个选择是以root身份使用&amp;lt;tt&amp;gt;vipw&amp;lt;/tt&amp;gt;程序安全的编辑你的{{path|/etc/passwd}}。在文件中找到“kde-devel”，将行尾的“{{path|/bin/sh}}”改为“{{path|/bin/bash}}”。保存你的修改并退出。&lt;br /&gt;
&lt;br /&gt;
新的shell将在你再次使用kde-devel用户登录时自动启动。&lt;br /&gt;
&lt;br /&gt;
== D-Bus ==&lt;br /&gt;
QtDBus和KDE使用D-Bus版本为0.62、0.92或更高的版本。0.60和0.61版也可能工作但未经测试。0.90和0.91版不能工作。我们建议使用1.0版（最低0.94），所以如果你还没有该版本，请考虑升级。&lt;br /&gt;
&lt;br /&gt;
你可以跳过这一节如果你已经使用了最新的D-Bus版本或者你不想升级。&lt;br /&gt;
&lt;br /&gt;
在运行秘诀中的步骤之前，请确认你有X11的头文件和库文件。配置脚本的第五行应该输出：&lt;br /&gt;
 Building X11 code:        yes&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&lt;br /&gt;
{{tip|请确认你的环境已按照[[Getting_Started/Build/KDE4#Setting_up_the_environment|上面]]叙述正确配置。这对&amp;lt;tt&amp;gt;cs&amp;lt;/tt&amp;gt;和&amp;lt;tt&amp;gt;cb&amp;lt;/tt&amp;gt;函数的正确运行是必须的。}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
wget http://dbus.freedesktop.org/releases/dbus/dbus-1.0.2.tar.gz&lt;br /&gt;
tar -xvzf dbus-1.0.2.tar.gz&lt;br /&gt;
cd dbus-1.0.2/&lt;br /&gt;
./configure --prefix=$DBUSDIR --localstatedir=$KDEDIR/var&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
dbus-uuidgen --ensure&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 === &lt;br /&gt;
在切换到源码目录后（第1行），从freedesktop.org下载了D-Bus的源代码（第2行）并解压缩（第3行）。在进入新创建的D-Bus目录后（第4行），通过提供的{{path|configure}}脚本准备构建（第5行）。在完成D-Bus的构建（第5行）和安装（第7行）后，使用&amp;lt;tt&amp;gt;dbus-uuidgen&amp;lt;/tt&amp;gt;工具来安装机器识别文件，该文件使得bus在桌面启动时自动运行（第8行）。&lt;br /&gt;
&lt;br /&gt;
注意，最后两步，你需要有对{{path|/var}}的写入权限，如果你的系统不支持sudo，你可以使用&amp;lt;tt&amp;gt;su&amp;lt;/tt&amp;gt;命令代替。例如：&amp;lt;tt&amp;gt;su -c &amp;quot;make install&amp;quot;&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
== CMake ==&lt;br /&gt;
如果你的[http://cmake.org/ CMake]&amp;gt;=2.4.5，那请跳过这一节。你可以直接使用[http://www.cmake.org/HTML/Download.html CMake网站]提供的二进制包。这里有针对一些发行版特定的软件包。针对openSUSE的CMake二进制包通过[http://software.opensuse.org/download/devel:/tools:/building/ openSUSE构建服务]提供。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
wget http://www.cmake.org/files/v2.4/cmake-2.4.6.tar.gz&lt;br /&gt;
tar zxf cmake-2.4.6.tar.gz&lt;br /&gt;
mkdir cmake-build&lt;br /&gt;
cd cmake-build&lt;br /&gt;
../cmake-2.4.6/bootstrap&lt;br /&gt;
make&lt;br /&gt;
sudo make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
首先，我们回到&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户的源码目录（第1行），获取CMake的源码（第2行）并解压（第3行）。然后创建一个CMake的构建目录（第4行）并进入该目录（第5行）。通过运行CMake的boostrap脚本来准备Cmake的构建（第6行），然后以root身份make(第7行）安装（第8行）CMake。&lt;br /&gt;
&lt;br /&gt;
如果你的系统没有&amp;lt;tt&amp;gt;sudo&amp;lt;/tt&amp;gt;命令,你可以使用&amp;lt;tt&amp;gt;su -c &amp;quot;make install&amp;quot;&amp;lt;/tt&amp;gt;命令代替。&lt;br /&gt;
&lt;br /&gt;
== Qt ==&lt;br /&gt;
下一步，我们需要从KDE的代码仓库获得Qt4。KDE保证可以依赖任何版本的Qt 4.3来构建。Qt 4.2和之前的版本不被支持并且将不能工作。这是一个未发行的版本，因此你的发行版不一定有打包好的软件包。你应该使用KDE Subversion服务器提供的拷贝。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/qt-copy&lt;br /&gt;
cd qt-copy&lt;br /&gt;
./apply_patches&lt;br /&gt;
./configure -qt-gif -no-exceptions -debug -fast \&lt;br /&gt;
 -prefix $QTDIR -qdbus -pch -nomake examples \&lt;br /&gt;
 -nomake demos&lt;br /&gt;
make sub-src sub-tools&lt;br /&gt;
# make install: only if QTDIR is not the current directory!&lt;br /&gt;
make install   &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们切换回&amp;lt;tt&amp;gt;kde-devel&amp;lt;/tt&amp;gt;用户的主目录（第1行），然后使用subversion（svn）从KDE的代码仓库下载源代码（第2行）。在切换进入{{path|qt-copy}}目录后（第3行），我们运行{{path|qt-copy}}下脚本来管理补丁（第4行）。&lt;br /&gt;
&lt;br /&gt;
当这些补丁被应用后，我们使用&amp;lt;tt&amp;gt;configure&amp;lt;/tt&amp;gt;脚本准备构建环境（第5-7行）。这里使用的这几行命令和选项在{{path|qt-copy/README.qt-copy}}文件里有解释。最后，我们构建KDE所需的最少需求（第8行）并安装Qt（第9-10行）。如果想要全部的例子和demo应用，你可以单独构建他们或直接在{{path|qt-copy}}目录下运行&amp;lt;tt&amp;gt;make&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
注意这次安装并不需要root，因为它把Qt安装到了本地的{{path|$QTDIR}}。所以，这次安装只需要{{path|$QTDIR}}和{{path|$HOME/qt-copy}}不同即可，如果你已经遵循这些指令执行了，就不会出现这种情况。&lt;br /&gt;
&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你得到了“error: X11/Xlib.h: No such file or directory”，请安装&amp;lt;tt&amp;gt;xorg&amp;lt;/tt&amp;gt;（实际的名称可能根据操作系统的不同而改变，例如在基于Ubuntu的系统Kubuntu上，这个包叫&amp;lt;tt&amp;gt;xorg-dev&amp;lt;/tt&amp;gt;）的开发包。&lt;br /&gt;
&lt;br /&gt;
如果你在configure时获得缺失定义的错误，请检查&amp;lt;tt&amp;gt;$QMAKESPEC&amp;lt;/tt&amp;gt;的值。一些发行版将这个值设置为系统安装的Qt，如果&amp;lt;tt&amp;gt;unset QMAKESPEC&amp;lt;/tt&amp;gt;可以解决这个问题，你可能希望把它添加到&amp;lt;tt&amp;gt;~/.bashrc&amp;lt;/tt&amp;gt;脚本中。&lt;br /&gt;
&lt;br /&gt;
如果你得到错误“.pch/debug-shared/QtCore”，这是因为Qt 4.3激活了你的gcc所支持的一些预编译头文件，但因为一些原因它不能为你工作。如果你使用distcc，使用-no-pch来配置Qt。如果你使用icecream，从svn主线上升级到最新的版本。&lt;br /&gt;
&lt;br /&gt;
如果你的gcc支持，Qt4.3允许使用预编译的头文件，但因为某些原因它不工作。如果你使用distcc,使用 -no-pch来configure Qt.如果你使用icecream，从svn上升级到最新的版本。&lt;br /&gt;
&lt;br /&gt;
尝试运行一些Qt程序，比如{{program|assistant}}。如果它在QSpanData::adjustSpanMethods崩溃，那你可能使用了oxygen风格。尝试删除{{path|/lib/kde4/plugins/styles/kstyle-oxygen.so}}和{{path|/lib/kde4/plugins/styles/oxygen.so}}。当然，如果它们存在的话。&lt;br /&gt;
&lt;br /&gt;
== Strigi ==&lt;br /&gt;
&lt;br /&gt;
{{warning|如果你没有阅读[[Getting_Started/Build/KDE4_(zh_CN)#设置环境|设置环境]]而直接跳到这里的话，'''那下面提供的秘诀将无法工作'''。&lt;br /&gt;
&lt;br /&gt;
秘诀没有错误，&amp;lt;tt&amp;gt;cs&amp;lt;/tt&amp;gt;和&amp;lt;tt&amp;gt;cb&amp;lt;/tt&amp;gt;也没有排版错误。为了这份教程可以正确的工作，你'''需要'''根据这些指令正确设置你的环境。}}&lt;br /&gt;
&lt;br /&gt;
获取文件元数据（file metadata）的代码现在依赖于Strigi。要安装Strigi，你需要libz、libbz2、openssl（libcrypto或者libssl）、libclucene（&amp;gt;=0.9.16）以及libxml2或libexpat的库和头文件。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/kdesupport/strigi&lt;br /&gt;
cd strigi&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
先切换到源码的根目录下（第1行）。使用subversion下载Strigi的源代码（第2行），进入新的{{path|~/src/strigi}}目录（第3行），开始构建（第4行）。这将使我们在构建完成后仍留在Strigi的构建目录里。&lt;br /&gt;
&lt;br /&gt;
== kdelibs ==&lt;br /&gt;
&lt;br /&gt;
构建好Qt4和Strigi之后，我们现在可以开始构建KDE的基础库了，如果你使用了上述的[[Getting Started/Increased Productivity in KDE4 with Scripts/.bashrc|.bashrc]，里面就会有那些新的功能了。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd $KDE_SRC&lt;br /&gt;
mkdir KDE &amp;amp;&amp;amp; cd KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs&lt;br /&gt;
cd kdelibs&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{tip|如果命令失败，并提示“CMake requires an out of source build directory”，请移除~/src/KDE/kdelibs/CMakeCache.txt，然后再次尝试。}}&lt;br /&gt;
&lt;br /&gt;
{{tip|如果&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;还输出同样的错误，那试试这个：&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cd&lt;br /&gt;
cmake -DCMAKE_INSTALL_PREFIX=$KDEDIR \&lt;br /&gt;
-DCMAKE_BUILD_TYPE=debugfull DKDE4_BUILD_TESTS=ON \&lt;br /&gt;
~/src/KDE/kdelibs&lt;br /&gt;
make&lt;br /&gt;
make install&lt;br /&gt;
&amp;lt;/code&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们先进入源文件的根目录（第1行），然后执行make并进入KDE目录（第2行）。使用subversion下载kdelibs的源码（第3行），进入新的{{path|~/src/KDE/kdelibs}}目录（第4行），并开始构建（第5行）。这将使我们在构建完成后仍留在kdelibs的构建目录里。&lt;br /&gt;
&lt;br /&gt;
{{tip|这里你的系统上可能会缺少某些依赖关系！可以通过&amp;lt;tt&amp;gt;cmakekde&amp;lt;/tt&amp;gt;的输出观察到这些缺少的依赖关系。你可能希望先执行&amp;lt;tt&amp;gt;cmake ~/src/KDE/MODULE_NAME&amp;lt;/tt&amp;gt;来编译一些kde模块（比如kdelibs、kdepimlibs等）}}&lt;br /&gt;
&lt;br /&gt;
=== 附加的KDE特定的CMake模块 ===&lt;br /&gt;
在{{path|kdelibs/cmake/modules/}}中有一些构建KDE4应用所需的附加的CMake模块。它们在kdelibs安装时会被安装。&lt;br /&gt;
&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你在编译kdelibs时遇到问题，请先确认[[Getting_Started/Build/KDE4_(zh_CN)#所需软件|所需软件]]中提到的软件是否正确的安装并且工作。其他的可能包括：&lt;br /&gt;
* 如果你得到错误信息说“Please create a separate build directory and run 'cmake path_to_kdelibs [options]' there.”，那么你需要在运行cmakekde之前改变你的构建目录（例：&amp;lt;tt&amp;gt;cs KDE/kdelibs &amp;amp;&amp;amp; cb &amp;amp;&amp;amp; cmakekde&amp;lt;/tt&amp;gt;）&lt;br /&gt;
* 如果Qt没有被找到或者找到了Qt的错误版本，请确认路径中的第一个qmake就是你需要的qmake。&lt;br /&gt;
* 如果还是有问题，尝试CMake make-option &amp;lt;tt&amp;gt;--keep-going&amp;lt;/tt&amp;gt;。&lt;br /&gt;
* 这里你需要libungif库，不然你将得到象这样的错误信息“&amp;lt;tt&amp;gt;Could NOT find GIF&amp;lt;/tt&amp;gt;”。&lt;br /&gt;
* Qt-4.3升级：如果你在kjsembed中得到关于QScriptEngine的链接错误，编辑kdelibs中的CMakeCache.txt并移除关于QT_QTUITOOLS_LIBRARY的那些行，然后再次输入make.（这个静态库有新的依赖关系，需要运行cmake的代码添加它运行所需要的）&lt;br /&gt;
&lt;br /&gt;
== kdepimlibs ==&lt;br /&gt;
在&amp;lt;tt&amp;gt;kdelibs&amp;lt;/tt&amp;gt;之后，''kdebase''之前，你需要构建和安装''kdepimlibs''。&lt;br /&gt;
&lt;br /&gt;
=== 秘诀 ===&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdepimlibs&lt;br /&gt;
cd kdepimlibs&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 发生了什么 ===&lt;br /&gt;
我们先进入KDE源码目录（第1行）。使用subversion下载kdepimlibs的源码（第2行），进入新的{{path|~/src/KDE/kdepimlibs}}目录（第3行），并开始构建（第4行）。这将使我们在构建完成后仍留在&amp;lt;tt&amp;gt;kdepimlibs&amp;lt;/tt&amp;gt;的构建目录里。&lt;br /&gt;
&lt;br /&gt;
== kdebase ==&lt;br /&gt;
一些kioslaves需要kdebase。&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
svn checkout svn://anonsvn.kde.org/home/kde/trunk/KDE/kdebase&lt;br /&gt;
cd kdebase&lt;br /&gt;
cmakekde&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
=== 疑难解答 ===&lt;br /&gt;
如果你在编译kdebase时遇到问题：&lt;br /&gt;
* 请确认你安装了&amp;lt;tt&amp;gt;libxss的头文件&amp;lt;/tt&amp;gt;。（如果你没有这些头文件，通常你会得到“undefined references on xscreensaver objects”）&lt;br /&gt;
* 那个&amp;lt;tt&amp;gt;meinproc&amp;lt;/tt&amp;gt;必须放到{{path|/home/kde-devel/kde/bin/meinproc}}&lt;br /&gt;
* 如果cmakekde无法找到kdepimlibs的路径，请编辑{{path|$KDE_BUILD/kdebase/CMakeCache.txt}}并手工设置&amp;lt;tt&amp;gt;KDEPIMLIBS_INCLUDE_DIR:PATH=$KDE_BUILD/kdepimlibs&amp;lt;/tt&amp;gt;&lt;br /&gt;
* 如果你得到错误说“Please set the following variables: X11_XTest_LIB(ADVANCED)”， 请安装&amp;lt;tt&amp;gt;Xtst&amp;lt;/tt&amp;gt;的开发包。有些系统上，这个包独立于&amp;lt;tt&amp;gt;xext&amp;lt;/tt&amp;gt;，并取名为&amp;lt;tt&amp;gt;x11proto-xext-dev&amp;lt;/tt&amp;gt;或者&amp;lt;tt&amp;gt;libxtst-dev&amp;lt;/tt&amp;gt;。在安装完软件包后，你可能需要移除构建目录下的CMakeCache.txt。&lt;br /&gt;
* 和“X11_Xinerama_LIB (ADVANCED)”一样，你需要安装&amp;lt;tt&amp;gt;xinerama&amp;lt;/tt&amp;gt;的开发包&lt;br /&gt;
* 如果你得到错误说“Please set the following variables: FONTCONFIG_INCLUDE_DIR, FONTCONFIG_LIBRARIES (ADVANCED)”，那么你需要安装libfontconfig。&lt;br /&gt;
	&lt;br /&gt;
== 生成本地API文档 ==&lt;br /&gt;
虽然KDE的API文档在[http://api.kde.org api.kde.org]上提供，有时在你的硬盘上有一份拷贝也是有用的，例如你想要通过[[Getting_Started/Set_up_KDE_4_for_development#KDevelop|KDevelop]]浏览这些文档或你无法上网时。&lt;br /&gt;
&lt;br /&gt;
注意，生成API文档需要几个小时并占用差不多500M的磁盘空间。文档的生成通过{{path|kdelibs/doc/api}}下的一个脚本完成，运行这个脚本你需要&amp;lt;tt&amp;gt;doxygen&amp;lt;/tt&amp;gt;。&lt;br /&gt;
&lt;br /&gt;
为了构建kdelibs的API文档，请输入下列命令：&lt;br /&gt;
&amp;lt;!--'cs'和'cb'不是拼写错误!--&amp;gt;&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cs KDE&lt;br /&gt;
mkdir apidox&lt;br /&gt;
cd apidox&lt;br /&gt;
../kdelibs/doc/api/doxygen.sh ../kdelibs/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 成功了！ ==&lt;br /&gt;
你现在可以使用构建kdebase一样的方法构建其他svn模块，运行并测试KDE4或者编写你自己的补丁和应用程序。&lt;br /&gt;
&lt;br /&gt;
关于如何在你的新的KDE4环境下开始工作，请阅读[[Getting Started/Set up KDE 4 for development#Nested_KDE_4_session|Starting a KDE4 Environment and Applications]]。&lt;br /&gt;
&lt;br /&gt;
[[Category:Build KDE]]&lt;br /&gt;
[[Category:KDE4]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Getting_Started/Build</id>
		<title>Getting Started/Build</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Getting_Started/Build"/>
				<updated>2007-04-03T12:42:07Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add a link for chinese version of kde4&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here you will find instructions for compiling and installing KDE from source and suggestions for when compilation doesn't go so smoothly.&lt;br /&gt;
&lt;br /&gt;
== Building The Source ==&lt;br /&gt;
&lt;br /&gt;
; [[/Stable Version|KDE 3.5 (Stable version)]]: Instructions for installing the latest stable KDE 3.5 release.&lt;br /&gt;
&lt;br /&gt;
; [[/KDE4|KDE 4 (Unstable version, trunk)]][[/KDE4_(zh_CN)|(Simplified Chinese version)]]: Instructions for installing the latest and greatest KDE development source code.&lt;br /&gt;
&lt;br /&gt;
; [[/Older KDE Versions|Old Versions]]: Instructions for building older KDE versions.&lt;br /&gt;
&lt;br /&gt;
; [[/Coexisting Versions|Coexisting Versions]]: Directions to build multiple KDE versions on the same machine simultaneously.&lt;br /&gt;
&lt;br /&gt;
; [[/FAQ|FAQ]]: Help with errors and other questions you might have.&lt;br /&gt;
&lt;br /&gt;
== Further Links ==&lt;br /&gt;
* Build [http://solaris.kde.org/ KDE on Solaris]&lt;br /&gt;
* Build [http://www.kdelibs.com/ KDE on Windows]&lt;br /&gt;
* Build [[/KDE4/Mac_OS_X|KDE on Mac OS X]]&lt;br /&gt;
* Build [[/KDE4/FreeBSD|KDE on FreeBSD]]&lt;br /&gt;
[[Category:Build KDE]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Development/Tutorials/CMake</id>
		<title>Development/Tutorials/CMake</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Development/Tutorials/CMake"/>
				<updated>2007-04-01T17:54:49Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add template for simplified chinese cmake&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:I18n/Development/Tutorials/CMake}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
CMake reads script files and produces input files for the native buildsystem of the platform where it runs on. It can create GNU Makefiles, KDevelop project files, XCode project files, and Visual Studio project files.&lt;br /&gt;
&lt;br /&gt;
CMake is free software and released under a BSD-style license.  It is developed by [http://www.kitware.com Kitware Inc.]&lt;br /&gt;
&lt;br /&gt;
Here are some good places to learn about CMake in general:&lt;br /&gt;
* [http://www.cmake.org/HTML/Documentation.html CMake Manual]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake CMake Wiki]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks CMake System Checks ]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware Finding Optional Packages ]&lt;br /&gt;
* [http://www.cmake.org/Wiki/HowToBuildKDE4Software KDE 4 Tutorial at the CMake Wiki ]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_FAQ CMake FAQ]&lt;br /&gt;
* [http://mail.kde.org/pipermail/kde-buildsystem/ The kde-buildsystem Mailing List Archive]&lt;br /&gt;
&lt;br /&gt;
Also, consider joining the [http://www.cmake.org/mailman/listinfo/cmake CMake mailing list].&lt;br /&gt;
&lt;br /&gt;
== Why use CMake ? ==&lt;br /&gt;
CMake is the official tool of KDE 4 release, decided in March 2006, primarily due to technical merits as compared to the older KDE tools automake and unsermake:&lt;br /&gt;
* CMake is developed independently of KDE, it can be used by other projects as well &lt;br /&gt;
* Compilation time is much faster, mainly due to not using libtool anymore&lt;br /&gt;
* The build files are easier to write&lt;br /&gt;
&lt;br /&gt;
== How to compile KDE using CMake==&lt;br /&gt;
&lt;br /&gt;
=== Get and install CMake ===&lt;br /&gt;
==== Linux, BSD, and other Unix Systems ====&lt;br /&gt;
Retrieve the latest stable version of CMake from [http://www.cmake.org/HTML/Download.html].&lt;br /&gt;
&lt;br /&gt;
Once downloaded, unpack and compile it:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ mkdir cmake-build&lt;br /&gt;
$ cd cmake-build&lt;br /&gt;
$ ../bootstrap&lt;br /&gt;
$ make&lt;br /&gt;
$ make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, this will install CMake in /usr/local, so make sure to have /usr/local/bin in your execute path.   To change the installation prefix (e.g. to /usr in debian), add the '--prefix=PATH' option to the bootstrap command.&lt;br /&gt;
&lt;br /&gt;
Please follow the instructions located [http://cmake.org/HTML/Download.html#cvs here] if you would like to use the current development version.&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
Retrieve the latest stable version of CMake from [http://www.cmake.org/HTML/Download.html].&lt;br /&gt;
&lt;br /&gt;
Once downloaded, run the cmake installer. &lt;br /&gt;
&lt;br /&gt;
By default, this will install CMake in C:\Program Files\CMake 2.4, so make sure to have &amp;lt;installpath&amp;gt;\bin in your execute path.   &lt;br /&gt;
&lt;br /&gt;
Please follow the instructions at [http://cmake.org/HTML/Download.html#cvs here] if you would like to use the current development version.&lt;br /&gt;
==== Mac OSX ====&lt;br /&gt;
&lt;br /&gt;
=== Run CMake ===&lt;br /&gt;
&lt;br /&gt;
==== Linux, BSD, and other Unix Systems ====&lt;br /&gt;
You have to run CMake so that it generates the build files for your system.  Both in-source and out-of-source builds are supported by CMake, but currently in-source builds are prevented by the KDE implementation.&lt;br /&gt;
&lt;br /&gt;
So, let's say you have kdelibs/ in ~/src/kdelibs/, then do the following:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ ls&lt;br /&gt;
kdelibs/&lt;br /&gt;
$ mkdir kdelibs-build&lt;br /&gt;
$ cd kdelibs-build&lt;br /&gt;
$ cmake ../kdelibs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This will generated the Makefiles for building kdelibs/ in kdelibs-build/.&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
You have to run CMake so that it generates the build files for your system.  Both in-source and out-of-source builds are supported by CMake, but currently in-source builds are prevented by the KDE implementation.&lt;br /&gt;
&lt;br /&gt;
So, let's say you have kdelibs\ in c:\daten\kde4, then do the following:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
c:\daten\kde4&amp;gt; cd kdelibs\win&lt;br /&gt;
c:\daten\kde4&amp;gt; cmake&lt;br /&gt;
c:\daten\kde4&amp;gt; make &lt;br /&gt;
c:\daten\kde4&amp;gt; make install&lt;br /&gt;
c:\daten\kde4&amp;gt; cd ..&lt;br /&gt;
c:\daten\kde4&amp;gt; mkdir kdelibs-build&lt;br /&gt;
c:\daten\kde4&amp;gt; cd kdelibs-build&lt;br /&gt;
c:\daten\kde4\kdelibs-build&amp;gt; cmake ..\kdelibs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will generated the Makefiles for building kdelibs\ in kdelibs-build\. See [[KDE On Windows]] for more informations about compiling KDE on Windows.&lt;br /&gt;
&lt;br /&gt;
==== Mac OSX ====&lt;br /&gt;
&lt;br /&gt;
==== KDevelop Project Files ====&lt;br /&gt;
If you prefer project files for KDevelop (which will basically be Makefiles accompanied by some extra files for KDevelop), run it like this:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ cmake ../kdelibs -GKDevelop3&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Use 'cmake -h' to find out which generators CMake supports and the other options.&lt;br /&gt;
&lt;br /&gt;
==== CMake and Qt4 ====&lt;br /&gt;
To locate Qt 4, CMake searches for qmake in your execute path. CMake does ''not'' use the QTDIR environment variable.  So make sure that the first qmake found in the execution path is the one you like to use.&lt;br /&gt;
&lt;br /&gt;
==== More Details ====&lt;br /&gt;
When CMake has finished, it will have created a file called &amp;quot;CMakeCache.txt&amp;quot;.  This file contains all the settings CMake has detected on your system.  If you want to run CMake with another generator or you want CMake to detect everything again, delete this file.&lt;br /&gt;
&lt;br /&gt;
If CMake didn't find something, but you know it is somewere on your box, you can tell CMake manually where to find it.  CMake uses variables to store this information.  These variables are cached in the already mentioned file CMakeCache.txt.  You have three options to adjust these variables manually:&lt;br /&gt;
* tell CMake the correct value via the command line: cmake ../kdelibs -DNAME_OF_THE_VARIABLE=value&lt;br /&gt;
* use ccmake, which provides a curses based GUI to adjust the CMake variables (run: ccmake ../kdelibs)&lt;br /&gt;
* edit the file CMakeCache.txt directly (not recommended)&lt;br /&gt;
&lt;br /&gt;
You should run &amp;quot;ccmake ../kdelibs&amp;quot; at least once so that you get an impression which variables CMake uses.  Press &amp;quot;T&amp;quot; to see also the &amp;quot;advanced&amp;quot; variables.  So, if CMake didn't find something, start ccmake and adjust it manually.&lt;br /&gt;
&lt;br /&gt;
Some variables you probably will want to set:&lt;br /&gt;
* '''CMAKE_INSTALL_PREFIX''': cmake ../kdelibs -DCMAKE_INSTALL_PREFIX=/opt/kde4 is the equivalent to ./configure --prefix=/opt/kde4&lt;br /&gt;
* '''CMAKE_BUILD_TYPE''': decide which type of build you want. You can chose between &amp;quot;debugfull&amp;quot;, &amp;quot;debug&amp;quot;, &amp;quot;profile&amp;quot;, &amp;quot;relwithdebinfo&amp;quot; and &amp;quot;release&amp;quot;. The default is &amp;quot;relwithdebinfo&amp;quot; (-O2 -g). See FindKDE4Internal.cmake for details.&lt;br /&gt;
* '''RPATH_STYLE''': This is not available anymore. By default everything will be built with RPATH set correctly. If you don't want RPATH at all, set CMAKE_SKIP_RPATH to TRUE.&lt;br /&gt;
* '''WITH_FOO''': there are several options, e.g. WITH_CUPS or WITH_Jasper. If you disable them, cmake will not even try to find this package. If it is enabled, cmake will try to find it. If it fails with this, you can still adjust it manually as described above.&lt;br /&gt;
&lt;br /&gt;
=== Environment Variables ===&lt;br /&gt;
If you have headers and libraries installed in non-standard locations that cmake cannot find (e.g., fink on Mac OSX installs to /sw), then set the following as environment variables.  Despite the similar naming convention, these will not work as arguments on the cmake command line:&lt;br /&gt;
* '''CMAKE_INCLUDE_PATH''', eg. export CMAKE_INCLUDE_PATH=/sw/include&lt;br /&gt;
* '''CMAKE_LIBRARY_PATH''', eg. export CMAKE_LIBRARY_PATH=/sw/lib&lt;br /&gt;
&lt;br /&gt;
For more information on variables, see [http://www.cmake.org/Wiki/CMake_Useful_Variables this cmake.org wiki page]&lt;br /&gt;
&lt;br /&gt;
=== Going Further ===&lt;br /&gt;
If cmake finishes with &amp;quot;Generating done&amp;quot; then there was no errors, but if it finishes with &amp;quot;Configuring done&amp;quot; then there was errors that you have to fix.  Once cmake finishes successfully, run your buildtool (i.e. make, KDevelop, XCode or MSVC) and build and wait until it has finished.  Then &amp;quot;make install&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
If you got a failure that says something like&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
CMake Error: This project requires some variables to be set,&lt;br /&gt;
and cmake can not find them.&lt;br /&gt;
Please set the following variables:&lt;br /&gt;
X11_XTest_LIB (ADVANCED)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
then you may have a missing library (or other dependency). To find&lt;br /&gt;
out which library, search in the cmake/modules directory for&lt;br /&gt;
the variable that cmake can't find. In the example above, it is&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
FIND_LIBRARY(X11_XTest_LIB Xtst ${X11_LIB_SEARCH_PATH})&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So the missing library is Xtst. You then need to find it (perhaps installing a libXtst-devel library) and re-run cmake.&lt;br /&gt;
&lt;br /&gt;
== Using CMake for a Simple Application ==&lt;br /&gt;
&lt;br /&gt;
Here's the most simple CMakeLists.txt:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
add_executable(hello main.cpp)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This will create an executable named &amp;quot;hello&amp;quot; (or &amp;quot;hello.exe&amp;quot; under Windows) from the source file main.cpp. You can mix C and C++ files as you want.  You can have multiple executables and libraries in one CMakeLists.txt.  The same source file can be used in multiple targets, it will be compiled for each target independently from the other targets.  Probably the most important part of the cmake language are the variables:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SET( MY_SOURCES main.cpp widget.cpp)&lt;br /&gt;
MESSAGE(STATUS &amp;quot;my sources: ${MY_SOURCES}&amp;quot;)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
So, use the SET() command to set the value of a variable. If you list more than one string, the variable will be a list.   A list is a list of strings separated by semicolons. If you set it to only one item, it will have just that value. To get the value of a variable, use ${VAR}.&lt;br /&gt;
You can iterate over a list using FOREACH():&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
FOREACH(next_ITEM ${MY_SOURCES})&lt;br /&gt;
   MESSAGE(STATUS &amp;quot;next item: ${next_ITEM}&amp;quot;)&lt;br /&gt;
ENDFOREACH(next_ITEM ${MY_SOURCES})&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The commands in CMake are case-insensitive.  Names of variables and names of parameter are case-sensitive.&lt;br /&gt;
&lt;br /&gt;
You can also test for various things:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
IF (UNIX)&lt;br /&gt;
   MESSAGE(STATUS &amp;quot;This is UNIX (including OS X and CygWin)&amp;quot;)&lt;br /&gt;
ENDIF (UNIX)&lt;br /&gt;
&lt;br /&gt;
IF (MSVC)&lt;br /&gt;
   SET(MY_SRCS ${MY_SRCS} winextra.cpp)&lt;br /&gt;
ENDIF (MSVC)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
In this second example  you can see also how to append items to a list.&lt;br /&gt;
&lt;br /&gt;
In the cmake Wiki there is also a [http://www.cmake.org/Wiki/HowToBuildKDE4Software  tutorial] on using cmake to build KDE 4 software. It is recommended reading.&lt;br /&gt;
&lt;br /&gt;
== Using CMake for a KDE Project ==&lt;br /&gt;
&lt;br /&gt;
Here's a basic CMakeList file that builds a small KDE 4 project:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
PROJECT( kde4project)&lt;br /&gt;
FIND_PACKAGE(KDE4 REQUIRED)&lt;br /&gt;
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} )&lt;br /&gt;
&lt;br /&gt;
SET(KDE4ProjectSources kde4mainapp.cpp someclass.cpp someotherclass.cpp)&lt;br /&gt;
&lt;br /&gt;
KDE4_AUTOMOC( ${KDE4ProjectSources} )&lt;br /&gt;
&lt;br /&gt;
KDE4_ADD_EXECUTABLE(kde4project ${KDE4ProjectSources} )&lt;br /&gt;
&lt;br /&gt;
TARGET_LINK_LIBRARIES(kde4project ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Extending CMake ==&lt;br /&gt;
CMake can be extended using cmake scripts. CMake comes with a number of scripts; under UNIX they are by default installed to /usr/local/share/CMake/Modules/. The KDE libraries install also a set of cmake modules into share/apps/cmake/modules/. The files located there will be preferred over the ones in the system global cmake module path. &lt;br /&gt;
For detecting software packages there are FindFOO.cmake files, see [http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware here] for more information.&lt;br /&gt;
You can also write macros in CMake. They are powerful enough to do most things you will need to build software, but they are not intended to be used as a general purpose programming language.&lt;br /&gt;
&lt;br /&gt;
== Converting autotools-based KDE software to CMake ==&lt;br /&gt;
In kdesdk/cmake/ you can find a script am2cmake . This is a ruby script, so you need to have ruby installed. Run am2cmake in the toplevel directory of your sources:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ cd src/mykooltool/&lt;br /&gt;
$ am2cmake --kde4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Don't forget the switch &amp;quot;--kde4&amp;quot;, otherwise it won't generate files suitable for KDE 4 software. The converted files 'may' work as they are, but complicated projects will require some additional editing.&lt;br /&gt;
&lt;br /&gt;
You may have to:&lt;br /&gt;
* add more include direcories, using INCLUDE_DIRECTORIES()&lt;br /&gt;
* add more link libraries, using TARGET_LINK_LIBRARIES()&lt;br /&gt;
* add some compile switches, using ADD_DEFINITIONS()&lt;br /&gt;
* add some &amp;quot;configure&amp;quot; checks, see [http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks How To Do Platform Checks] and [http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware How To Find Installed Software]&lt;br /&gt;
* take special care of former libtool convenience libraries. They are not supported by cmake, instead there will be a file ConvenienceLibs.cmake created.  In this file you will find for every convenience lib a variable, which contains all source files of this convenience lib.  For the targets which linked to this convenience lib, just add the variable to the sources.&lt;br /&gt;
* a file AdditionalInfo.txt will be created.  There you will see all *.in and *.in.in files of your project. The stuff done in these files will have to be converted manually to cmake.&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== How can I teach my favorite editor about CMake syntax and indentation ? ===&lt;br /&gt;
Read the CMake Wiki section [http://www.cmake.org/Wiki/CMake_Editors_Support CMake Editors Support].  It describes how to setup Emacs (XEmacs works too), VIM, Kate, KWrite, and KDevelop.&lt;br /&gt;
&lt;br /&gt;
=== I need to generate some files during the build. How do I do this ? ===&lt;br /&gt;
Use ADD_CUSTOM_COMMAND(). It's explained here in the CMake wiki: [http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F  How can I generate a source file during the build]&lt;br /&gt;
&lt;br /&gt;
=== I need to build an executable which is used later on during the build to generate files. How do I do this ? ===&lt;br /&gt;
Let's say the executable is called genembed. Then use KDE4_ADD_EXECUTABLE(foo RUN_UNINSTALLED ${fooSources})to create the executable. The RUN_UNINSTALLED option is important, because the executable has to run from the build dir and has to link to the libraries in the builddir. To achieve this, the executable is compiled with RPATH set accordingly and a wrapper shell script, named just like the executable but with the suffix &amp;quot;.sh&amp;quot; is created. This shell scripts sets up LD_LIBRARY_PATH and the calls the actual executable.&lt;br /&gt;
Use this wrapper shell script in the ADD_CUSTOM_COMMAND() as described above.&lt;br /&gt;
You can find out the name and exact location by querying the property WRAPPER_SCRIPT. Here's a full example taken from kdelibs/kstyles/keramik/ :&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# build the executable&lt;br /&gt;
KDE4_ADD_EXECUTABLE(genembed RUN_UNINSTALLED ${genembed_SRCS})&lt;br /&gt;
&lt;br /&gt;
# get the name of the generated wrapper script (which sets up LD_LIBRARY_PATH)&lt;br /&gt;
GET_TARGET_PROPERTY(GENEMBED_EXECUTABLE genembed WRAPPER_SCRIPT)&lt;br /&gt;
&lt;br /&gt;
# and the custom command&lt;br /&gt;
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/keramikrc.h&lt;br /&gt;
  COMMAND ${GENEMBED_EXECUTABLE} --file ${CMAKE_CURRENT_BINARY_DIR}/keramikPics.txt &amp;gt; \&lt;br /&gt;
  ${CMAKE_CURRENT_BINARY_DIR}/pixmaps.keramik&lt;br /&gt;
  DEPENDS genembed ${keramikPics}&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see genembed is also listed as a dependency, this means cmake knows that it has to build the executable genembed before executing this rule.&lt;br /&gt;
&lt;br /&gt;
=== I don't want to set the -DCMAKE_INSTALL_PREFIX command line option.  Does cmake support the KDEDIR environment variable? ===&lt;br /&gt;
No.  $KDEDIR is deprecated in KDE 4.&lt;br /&gt;
&lt;br /&gt;
=== Why do i get compile errors like /usr/lib/qt4/include/QtCore/qstring.h:536: undefined reference to `QString::fromLatin1_helper(char const*, int)'? ===&lt;br /&gt;
A: If you have an old Qt4 version in your qt/lib directory you must delete the old (4.0.1) files.&lt;br /&gt;
&lt;br /&gt;
=== How do I tell cmake to create noisy makefiles?  I want to see the exact commands that are run during the make process. ===&lt;br /&gt;
Pass the VERBOSE variable to make, i.e.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
% make VERBOSE=1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
or&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
% VERBOSE=1 make&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more details see the CMake wiki: [http://www.cmake.org/Wiki/CMake_FAQ#Is_there_an_option_to_produce_more_.27verbose.27_compiling.3F Is there an option to produce more 'verbose' compiling?]&lt;br /&gt;
&lt;br /&gt;
=== There is no 'make distclean' target in the generated Makefiles.  How do I clean up everything, including the cache files? ===&lt;br /&gt;
Simply remove the build directory, or just the contents of the build directory.&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
[[Category:FAQs]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Development/Tutorials/CMake_(zh_CN)</id>
		<title>Development/Tutorials/CMake (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Development/Tutorials/CMake_(zh_CN)"/>
				<updated>2007-04-01T17:45:24Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: adjust template&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:I18n/Development/Tutorials/CMake}}&lt;br /&gt;
&lt;br /&gt;
== 简介 ==&lt;br /&gt;
CMake读取脚本文件并且为它所运行的平台的本地构建系统产生输入文件。它可以生成GNU Makefiles、KDevelop的项目文件、XCode项目文件以及Visual Studio项目文件等多种文件格式。&lt;br /&gt;
&lt;br /&gt;
CMake是自由软件并且是在BSD协议下发布的。它是由[http://www.kitware.com Kitware公司]开发的。&lt;br /&gt;
&lt;br /&gt;
这些地方学习CMake挺不错的：&lt;br /&gt;
* [http://www.cmake.org/HTML/Documentation.html CMake手册]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake CMake Wiki]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks CMake系统检查]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 查找可替换的软件包]&lt;br /&gt;
* [http://www.cmake.org/Wiki/HowToBuildKDE4Software CMake Wiki上的KDE4指导]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_FAQ CMake FAQ]&lt;br /&gt;
* [http://mail.kde.org/pipermail/kde-buildsystem/ kde-buildsystem的邮件列表存档]&lt;br /&gt;
&lt;br /&gt;
另外，还可以考虑加入[http://www.cmake.org/mailman/listinfo/cmake CMake邮件列表]。&lt;br /&gt;
&lt;br /&gt;
== 为什么使用CMake？ ==&lt;br /&gt;
CMake是KDE 4发布中的官方工具，这是在2006年3月决定的，它和以前的KDE工具automake和unsermake的主要技术不同点有：&lt;br /&gt;
* CMake是独立于KDE开发的，它也可以被用于其它项目。&lt;br /&gt;
* 编译时间更快，主要是因为没有再使用libtool。&lt;br /&gt;
* 构建文件更容易编写。&lt;br /&gt;
&lt;br /&gt;
== 如何使用CMake编译KDE ==&lt;br /&gt;
&lt;br /&gt;
=== 获取和安装CMake ===&lt;br /&gt;
==== Linux、BSD及其他Unix系统 ====&lt;br /&gt;
从[http://www.cmake.org/HTML/Download.html]获得取回最新的CMake稳定版。&lt;br /&gt;
&lt;br /&gt;
下载完后，解压并安装：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ mkdir cmake-build&lt;br /&gt;
$ cd cmake-build&lt;br /&gt;
$ ../bootstrap&lt;br /&gt;
$ make&lt;br /&gt;
$ make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
默认的，这将把CMake安装在/usr/local，因此，确定/usr/local/bin在的执行路径里。要改变安装路径，（例如debian中改为/usr），在bootstrap命令中加入'--prefix=PATH'选项。&lt;br /&gt;
&lt;br /&gt;
如果你想使用当前的开发版本，请遵循[http://cmake.org/HTML/Download.html#cvs 这里]的指令。&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
从[http://www.cmake.org/HTML/Download.html]获得取回最新的CMake稳定版。&lt;br /&gt;
&lt;br /&gt;
下载完后，运行cmake的安装程序。&lt;br /&gt;
&lt;br /&gt;
默认将把CMake安装在C:\Program Files\CMake 2.4,，因此要确保&amp;lt;installpath&amp;gt;\bin在你的执行路径中。&lt;br /&gt;
&lt;br /&gt;
如果你想使用当前的开发版本，请遵循[http://cmake.org/HTML/Download.html#cvs 这里]的指令。&lt;br /&gt;
&lt;br /&gt;
==== Mac OSX ====&lt;br /&gt;
&lt;br /&gt;
=== 运行CMake ===&lt;br /&gt;
&lt;br /&gt;
==== Linux、BSD及其他Unix系统 ====&lt;br /&gt;
你必须运行CMake来为你的系统生成build文件。CMake支持in-source和out-of-source构建，不过目前KDE默认禁用in-source构建。&lt;br /&gt;
&lt;br /&gt;
假定你在~/src/kdelibs/中有kdelibs/，那么，输入：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ ls&lt;br /&gt;
kdelibs/&lt;br /&gt;
$ mkdir kdelibs-build&lt;br /&gt;
$ cd kdelibs-build&lt;br /&gt;
$ cmake ../kdelibs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这会在kdelibs-build/中生成构建kdelibs/的Makefiles。&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
你必须运行CMake来为你的系统生成build文件。CMake支持in-source和out-of-source构建，不过目前KDE默认禁用in-source构建。&lt;br /&gt;
&lt;br /&gt;
假定你在c:\daten\kde4中有kdelibs\，那么，输入：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
c:\daten\kde4&amp;gt; cd kdelibs\win&lt;br /&gt;
c:\daten\kde4&amp;gt; cmake&lt;br /&gt;
c:\daten\kde4&amp;gt; make &lt;br /&gt;
c:\daten\kde4&amp;gt; make install&lt;br /&gt;
c:\daten\kde4&amp;gt; cd ..&lt;br /&gt;
c:\daten\kde4&amp;gt; mkdir kdelibs-build&lt;br /&gt;
c:\daten\kde4&amp;gt; cd kdelibs-build&lt;br /&gt;
c:\daten\kde4\kdelibs-build&amp;gt; cmake ..\kdelibs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
这样就生成了在 kdelibs-build\中构建kdelibs\的Makefiles。要获得更多的关于在Windows下编译KDE的信息，请阅读[[KDE On Windows]]。&lt;br /&gt;
&lt;br /&gt;
==== Mac OSX ====&lt;br /&gt;
&lt;br /&gt;
==== KDevelop项目 ====&lt;br /&gt;
如果你更喜欢KDevelop的项目文件（基本上就是Makefiles及为KDevelop生成的一些文件），这样运行CMake：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ cmake ../kdelibs -GKDevelop3&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
使用“cmake -h”来查看CMake支持那些生成器 （generators）及其他的选项。&lt;br /&gt;
&lt;br /&gt;
==== CMake和Qt4 ====&lt;br /&gt;
为了定位Qt 4，CMake会在你的执行路径中搜索qmake。CMake''不''会使用QTDIR这个环境变量。因此请确保在执行路径中寻找到的第一个qmake就是你希望使用的。&lt;br /&gt;
&lt;br /&gt;
==== 更多细节 ====&lt;br /&gt;
当CMake执行完成，它会生成一个叫“CMakeCache.txt”的文件。这个文件包含了CMake在你的系统上检测到的所有设置。如果你希望在其他生成器（generators)上运行CMake,或你希望CMake重新检测系统，请删除这个文件。&lt;br /&gt;
&lt;br /&gt;
如果有些东西你知道它存在，而CMake没有检测到，你可以手动的告诉CMake到哪里去找它。CMake通过变量来存储这些信息。这些变量缓存在前面提到的 CMakeCache.txt中。这里有3个选项来手工调整这些变量：&lt;br /&gt;
* 通过命令行告诉CMake现在的值: cmake ../kdelibs -DNAME_OF_THE_VARIABLE=value&lt;br /&gt;
* 使用ccmake，它提供了一个基于鼠标的GUI来调整CMake变量（运行: ccmake ../kdelibs）&lt;br /&gt;
* 直接编辑CMakeCache.txt（不推荐）&lt;br /&gt;
&lt;br /&gt;
你应该最起码运行一次“ccmake ../kdelibs”，这样你会对CMake使用了那些变量有个印象。按“T”来查看“高级”的变量。如果有些东西CMake没有找到，运行ccmake并手工调整它。&lt;br /&gt;
&lt;br /&gt;
一些你可能希望设置的变量：&lt;br /&gt;
* '''CMAKE_INSTALL_PREFIX''': cmake ../kdelibs -DCMAKE_INSTALL_PREFIX=/opt/kde4 相当于./configure --prefix=/opt/kde4&lt;br /&gt;
* '''CMAKE_BUILD_TYPE''': 决定你如何构建系统。你可以在“debugfull”、“debug”、“profile”、“relwithdebinfo”和“release”中进行选择。默认的是“relwithdebinfo”(-O2 -g)。更多细节查看FindKDE4Internal.cmake。&lt;br /&gt;
* '''RPATH_STYLE''': 这个不再有效了。默认情况下，一切都将在RPATH设置正确的情况下来构建。如果你不希望使用RPATH，将CMAKE_SKIP_RPATH设置为TRUE。&lt;br /&gt;
* '''WITH_FOO''': 这里有一些选项，例如WITH_CUPS或WITH_Jasper。如果你将他们关闭，cmake甚至不会去尝试寻找这个包。如果将它激活，cmake将会尝试寻找这个包。如果这样做失败了，你还可以通过上面介绍的方法手工设置。&lt;br /&gt;
&lt;br /&gt;
=== 环境变量 ===&lt;br /&gt;
如果你在CMake没法找到的非标准位置安装了头文件或库（ 例如Mac OSX下把fink安装到/sw），那么就请设置下面这些环境变量。尽管有相似的命名规则，这些设置在cmake的命令中并不会做为参数来工作。&lt;br /&gt;
* '''CMAKE_INCLUDE_PATH'''，例如export CMAKE_INCLUDE_PATH=/sw/include&lt;br /&gt;
* '''CMAKE_LIBRARY_PATH'''，例如export CMAKE_LIBRARY_PATH=/sw/lib&lt;br /&gt;
&lt;br /&gt;
关于变量的更多信息，请参考&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_Useful_Variables cmake.org wiki page]。&lt;br /&gt;
&lt;br /&gt;
=== 更进一步 ===&lt;br /&gt;
如果cmake以“Generating done”结束，那表示没有错误，但如果以“Configuring done”结束，那表示有错误需要修正。当cmake成功结束，运行你的构建工具（如make、KDevelop、XCode或MSVC）来构建并等到它结束。然后运行“make install”。&lt;br /&gt;
&lt;br /&gt;
如果你得到如下错误提示：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
CMake Error: This project requires some variables to be set,&lt;br /&gt;
and cmake can not find them.&lt;br /&gt;
Please set the following variables:&lt;br /&gt;
X11_XTest_LIB (ADVANCED)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
那表示你可能缺少库（或其他依赖包）。在cmake/modules目录中查找cmake无法找到的变量来确定是缺少哪个库文件。在上面的例子中，就是：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
FIND_LIBRARY(X11_XTest_LIB Xtst ${X11_LIB_SEARCH_PATH})&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这里缺失的库是Xtst。然后你找到这个库（也许是通过安装libXtst-devel）并再次运行cmake。&lt;br /&gt;
&lt;br /&gt;
== 在简单的应用中使用CMake ==&lt;br /&gt;
这是最简单的CMakeLists.txt：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
add_executable(hello main.cpp)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这将从main.cpp源码文件创建一个叫“hello”（Windows下叫“hello.exe”）的可执行文件。你可以根据自己的需要将C和C++文件混合。在同一个CMakeLists.txt可以有多个可执行文件和库。同一个源码文件可以用于不同的目的，源码可以从其他目标中为每个目的独立的编译。CMake语言最重要的部分可能是变量：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SET( MY_SOURCES main.cpp widget.cpp)&lt;br /&gt;
MESSAGE(STATUS &amp;quot;my sources: ${MY_SOURCES}&amp;quot;)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
使用SET()命令来为变量设置值。如果你列出了一个以上的字符串，变量将是串列表。列表是一列由分号隔开的字符串。如果只设置个一项，那么这项只有一个值。可以通过${VAR}获得变量的值。可以使用FOREACH()来迭代一份列表：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
FOREACH(next_ITEM ${MY_SOURCES})&lt;br /&gt;
   MESSAGE(STATUS &amp;quot;next item: ${next_ITEM}&amp;quot;)&lt;br /&gt;
ENDFOREACH(next_ITEM ${MY_SOURCES})&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
CMake中的命令是大小写无关的。变量名和参数名是大小写相关的。&lt;br /&gt;
&lt;br /&gt;
还可以测试一些不同的东西：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
IF (UNIX)&lt;br /&gt;
   MESSAGE(STATUS &amp;quot;This is UNIX (including OS X and CygWin)&amp;quot;)&lt;br /&gt;
ENDIF (UNIX)&lt;br /&gt;
&lt;br /&gt;
IF (MSVC)&lt;br /&gt;
   SET(MY_SRCS ${MY_SRCS} winextra.cpp)&lt;br /&gt;
ENDIF (MSVC)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
在第二个例子中，你可以看到如何将项目附加到列表中。&lt;br /&gt;
&lt;br /&gt;
在cmake Wiki中有一份使用cmake构建KDE4软件的[http://www.cmake.org/Wiki/HowToBuildKDE4Software 指导]，推荐阅读。&lt;br /&gt;
&lt;br /&gt;
== 在KDE项目中使用CMake ==&lt;br /&gt;
这里是一份基本的构建一个小KDE4项目的CMakeList文件：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
PROJECT( kde4project)&lt;br /&gt;
FIND_PACKAGE(KDE4 REQUIRED)&lt;br /&gt;
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} )&lt;br /&gt;
&lt;br /&gt;
SET(KDE4ProjectSources kde4mainapp.cpp someclass.cpp someotherclass.cpp)&lt;br /&gt;
&lt;br /&gt;
KDE4_AUTOMOC( ${KDE4ProjectSources} )&lt;br /&gt;
&lt;br /&gt;
KDE4_ADD_EXECUTABLE(kde4project ${KDE4ProjectSources} )&lt;br /&gt;
&lt;br /&gt;
TARGET_LINK_LIBRARIES(kde4project ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 扩展CMake ==&lt;br /&gt;
CMake可以通过cmake脚本扩展，CMake带有大量的脚本，在UNIX下，这些脚本默认安装在 /usr/local/share/CMake/Modules/内。KDE库也在/apps/cmake/modules/安装了一些CMake模块。这里的文件将被代替CMake的系统全局模块路径。FindFOO.cmake用来检测软件包，&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 这里]有更多信息。在CMake中也可以写宏文件，对于大多数的软件构建来说，他们足够强大了。这些宏不会做为通用语言来使用。&lt;br /&gt;
&lt;br /&gt;
你还可以在CMake中编写宏。他们非常强大，可以满足你编译的软件中所需要的所有事情，但是他们并不是被用作通用目的的编程语言。&lt;br /&gt;
&lt;br /&gt;
== 将基于autotools的KDE软件转换为CMake ==&lt;br /&gt;
你可以在kdesdk/cmake/找到am2cmake脚本。这是ruby写成的，所以确定你的系统安装了ruby。在你的源码目录最上层运行am2cmak：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ cd src/mykooltool/&lt;br /&gt;
$ am2cmake --kde4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
不要忘了开关“--kde4”，不然系统无法生成适合KDE4的文件。转换文件可能会正常工作，但编译的项目将需要一些额外的编辑。&lt;br /&gt;
&lt;br /&gt;
你可能需要：&lt;br /&gt;
* 使用INCLUDE_DIRECTORIES()添加更多include目录。&lt;br /&gt;
* 使用TARGET_LINK_LIBRARIES()添加更多链接库。&lt;br /&gt;
* 使用ADD_DEFINITIONS()添加更多编译开关。&lt;br /&gt;
* 添加一些“configure”检查，参照[http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks 如何进行平台检查]和[http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 如何找到已经安装的软件]。&lt;br /&gt;
* 特别要注意以往的libtool便捷库，CMake并不支持这些库，而是生成一个ConvenienceLibs.cmake文件代替。在这个文件里，你可以为每个便捷库找到一个包含了这个库所有源码的变量。对于链接到这些库的目标，只要在源码中添加这些变量即可。&lt;br /&gt;
* 一个AdditionalInfo.txt文件将被创建。你可以在这里找到项目所有的*.in和*.in.in文件。这些文件完成的任务将被手工转换到CMake.&lt;br /&gt;
&lt;br /&gt;
== 常见问题 ==&lt;br /&gt;
&lt;br /&gt;
=== 如何使我最喜欢的编辑器支持CMake的语法和缩进？ ===&lt;br /&gt;
请阅读CMake Wiki中[http://www.cmake.org/Wiki/CMake_Editors_Support CMake编辑器支持]这部分。这里介绍了如何设置Emac、VI、Kat、KWrite和KDevelop。&lt;br /&gt;
&lt;br /&gt;
=== 我需要在构建过程中产生一些文件，我该如何做？ ===&lt;br /&gt;
使用ADD_CUSTOM_COMMAND()。这里有解释：[http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F 在构建过程中如何生成一个源文件]。&lt;br /&gt;
&lt;br /&gt;
=== 我想在产生文件的构建过程中创建一个稍后使用的可执行文件，我要如何做？ ===&lt;br /&gt;
假定可执行文件叫genembed。那么使用KDE4_ADD_EXECUTABLE(foo RUN_UNINSTALLED ${fooSources})来生成可执行文件。RUN_UNINSTALLED选项非常重要，因为可执行文件必须从构建目录运行，并会链接到builddir中的一些库。为达到这个目的，可执行文件通过相应设置的RPATH和包装的外壳脚本编译，和可执行文件的命名一样只是多了“.sh”后缀。这个外壳脚本设置LD_LIBRARY_PATH并调用实际的可执行文件。象上面介绍的在ADD_CUSTOM_COMMAND()中使用这个包装的外壳脚本。可以通过查询WRAPPER_SCRIPT来获得名称和确切的路径。这里有一个来自kdelibs/kstyles/keramik/完整的例子：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# build the executable&lt;br /&gt;
KDE4_ADD_EXECUTABLE(genembed RUN_UNINSTALLED ${genembed_SRCS})&lt;br /&gt;
&lt;br /&gt;
# get the name of the generated wrapper script (which sets up LD_LIBRARY_PATH)&lt;br /&gt;
GET_TARGET_PROPERTY(GENEMBED_EXECUTABLE genembed WRAPPER_SCRIPT)&lt;br /&gt;
&lt;br /&gt;
# and the custom command&lt;br /&gt;
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/keramikrc.h&lt;br /&gt;
  COMMAND ${GENEMBED_EXECUTABLE} --file ${CMAKE_CURRENT_BINARY_DIR}/keramikPics.txt &amp;gt; \&lt;br /&gt;
  ${CMAKE_CURRENT_BINARY_DIR}/pixmaps.keramik&lt;br /&gt;
  DEPENDS genembed ${keramikPics}&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
如你所见genembed也做为依赖关系列出。这表示CMake知道它应该在执行这些规则之前创建genembed的可执行文件。&lt;br /&gt;
&lt;br /&gt;
=== 我不想设置-DCMAKE_INSTALL_PREFIX命令行参数。CMake是否支持KDEDIR环境变量？ ===&lt;br /&gt;
不。KDE4反对使用$KDEDIR。&lt;br /&gt;
&lt;br /&gt;
=== 为什么我会得到类似/usr/lib/qt4/include/QtCore/qstring.h:536: undefined reference to `QString::fromLatin1_helper(char const*, int)'的编译错误？ ===&lt;br /&gt;
如果你的qt/lib目录下有个老版本的Qt4，你必须删除这些老版本（4.0.4）文件。&lt;br /&gt;
&lt;br /&gt;
=== 我如何让CMake创建noisy makefiles？我希望准确的看到make过程执行的命令。 ===&lt;br /&gt;
给make传递 VERBOSE 变量，例如：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
% make VERBOSE=1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
或者&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
% VERBOSE=1 make&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
更多细节请查看CMake wiki：&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_FAQ#Is_there_an_option_to_produce_more_.27verbose.27_compiling.3F 有没有选项可以产生更多的“verbose”编译？]&lt;br /&gt;
&lt;br /&gt;
=== 产生的Makefiles中没有“make distclean”标签。我如何才能清理包括cache文件在内的所有文件？ ===&lt;br /&gt;
只需删除构建目录，或目录里包含的内容。&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
[[Category:FAQs]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Development/Tutorials/CMake_(zh_CN)</id>
		<title>Development/Tutorials/CMake (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Development/Tutorials/CMake_(zh_CN)"/>
				<updated>2007-04-01T14:38:52Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: a typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:CMake}}&lt;br /&gt;
&lt;br /&gt;
== 简介 ==&lt;br /&gt;
CMake读取脚本文件并且为它所运行的平台的本地构建系统产生输入文件。它可以生成GNU Makefiles、KDevelop的项目文件、XCode项目文件以及Visual Studio项目文件等多种文件格式。&lt;br /&gt;
&lt;br /&gt;
CMake是自由软件并且是在BSD协议下发布的。它是由[http://www.kitware.com Kitware公司]开发的。&lt;br /&gt;
&lt;br /&gt;
这些地方学习CMake挺不错的：&lt;br /&gt;
* [http://www.cmake.org/HTML/Documentation.html CMake手册]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake CMake Wiki]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks CMake系统检查]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 查找可替换的软件包]&lt;br /&gt;
* [http://www.cmake.org/Wiki/HowToBuildKDE4Software CMake Wiki上的KDE4指导]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_FAQ CMake FAQ]&lt;br /&gt;
* [http://mail.kde.org/pipermail/kde-buildsystem/ kde-buildsystem的邮件列表存档]&lt;br /&gt;
&lt;br /&gt;
另外，还可以考虑加入[http://www.cmake.org/mailman/listinfo/cmake CMake邮件列表]。&lt;br /&gt;
&lt;br /&gt;
== 为什么使用CMake？ ==&lt;br /&gt;
CMake是KDE 4发布中的官方工具，这是在2006年3月决定的，它和以前的KDE工具automake和unsermake的主要技术不同点有：&lt;br /&gt;
* CMake是独立于KDE开发的，它也可以被用于其它项目。&lt;br /&gt;
* 编译时间更快，主要是因为没有再使用libtool。&lt;br /&gt;
* 构建文件更容易编写。&lt;br /&gt;
&lt;br /&gt;
== 如何使用CMake编译KDE ==&lt;br /&gt;
&lt;br /&gt;
=== 获取和安装CMake ===&lt;br /&gt;
==== Linux、BSD及其他Unix系统 ====&lt;br /&gt;
从[http://www.cmake.org/HTML/Download.html]获得取回最新的CMake稳定版。&lt;br /&gt;
&lt;br /&gt;
下载完后，解压并安装：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ mkdir cmake-build&lt;br /&gt;
$ cd cmake-build&lt;br /&gt;
$ ../bootstrap&lt;br /&gt;
$ make&lt;br /&gt;
$ make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
默认的，这将把CMake安装在/usr/local，因此，确定/usr/local/bin在的执行路径里。要改变安装路径，（例如debian中改为/usr），在bootstrap命令中加入'--prefix=PATH'选项。&lt;br /&gt;
&lt;br /&gt;
如果你想使用当前的开发版本，请遵循[http://cmake.org/HTML/Download.html#cvs 这里]的指令。&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
从[http://www.cmake.org/HTML/Download.html]获得取回最新的CMake稳定版。&lt;br /&gt;
&lt;br /&gt;
下载完后，运行cmake的安装程序。&lt;br /&gt;
&lt;br /&gt;
默认将把CMake安装在C:\Program Files\CMake 2.4,，因此要确保&amp;lt;installpath&amp;gt;\bin在你的执行路径中。&lt;br /&gt;
&lt;br /&gt;
如果你想使用当前的开发版本，请遵循[http://cmake.org/HTML/Download.html#cvs 这里]的指令。&lt;br /&gt;
&lt;br /&gt;
==== Mac OSX ====&lt;br /&gt;
&lt;br /&gt;
=== 运行CMake ===&lt;br /&gt;
&lt;br /&gt;
==== Linux、BSD及其他Unix系统 ====&lt;br /&gt;
你必须运行CMake来为你的系统生成build文件。CMake支持in-source和out-of-source构建，不过目前KDE默认禁用in-source构建。&lt;br /&gt;
&lt;br /&gt;
假定你在~/src/kdelibs/中有kdelibs/，那么，输入：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ ls&lt;br /&gt;
kdelibs/&lt;br /&gt;
$ mkdir kdelibs-build&lt;br /&gt;
$ cd kdelibs-build&lt;br /&gt;
$ cmake ../kdelibs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这会在kdelibs-build/中生成构建kdelibs/的Makefiles。&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
你必须运行CMake来为你的系统生成build文件。CMake支持in-source和out-of-source构建，不过目前KDE默认禁用in-source构建。&lt;br /&gt;
&lt;br /&gt;
假定你在c:\daten\kde4中有kdelibs\，那么，输入：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
c:\daten\kde4&amp;gt; cd kdelibs\win&lt;br /&gt;
c:\daten\kde4&amp;gt; cmake&lt;br /&gt;
c:\daten\kde4&amp;gt; make &lt;br /&gt;
c:\daten\kde4&amp;gt; make install&lt;br /&gt;
c:\daten\kde4&amp;gt; cd ..&lt;br /&gt;
c:\daten\kde4&amp;gt; mkdir kdelibs-build&lt;br /&gt;
c:\daten\kde4&amp;gt; cd kdelibs-build&lt;br /&gt;
c:\daten\kde4\kdelibs-build&amp;gt; cmake ..\kdelibs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
这样就生成了在 kdelibs-build\中构建kdelibs\的Makefiles。要获得更多的关于在Windows下编译KDE的信息，请阅读[[KDE On Windows]]。&lt;br /&gt;
&lt;br /&gt;
==== Mac OSX ====&lt;br /&gt;
&lt;br /&gt;
==== KDevelop项目 ====&lt;br /&gt;
如果你更喜欢KDevelop的项目文件（基本上就是Makefiles及为KDevelop生成的一些文件），这样运行CMake：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ cmake ../kdelibs -GKDevelop3&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
使用“cmake -h”来查看CMake支持那些生成器 （generators）及其他的选项。&lt;br /&gt;
&lt;br /&gt;
==== CMake和Qt4 ====&lt;br /&gt;
为了定位Qt 4，CMake会在你的执行路径中搜索qmake。CMake''不''会使用QTDIR这个环境变量。因此请确保在执行路径中寻找到的第一个qmake就是你希望使用的。&lt;br /&gt;
&lt;br /&gt;
==== 更多细节 ====&lt;br /&gt;
当CMake执行完成，它会生成一个叫“CMakeCache.txt”的文件。这个文件包含了CMake在你的系统上检测到的所有设置。如果你希望在其他生成器（generators)上运行CMake,或你希望CMake重新检测系统，请删除这个文件。&lt;br /&gt;
&lt;br /&gt;
如果有些东西你知道它存在，而CMake没有检测到，你可以手动的告诉CMake到哪里去找它。CMake通过变量来存储这些信息。这些变量缓存在前面提到的 CMakeCache.txt中。这里有3个选项来手工调整这些变量：&lt;br /&gt;
* 通过命令行告诉CMake现在的值: cmake ../kdelibs -DNAME_OF_THE_VARIABLE=value&lt;br /&gt;
* 使用ccmake，它提供了一个基于鼠标的GUI来调整CMake变量（运行: ccmake ../kdelibs）&lt;br /&gt;
* 直接编辑CMakeCache.txt（不推荐）&lt;br /&gt;
&lt;br /&gt;
你应该最起码运行一次“ccmake ../kdelibs”，这样你会对CMake使用了那些变量有个印象。按“T”来查看“高级”的变量。如果有些东西CMake没有找到，运行ccmake并手工调整它。&lt;br /&gt;
&lt;br /&gt;
一些你可能希望设置的变量：&lt;br /&gt;
* '''CMAKE_INSTALL_PREFIX''': cmake ../kdelibs -DCMAKE_INSTALL_PREFIX=/opt/kde4 相当于./configure --prefix=/opt/kde4&lt;br /&gt;
* '''CMAKE_BUILD_TYPE''': 决定你如何构建系统。你可以在“debugfull”、“debug”、“profile”、“relwithdebinfo”和“release”中进行选择。默认的是“relwithdebinfo”(-O2 -g)。更多细节查看FindKDE4Internal.cmake。&lt;br /&gt;
* '''RPATH_STYLE''': 这个不再有效了。默认情况下，一切都将在RPATH设置正确的情况下来构建。如果你不希望使用RPATH，将CMAKE_SKIP_RPATH设置为TRUE。&lt;br /&gt;
* '''WITH_FOO''': 这里有一些选项，例如WITH_CUPS或WITH_Jasper。如果你将他们关闭，cmake甚至不会去尝试寻找这个包。如果将它激活，cmake将会尝试寻找这个包。如果这样做失败了，你还可以通过上面介绍的方法手工设置。&lt;br /&gt;
&lt;br /&gt;
=== 环境变量 ===&lt;br /&gt;
如果你在CMake没法找到的非标准位置安装了头文件或库（ 例如Mac OSX下把fink安装到/sw），那么就请设置下面这些环境变量。尽管有相似的命名规则，这些设置在cmake的命令中并不会做为参数来工作。&lt;br /&gt;
* '''CMAKE_INCLUDE_PATH'''，例如export CMAKE_INCLUDE_PATH=/sw/include&lt;br /&gt;
* '''CMAKE_LIBRARY_PATH'''，例如export CMAKE_LIBRARY_PATH=/sw/lib&lt;br /&gt;
&lt;br /&gt;
关于变量的更多信息，请参考&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_Useful_Variables cmake.org wiki page]。&lt;br /&gt;
&lt;br /&gt;
=== 更进一步 ===&lt;br /&gt;
如果cmake以“Generating done”结束，那表示没有错误，但如果以“Configuring done”结束，那表示有错误需要修正。当cmake成功结束，运行你的构建工具（如make、KDevelop、XCode或MSVC）来构建并等到它结束。然后运行“make install”。&lt;br /&gt;
&lt;br /&gt;
如果你得到如下错误提示：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
CMake Error: This project requires some variables to be set,&lt;br /&gt;
and cmake can not find them.&lt;br /&gt;
Please set the following variables:&lt;br /&gt;
X11_XTest_LIB (ADVANCED)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
那表示你可能缺少库（或其他依赖包）。在cmake/modules目录中查找cmake无法找到的变量来确定是缺少哪个库文件。在上面的例子中，就是：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
FIND_LIBRARY(X11_XTest_LIB Xtst ${X11_LIB_SEARCH_PATH})&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这里缺失的库是Xtst。然后你找到这个库（也许是通过安装libXtst-devel）并再次运行cmake。&lt;br /&gt;
&lt;br /&gt;
== 在简单的应用中使用CMake ==&lt;br /&gt;
这是最简单的CMakeLists.txt：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
add_executable(hello main.cpp)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这将从main.cpp源码文件创建一个叫“hello”（Windows下叫“hello.exe”）的可执行文件。你可以根据自己的需要将C和C++文件混合。在同一个CMakeLists.txt可以有多个可执行文件和库。同一个源码文件可以用于不同的目的，源码可以从其他目标中为每个目的独立的编译。CMake语言最重要的部分可能是变量：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SET( MY_SOURCES main.cpp widget.cpp)&lt;br /&gt;
MESSAGE(STATUS &amp;quot;my sources: ${MY_SOURCES}&amp;quot;)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
使用SET()命令来为变量设置值。如果你列出了一个以上的字符串，变量将是串列表。列表是一列由分号隔开的字符串。如果只设置个一项，那么这项只有一个值。可以通过${VAR}获得变量的值。可以使用FOREACH()来迭代一份列表：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
FOREACH(next_ITEM ${MY_SOURCES})&lt;br /&gt;
   MESSAGE(STATUS &amp;quot;next item: ${next_ITEM}&amp;quot;)&lt;br /&gt;
ENDFOREACH(next_ITEM ${MY_SOURCES})&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
CMake中的命令是大小写无关的。变量名和参数名是大小写相关的。&lt;br /&gt;
&lt;br /&gt;
还可以测试一些不同的东西：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
IF (UNIX)&lt;br /&gt;
   MESSAGE(STATUS &amp;quot;This is UNIX (including OS X and CygWin)&amp;quot;)&lt;br /&gt;
ENDIF (UNIX)&lt;br /&gt;
&lt;br /&gt;
IF (MSVC)&lt;br /&gt;
   SET(MY_SRCS ${MY_SRCS} winextra.cpp)&lt;br /&gt;
ENDIF (MSVC)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
在第二个例子中，你可以看到如何将项目附加到列表中。&lt;br /&gt;
&lt;br /&gt;
在cmake Wiki中有一份使用cmake构建KDE4软件的[http://www.cmake.org/Wiki/HowToBuildKDE4Software 指导]，推荐阅读。&lt;br /&gt;
&lt;br /&gt;
== 在KDE项目中使用CMake ==&lt;br /&gt;
这里是一份基本的构建一个小KDE4项目的CMakeList文件：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
PROJECT( kde4project)&lt;br /&gt;
FIND_PACKAGE(KDE4 REQUIRED)&lt;br /&gt;
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} )&lt;br /&gt;
&lt;br /&gt;
SET(KDE4ProjectSources kde4mainapp.cpp someclass.cpp someotherclass.cpp)&lt;br /&gt;
&lt;br /&gt;
KDE4_AUTOMOC( ${KDE4ProjectSources} )&lt;br /&gt;
&lt;br /&gt;
KDE4_ADD_EXECUTABLE(kde4project ${KDE4ProjectSources} )&lt;br /&gt;
&lt;br /&gt;
TARGET_LINK_LIBRARIES(kde4project ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 扩展CMake ==&lt;br /&gt;
CMake可以通过cmake脚本扩展，CMake带有大量的脚本，在UNIX下，这些脚本默认安装在 /usr/local/share/CMake/Modules/内。KDE库也在/apps/cmake/modules/安装了一些CMake模块。这里的文件将被代替CMake的系统全局模块路径。FindFOO.cmake用来检测软件包，&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 这里]有更多信息。在CMake中也可以写宏文件，对于大多数的软件构建来说，他们足够强大了。这些宏不会做为通用语言来使用。&lt;br /&gt;
&lt;br /&gt;
你还可以在CMake中编写宏。他们非常强大，可以满足你编译的软件中所需要的所有事情，但是他们并不是被用作通用目的的编程语言。&lt;br /&gt;
&lt;br /&gt;
== 将基于autotools的KDE软件转换为CMake ==&lt;br /&gt;
你可以在kdesdk/cmake/找到am2cmake脚本。这是ruby写成的，所以确定你的系统安装了ruby。在你的源码目录最上层运行am2cmak：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ cd src/mykooltool/&lt;br /&gt;
$ am2cmake --kde4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
不要忘了开关“--kde4”，不然系统无法生成适合KDE4的文件。转换文件可能会正常工作，但编译的项目将需要一些额外的编辑。&lt;br /&gt;
&lt;br /&gt;
你可能需要：&lt;br /&gt;
* 使用INCLUDE_DIRECTORIES()添加更多include目录。&lt;br /&gt;
* 使用TARGET_LINK_LIBRARIES()添加更多链接库。&lt;br /&gt;
* 使用ADD_DEFINITIONS()添加更多编译开关。&lt;br /&gt;
* 添加一些“configure”检查，参照[http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks 如何进行平台检查]和[http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 如何找到已经安装的软件]。&lt;br /&gt;
* 特别要注意以往的libtool便捷库，CMake并不支持这些库，而是生成一个ConvenienceLibs.cmake文件代替。在这个文件里，你可以为每个便捷库找到一个包含了这个库所有源码的变量。对于链接到这些库的目标，只要在源码中添加这些变量即可。&lt;br /&gt;
* 一个AdditionalInfo.txt文件将被创建。你可以在这里找到项目所有的*.in和*.in.in文件。这些文件完成的任务将被手工转换到CMake.&lt;br /&gt;
&lt;br /&gt;
== 常见问题 ==&lt;br /&gt;
&lt;br /&gt;
=== 如何使我最喜欢的编辑器支持CMake的语法和缩进？ ===&lt;br /&gt;
请阅读CMake Wiki中[http://www.cmake.org/Wiki/CMake_Editors_Support CMake编辑器支持]这部分。这里介绍了如何设置Emac、VI、Kat、KWrite和KDevelop。&lt;br /&gt;
&lt;br /&gt;
=== 我需要在构建过程中产生一些文件，我该如何做？ ===&lt;br /&gt;
使用ADD_CUSTOM_COMMAND()。这里有解释：[http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F 在构建过程中如何生成一个源文件]。&lt;br /&gt;
&lt;br /&gt;
=== 我想在产生文件的构建过程中创建一个稍后使用的可执行文件，我要如何做？ ===&lt;br /&gt;
假定可执行文件叫genembed。那么使用KDE4_ADD_EXECUTABLE(foo RUN_UNINSTALLED ${fooSources})来生成可执行文件。RUN_UNINSTALLED选项非常重要，因为可执行文件必须从构建目录运行，并会链接到builddir中的一些库。为达到这个目的，可执行文件通过相应设置的RPATH和包装的外壳脚本编译，和可执行文件的命名一样只是多了“.sh”后缀。这个外壳脚本设置LD_LIBRARY_PATH并调用实际的可执行文件。象上面介绍的在ADD_CUSTOM_COMMAND()中使用这个包装的外壳脚本。可以通过查询WRAPPER_SCRIPT来获得名称和确切的路径。这里有一个来自kdelibs/kstyles/keramik/完整的例子：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# build the executable&lt;br /&gt;
KDE4_ADD_EXECUTABLE(genembed RUN_UNINSTALLED ${genembed_SRCS})&lt;br /&gt;
&lt;br /&gt;
# get the name of the generated wrapper script (which sets up LD_LIBRARY_PATH)&lt;br /&gt;
GET_TARGET_PROPERTY(GENEMBED_EXECUTABLE genembed WRAPPER_SCRIPT)&lt;br /&gt;
&lt;br /&gt;
# and the custom command&lt;br /&gt;
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/keramikrc.h&lt;br /&gt;
  COMMAND ${GENEMBED_EXECUTABLE} --file ${CMAKE_CURRENT_BINARY_DIR}/keramikPics.txt &amp;gt; \&lt;br /&gt;
  ${CMAKE_CURRENT_BINARY_DIR}/pixmaps.keramik&lt;br /&gt;
  DEPENDS genembed ${keramikPics}&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
如你所见genembed也做为依赖关系列出。这表示CMake知道它应该在执行这些规则之前创建genembed的可执行文件。&lt;br /&gt;
&lt;br /&gt;
=== 我不想设置-DCMAKE_INSTALL_PREFIX命令行参数。CMake是否支持KDEDIR环境变量？ ===&lt;br /&gt;
不。KDE4反对使用$KDEDIR。&lt;br /&gt;
&lt;br /&gt;
=== 为什么我会得到类似/usr/lib/qt4/include/QtCore/qstring.h:536: undefined reference to `QString::fromLatin1_helper(char const*, int)'的编译错误？ ===&lt;br /&gt;
如果你的qt/lib目录下有个老版本的Qt4，你必须删除这些老版本（4.0.4）文件。&lt;br /&gt;
&lt;br /&gt;
=== 我如何让CMake创建noisy makefiles？我希望准确的看到make过程执行的命令。 ===&lt;br /&gt;
给make传递 VERBOSE 变量，例如：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
% make VERBOSE=1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
或者&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
% VERBOSE=1 make&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
更多细节请查看CMake wiki：&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_FAQ#Is_there_an_option_to_produce_more_.27verbose.27_compiling.3F 有没有选项可以产生更多的“verbose”编译？]&lt;br /&gt;
&lt;br /&gt;
=== 产生的Makefiles中没有“make distclean”标签。我如何才能清理包括cache文件在内的所有文件？ ===&lt;br /&gt;
只需删除构建目录，或目录里包含的内容。&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
[[Category:FAQs]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Development/Tutorials/CMake_(zh_CN)</id>
		<title>Development/Tutorials/CMake (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Development/Tutorials/CMake_(zh_CN)"/>
				<updated>2007-04-01T14:37:17Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: a typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:CMake}}&lt;br /&gt;
&lt;br /&gt;
== 简介 ==&lt;br /&gt;
CMake读取脚本文件并且为它所运行的平台的本地构建系统产生输入文件。它可以生成GNU Makefiles、KDevelop的项目文件、XCode项目文件以及Visual Studio项目文件等多种文件格式。&lt;br /&gt;
&lt;br /&gt;
CMake是自由软件并且是在BSD协议下发布的。它是由[http://www.kitware.com Kitware公司]开发的。&lt;br /&gt;
&lt;br /&gt;
这些地方学习CMake挺不错的：&lt;br /&gt;
* [http://www.cmake.org/HTML/Documentation.html CMake手册]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake CMake Wiki]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks CMake系统检查]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 查找可替换的软件包]&lt;br /&gt;
* [http://www.cmake.org/Wiki/HowToBuildKDE4Software CMake Wiki上的KDE4指导]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_FAQ CMake FAQ]&lt;br /&gt;
* [http://mail.kde.org/pipermail/kde-buildsystem/ kde-buildsystem的邮件列表存档]&lt;br /&gt;
&lt;br /&gt;
另外，还可以考虑加入[http://www.cmake.org/mailman/listinfo/cmake CMake邮件列表]。&lt;br /&gt;
&lt;br /&gt;
== 为什么使用CMake？ ==&lt;br /&gt;
CMake是KDE 4发布中的官方工具，这是在2006年3月决定的，它和以前的KDE工具automake和unsermake的主要技术不同点有：&lt;br /&gt;
* CMake是独立于KDE开发的，它也可以被用于其它项目。&lt;br /&gt;
* 编译时间更快，主要是因为没有再使用libtool。&lt;br /&gt;
* 构建文件更容易编写。&lt;br /&gt;
&lt;br /&gt;
== 如何使用CMake编译KDE ==&lt;br /&gt;
&lt;br /&gt;
=== 获取和安装CMake ===&lt;br /&gt;
==== Linux、BSD及其他Unix系统 ====&lt;br /&gt;
从[http://www.cmake.org/HTML/Download.html]获得取回最新的CMake稳定版。&lt;br /&gt;
&lt;br /&gt;
下载完后，解压并安装：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ mkdir cmake-build&lt;br /&gt;
$ cd cmake-build&lt;br /&gt;
$ ../bootstrap&lt;br /&gt;
$ make&lt;br /&gt;
$ make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
默认的，这将把CMake安装在/usr/local，因此，确定/usr/local/bin在的执行路径里。要改变安装路径，（例如debian中改为/usr），在bootstrap命令中加入'--prefix=PATH'选项。&lt;br /&gt;
&lt;br /&gt;
如果你想使用当前的开发版本，请遵循[http://cmake.org/HTML/Download.html#cvs here]的指令。&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
从[http://www.cmake.org/HTML/Download.html]获得取回最新的CMake稳定版。&lt;br /&gt;
&lt;br /&gt;
下载完后，运行cmake的安装程序。&lt;br /&gt;
&lt;br /&gt;
默认将把CMake安装在C:\Program Files\CMake 2.4,，因此要确保&amp;lt;installpath&amp;gt;\bin在你的执行路径中。&lt;br /&gt;
&lt;br /&gt;
如果你想使用当前的开发版本，请遵循[http://cmake.org/HTML/Download.html#cvs here]的指令。&lt;br /&gt;
&lt;br /&gt;
==== Mac OSX ====&lt;br /&gt;
&lt;br /&gt;
=== 运行CMake ===&lt;br /&gt;
&lt;br /&gt;
==== Linux、BSD及其他Unix系统 ====&lt;br /&gt;
你必须运行CMake来为你的系统生成build文件。CMake支持in-source和out-of-source构建，不过目前KDE默认禁用in-source构建。&lt;br /&gt;
&lt;br /&gt;
假定你在~/src/kdelibs/中有kdelibs/，那么，输入：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ ls&lt;br /&gt;
kdelibs/&lt;br /&gt;
$ mkdir kdelibs-build&lt;br /&gt;
$ cd kdelibs-build&lt;br /&gt;
$ cmake ../kdelibs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这会在kdelibs-build/中生成构建kdelibs/的Makefiles。&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
你必须运行CMake来为你的系统生成build文件。CMake支持in-source和out-of-source构建，不过目前KDE默认禁用in-source构建。&lt;br /&gt;
&lt;br /&gt;
假定你在c:\daten\kde4中有kdelibs\，那么，输入：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
c:\daten\kde4&amp;gt; cd kdelibs\win&lt;br /&gt;
c:\daten\kde4&amp;gt; cmake&lt;br /&gt;
c:\daten\kde4&amp;gt; make &lt;br /&gt;
c:\daten\kde4&amp;gt; make install&lt;br /&gt;
c:\daten\kde4&amp;gt; cd ..&lt;br /&gt;
c:\daten\kde4&amp;gt; mkdir kdelibs-build&lt;br /&gt;
c:\daten\kde4&amp;gt; cd kdelibs-build&lt;br /&gt;
c:\daten\kde4\kdelibs-build&amp;gt; cmake ..\kdelibs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
这样就生成了在 kdelibs-build\中构建kdelibs\的Makefiles。要获得更多的关于在Windows下编译KDE的信息，请阅读[[KDE On Windows]]。&lt;br /&gt;
&lt;br /&gt;
==== Mac OSX ====&lt;br /&gt;
&lt;br /&gt;
==== KDevelop项目 ====&lt;br /&gt;
如果你更喜欢KDevelop的项目文件（基本上就是Makefiles及为KDevelop生成的一些文件），这样运行CMake：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ cmake ../kdelibs -GKDevelop3&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
使用“cmake -h”来查看CMake支持那些生成器 （generators）及其他的选项。&lt;br /&gt;
&lt;br /&gt;
==== CMake和Qt4 ====&lt;br /&gt;
为了定位Qt 4，CMake会在你的执行路径中搜索qmake。CMake''不''会使用QTDIR这个环境变量。因此请确保在执行路径中寻找到的第一个qmake就是你希望使用的。&lt;br /&gt;
&lt;br /&gt;
==== 更多细节 ====&lt;br /&gt;
当CMake执行完成，它会生成一个叫“CMakeCache.txt”的文件。这个文件包含了CMake在你的系统上检测到的所有设置。如果你希望在其他生成器（generators)上运行CMake,或你希望CMake重新检测系统，请删除这个文件。&lt;br /&gt;
&lt;br /&gt;
如果有些东西你知道它存在，而CMake没有检测到，你可以手动的告诉CMake到哪里去找它。CMake通过变量来存储这些信息。这些变量缓存在前面提到的 CMakeCache.txt中。这里有3个选项来手工调整这些变量：&lt;br /&gt;
* 通过命令行告诉CMake现在的值: cmake ../kdelibs -DNAME_OF_THE_VARIABLE=value&lt;br /&gt;
* 使用ccmake，它提供了一个基于鼠标的GUI来调整CMake变量（运行: ccmake ../kdelibs）&lt;br /&gt;
* 直接编辑CMakeCache.txt（不推荐）&lt;br /&gt;
&lt;br /&gt;
你应该最起码运行一次“ccmake ../kdelibs”，这样你会对CMake使用了那些变量有个印象。按“T”来查看“高级”的变量。如果有些东西CMake没有找到，运行ccmake并手工调整它。&lt;br /&gt;
&lt;br /&gt;
一些你可能希望设置的变量：&lt;br /&gt;
* '''CMAKE_INSTALL_PREFIX''': cmake ../kdelibs -DCMAKE_INSTALL_PREFIX=/opt/kde4 相当于./configure --prefix=/opt/kde4&lt;br /&gt;
* '''CMAKE_BUILD_TYPE''': 决定你如何构建系统。你可以在“debugfull”、“debug”、“profile”、“relwithdebinfo”和“release”中进行选择。默认的是“relwithdebinfo”(-O2 -g)。更多细节查看FindKDE4Internal.cmake。&lt;br /&gt;
* '''RPATH_STYLE''': 这个不再有效了。默认情况下，一切都将在RPATH设置正确的情况下来构建。如果你不希望使用RPATH，将CMAKE_SKIP_RPATH设置为TRUE。&lt;br /&gt;
* '''WITH_FOO''': 这里有一些选项，例如WITH_CUPS或WITH_Jasper。如果你将他们关闭，cmake甚至不会去尝试寻找这个包。如果将它激活，cmake将会尝试寻找这个包。如果这样做失败了，你还可以通过上面介绍的方法手工设置。&lt;br /&gt;
&lt;br /&gt;
=== 环境变量 ===&lt;br /&gt;
如果你在CMake没法找到的非标准位置安装了头文件或库（ 例如Mac OSX下把fink安装到/sw），那么就请设置下面这些环境变量。尽管有相似的命名规则，这些设置在cmake的命令中并不会做为参数来工作。&lt;br /&gt;
* '''CMAKE_INCLUDE_PATH'''，例如export CMAKE_INCLUDE_PATH=/sw/include&lt;br /&gt;
* '''CMAKE_LIBRARY_PATH'''，例如export CMAKE_LIBRARY_PATH=/sw/lib&lt;br /&gt;
&lt;br /&gt;
关于变量的更多信息，请参考&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_Useful_Variables cmake.org wiki page]。&lt;br /&gt;
&lt;br /&gt;
=== 更进一步 ===&lt;br /&gt;
如果cmake以“Generating done”结束，那表示没有错误，但如果以“Configuring done”结束，那表示有错误需要修正。当cmake成功结束，运行你的构建工具（如make、KDevelop、XCode或MSVC）来构建并等到它结束。然后运行“make install”。&lt;br /&gt;
&lt;br /&gt;
如果你得到如下错误提示：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
CMake Error: This project requires some variables to be set,&lt;br /&gt;
and cmake can not find them.&lt;br /&gt;
Please set the following variables:&lt;br /&gt;
X11_XTest_LIB (ADVANCED)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
那表示你可能缺少库（或其他依赖包）。在cmake/modules目录中查找cmake无法找到的变量来确定是缺少哪个库文件。在上面的例子中，就是：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
FIND_LIBRARY(X11_XTest_LIB Xtst ${X11_LIB_SEARCH_PATH})&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这里缺失的库是Xtst。然后你找到这个库（也许是通过安装libXtst-devel）并再次运行cmake。&lt;br /&gt;
&lt;br /&gt;
== 在简单的应用中使用CMake ==&lt;br /&gt;
这是最简单的CMakeLists.txt：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
add_executable(hello main.cpp)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这将从main.cpp源码文件创建一个叫“hello”（Windows下叫“hello.exe”）的可执行文件。你可以根据自己的需要将C和C++文件混合。在同一个CMakeLists.txt可以有多个可执行文件和库。同一个源码文件可以用于不同的目的，源码可以从其他目标中为每个目的独立的编译。CMake语言最重要的部分可能是变量：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SET( MY_SOURCES main.cpp widget.cpp)&lt;br /&gt;
MESSAGE(STATUS &amp;quot;my sources: ${MY_SOURCES}&amp;quot;)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
使用SET()命令来为变量设置值。如果你列出了一个以上的字符串，变量将是串列表。列表是一列由分号隔开的字符串。如果只设置个一项，那么这项只有一个值。可以通过${VAR}获得变量的值。可以使用FOREACH()来迭代一份列表：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
FOREACH(next_ITEM ${MY_SOURCES})&lt;br /&gt;
   MESSAGE(STATUS &amp;quot;next item: ${next_ITEM}&amp;quot;)&lt;br /&gt;
ENDFOREACH(next_ITEM ${MY_SOURCES})&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
CMake中的命令是大小写无关的。变量名和参数名是大小写相关的。&lt;br /&gt;
&lt;br /&gt;
还可以测试一些不同的东西：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
IF (UNIX)&lt;br /&gt;
   MESSAGE(STATUS &amp;quot;This is UNIX (including OS X and CygWin)&amp;quot;)&lt;br /&gt;
ENDIF (UNIX)&lt;br /&gt;
&lt;br /&gt;
IF (MSVC)&lt;br /&gt;
   SET(MY_SRCS ${MY_SRCS} winextra.cpp)&lt;br /&gt;
ENDIF (MSVC)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
在第二个例子中，你可以看到如何将项目附加到列表中。&lt;br /&gt;
&lt;br /&gt;
在cmake Wiki中有一份使用cmake构建KDE4软件的[http://www.cmake.org/Wiki/HowToBuildKDE4Software 指导]，推荐阅读。&lt;br /&gt;
&lt;br /&gt;
== 在KDE项目中使用CMake ==&lt;br /&gt;
这里是一份基本的构建一个小KDE4项目的CMakeList文件：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
PROJECT( kde4project)&lt;br /&gt;
FIND_PACKAGE(KDE4 REQUIRED)&lt;br /&gt;
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} )&lt;br /&gt;
&lt;br /&gt;
SET(KDE4ProjectSources kde4mainapp.cpp someclass.cpp someotherclass.cpp)&lt;br /&gt;
&lt;br /&gt;
KDE4_AUTOMOC( ${KDE4ProjectSources} )&lt;br /&gt;
&lt;br /&gt;
KDE4_ADD_EXECUTABLE(kde4project ${KDE4ProjectSources} )&lt;br /&gt;
&lt;br /&gt;
TARGET_LINK_LIBRARIES(kde4project ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 扩展CMake ==&lt;br /&gt;
CMake可以通过cmake脚本扩展，CMake带有大量的脚本，在UNIX下，这些脚本默认安装在 /usr/local/share/CMake/Modules/内。KDE库也在/apps/cmake/modules/安装了一些CMake模块。这里的文件将被代替CMake的系统全局模块路径。FindFOO.cmake用来检测软件包，&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 这里]有更多信息。在CMake中也可以写宏文件，对于大多数的软件构建来说，他们足够强大了。这些宏不会做为通用语言来使用。&lt;br /&gt;
&lt;br /&gt;
你还可以在CMake中编写宏。他们非常强大，可以满足你编译的软件中所需要的所有事情，但是他们并不是被用作通用目的的编程语言。&lt;br /&gt;
&lt;br /&gt;
== 将基于autotools的KDE软件转换为CMake ==&lt;br /&gt;
你可以在kdesdk/cmake/找到am2cmake脚本。这是ruby写成的，所以确定你的系统安装了ruby。在你的源码目录最上层运行am2cmak：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ cd src/mykooltool/&lt;br /&gt;
$ am2cmake --kde4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
不要忘了开关“--kde4”，不然系统无法生成适合KDE4的文件。转换文件可能会正常工作，但编译的项目将需要一些额外的编辑。&lt;br /&gt;
&lt;br /&gt;
你可能需要：&lt;br /&gt;
* 使用INCLUDE_DIRECTORIES()添加更多include目录。&lt;br /&gt;
* 使用TARGET_LINK_LIBRARIES()添加更多链接库。&lt;br /&gt;
* 使用ADD_DEFINITIONS()添加更多编译开关。&lt;br /&gt;
* 添加一些“configure”检查，参照[http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks 如何进行平台检查]和[http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 如何找到已经安装的软件]。&lt;br /&gt;
* 特别要注意以往的libtool便捷库，CMake并不支持这些库，而是生成一个ConvenienceLibs.cmake文件代替。在这个文件里，你可以为每个便捷库找到一个包含了这个库所有源码的变量。对于链接到这些库的目标，只要在源码中添加这些变量即可。&lt;br /&gt;
* 一个AdditionalInfo.txt文件将被创建。你可以在这里找到项目所有的*.in和*.in.in文件。这些文件完成的任务将被手工转换到CMake.&lt;br /&gt;
&lt;br /&gt;
== 常见问题 ==&lt;br /&gt;
&lt;br /&gt;
=== 如何使我最喜欢的编辑器支持CMake的语法和缩进？ ===&lt;br /&gt;
请阅读CMake Wiki中[http://www.cmake.org/Wiki/CMake_Editors_Support CMake编辑器支持]这部分。这里介绍了如何设置Emac、VI、Kat、KWrite和KDevelop。&lt;br /&gt;
&lt;br /&gt;
=== 我需要在构建过程中产生一些文件，我该如何做？ ===&lt;br /&gt;
使用ADD_CUSTOM_COMMAND()。这里有解释：[http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F 在构建过程中如何生成一个源文件]。&lt;br /&gt;
&lt;br /&gt;
=== 我想在产生文件的构建过程中创建一个稍后使用的可执行文件，我要如何做？ ===&lt;br /&gt;
假定可执行文件叫genembed。那么使用KDE4_ADD_EXECUTABLE(foo RUN_UNINSTALLED ${fooSources})来生成可执行文件。RUN_UNINSTALLED选项非常重要，因为可执行文件必须从构建目录运行，并会链接到builddir中的一些库。为达到这个目的，可执行文件通过相应设置的RPATH和包装的外壳脚本编译，和可执行文件的命名一样只是多了“.sh”后缀。这个外壳脚本设置LD_LIBRARY_PATH并调用实际的可执行文件。象上面介绍的在ADD_CUSTOM_COMMAND()中使用这个包装的外壳脚本。可以通过查询WRAPPER_SCRIPT来获得名称和确切的路径。这里有一个来自kdelibs/kstyles/keramik/完整的例子：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# build the executable&lt;br /&gt;
KDE4_ADD_EXECUTABLE(genembed RUN_UNINSTALLED ${genembed_SRCS})&lt;br /&gt;
&lt;br /&gt;
# get the name of the generated wrapper script (which sets up LD_LIBRARY_PATH)&lt;br /&gt;
GET_TARGET_PROPERTY(GENEMBED_EXECUTABLE genembed WRAPPER_SCRIPT)&lt;br /&gt;
&lt;br /&gt;
# and the custom command&lt;br /&gt;
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/keramikrc.h&lt;br /&gt;
  COMMAND ${GENEMBED_EXECUTABLE} --file ${CMAKE_CURRENT_BINARY_DIR}/keramikPics.txt &amp;gt; \&lt;br /&gt;
  ${CMAKE_CURRENT_BINARY_DIR}/pixmaps.keramik&lt;br /&gt;
  DEPENDS genembed ${keramikPics}&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
如你所见genembed也做为依赖关系列出。这表示CMake知道它应该在执行这些规则之前创建genembed的可执行文件。&lt;br /&gt;
&lt;br /&gt;
=== 我不想设置-DCMAKE_INSTALL_PREFIX命令行参数。CMake是否支持KDEDIR环境变量？ ===&lt;br /&gt;
不。KDE4反对使用$KDEDIR。&lt;br /&gt;
&lt;br /&gt;
=== 为什么我会得到类似/usr/lib/qt4/include/QtCore/qstring.h:536: undefined reference to `QString::fromLatin1_helper(char const*, int)'的编译错误？ ===&lt;br /&gt;
如果你的qt/lib目录下有个老版本的Qt4，你必须删除这些老版本（4.0.4）文件。&lt;br /&gt;
&lt;br /&gt;
=== 我如何让CMake创建noisy makefiles？我希望准确的看到make过程执行的命令。 ===&lt;br /&gt;
给make传递 VERBOSE 变量，例如：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
% make VERBOSE=1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
或者&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
% VERBOSE=1 make&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
更多细节请查看CMake wiki：&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_FAQ#Is_there_an_option_to_produce_more_.27verbose.27_compiling.3F 有没有选项可以产生更多的“verbose”编译？]&lt;br /&gt;
&lt;br /&gt;
=== 产生的Makefiles中没有“make distclean”标签。我如何才能清理包括cache文件在内的所有文件？ ===&lt;br /&gt;
只需删除构建目录，或目录里包含的内容。&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
[[Category:FAQs]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Development/Tutorials/CMake_(zh_CN)</id>
		<title>Development/Tutorials/CMake (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Development/Tutorials/CMake_(zh_CN)"/>
				<updated>2007-04-01T14:34:51Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: move all chinese from kdecn.org(Huanzhou Zhu)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:CMake}}&lt;br /&gt;
&lt;br /&gt;
== 简介 ==&lt;br /&gt;
CMake读取脚本文件并且为它所运行的平台的本地构建系统产生输入文件。它可以生成GNU Makefiles、KDevelop的项目文件、XCode项目文件以及Visual Studio项目文件等多种文件格式。&lt;br /&gt;
&lt;br /&gt;
CMake是自由软件并且是在BSD协议下发布的。它是由[http://www.kitware.com Kitware公司]开发的。&lt;br /&gt;
&lt;br /&gt;
这些地方学习CMake挺不错的：&lt;br /&gt;
* [http://www.cmake.org/HTML/Documentation.html CMake手册]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake CMake Wiki]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks CMake系统检查]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 查找可替换的软件包]&lt;br /&gt;
* [http://www.cmake.org/Wiki/HowToBuildKDE4Software CMake Wiki上的KDE4指导]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_FAQ CMake FAQ]&lt;br /&gt;
* [http://mail.kde.org/pipermail/kde-buildsystem/ kde-buildsystem的邮件列表存档]&lt;br /&gt;
&lt;br /&gt;
另外，还可以考虑加入[http://www.cmake.org/mailman/listinfo/cmake CMake邮件列表]。&lt;br /&gt;
&lt;br /&gt;
== 为什么使用CMake？ ==&lt;br /&gt;
CMake是KDE 4发布中的官方工具，这是在2006年3月决定的，它和以前的KDE工具automake和unsermake的主要技术不同点有：&lt;br /&gt;
* CMake是独立于KDE开发的，它也可以被用于其它项目。&lt;br /&gt;
* 编译时间更快，主要是因为没有再使用libtool。&lt;br /&gt;
* 构建文件更容易编写。&lt;br /&gt;
&lt;br /&gt;
== 如何使用CMake编译KDE ==&lt;br /&gt;
&lt;br /&gt;
=== 获取和安装CMake ===&lt;br /&gt;
==== Linux、BSD及其他Unix系统 ====&lt;br /&gt;
从[http://www.cmake.org/HTML/Download.html]获得取回最新的CMake稳定版。&lt;br /&gt;
&lt;br /&gt;
下载完后，解压并安装：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ mkdir cmake-build&lt;br /&gt;
$ cd cmake-build&lt;br /&gt;
$ ../bootstrap&lt;br /&gt;
$ make&lt;br /&gt;
$ make install&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
默认的，这将把CMake安装在/usr/local，因此，确定/usr/local/bin在的执行路径里。要改变安装路径，（例如debian中改为/usr），在bootstrap命令中加入'--prefix=PATH'选项。&lt;br /&gt;
&lt;br /&gt;
如果你想使用当前的开发版本，请遵循[http://cmake.org/HTML/Download.html#cvs here]的指令。&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
从[http://www.cmake.org/HTML/Download.html]获得取回最新的CMake稳定版。&lt;br /&gt;
&lt;br /&gt;
下载完后，运行cmake的安装程序。&lt;br /&gt;
&lt;br /&gt;
默认将把CMake安装在C:\Program Files\CMake 2.4,，因此要确保&amp;lt;installpath&amp;gt;\bin在你的执行路径中。&lt;br /&gt;
&lt;br /&gt;
如果你想使用当前的开发版本，请遵循[http://cmake.org/HTML/Download.html#cvs here]的指令。&lt;br /&gt;
&lt;br /&gt;
==== Mac OSX ====&lt;br /&gt;
&lt;br /&gt;
=== 运行CMake ===&lt;br /&gt;
&lt;br /&gt;
==== Linux、BSD及其他Unix系统 ====&lt;br /&gt;
你必须运行CMake来为你的系统生成build文件。CMake支持in-source和out-of-source构建，不过目前KDE默认禁用in-source构建。&lt;br /&gt;
&lt;br /&gt;
假定你在~/src/kdelibs/中有kdelibs/，那么，输入：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ ls&lt;br /&gt;
kdelibs/&lt;br /&gt;
$ mkdir kdelibs-build&lt;br /&gt;
$ cd kdelibs-build&lt;br /&gt;
$ cmake ../kdelibs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这会在kdelibs-build/中生成构建kdelibs/的Makefiles。&lt;br /&gt;
&lt;br /&gt;
==== Windows ====&lt;br /&gt;
你必须运行CMake来为你的系统生成build文件。CMake支持in-source和out-of-source构建，不过目前KDE默认禁用in-source构建。&lt;br /&gt;
&lt;br /&gt;
假定你在c:\daten\kde4中有kdelibs\，那么，输入：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
c:\daten\kde4&amp;gt; cd kdelibs\win&lt;br /&gt;
c:\daten\kde4&amp;gt; cmake&lt;br /&gt;
c:\daten\kde4&amp;gt; make &lt;br /&gt;
c:\daten\kde4&amp;gt; make install&lt;br /&gt;
c:\daten\kde4&amp;gt; cd ..&lt;br /&gt;
c:\daten\kde4&amp;gt; mkdir kdelibs-build&lt;br /&gt;
c:\daten\kde4&amp;gt; cd kdelibs-build&lt;br /&gt;
c:\daten\kde4\kdelibs-build&amp;gt; cmake ..\kdelibs&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
这样就生成了在 kdelibs-build\中构建kdelibs\的Makefiles。要获得更多的关于在Windows下编译KDE的信息，请阅读[[KDE On Windows]]。&lt;br /&gt;
&lt;br /&gt;
==== Mac OSX ====&lt;br /&gt;
&lt;br /&gt;
==== KDevelop项目 ====&lt;br /&gt;
如果你更喜欢KDevelop的项目文件（基本上就是Makefiles及为KDevelop生成的一些文件），这样运行CMake：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ cmake ../kdelibs -GKDevelop3&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
使用“cmake -h”来查看CMake支持那些生成器 （generators）及其他的选项。&lt;br /&gt;
&lt;br /&gt;
==== CMake和Qt4 ====&lt;br /&gt;
为了定位Qt 4，CMake会在你的执行路径中搜索qmake。CMake''不''会使用QTDIR这个环境变量。因此请确保在执行路径中寻找到的第一个qmake就是你希望使用的。&lt;br /&gt;
&lt;br /&gt;
==== 更多细节 ====&lt;br /&gt;
当CMake执行完成，它会生成一个叫“CMakeCache.txt”的文件。这个文件包含了CMake在你的系统上检测到的所有设置。如果你希望在其他生成器（generators)上运行CMake,或你希望CMake重新检测系统，请删除这个文件。&lt;br /&gt;
&lt;br /&gt;
如果有些东西你知道它存在，而CMake没有检测到，你可以手动的告诉CMake到哪里去找它。CMake通过变量来存储这些信息。这些变量缓存在前面提到的 CMakeCache.txt中。这里有3个选项来手工调整这些变量：&lt;br /&gt;
* 通过命令行告诉CMake现在的值: cmake ../kdelibs -DNAME_OF_THE_VARIABLE=value&lt;br /&gt;
* 使用ccmake，它提供了一个基于鼠标的GUI来调整CMake变量（运行: ccmake ../kdelibs）&lt;br /&gt;
* 直接编辑CMakeCache.txt（不推荐）&lt;br /&gt;
&lt;br /&gt;
你应该最起码运行一次“ccmake ../kdelibs”，这样你会对CMake使用了那些变量有个印象。按“T”来查看“高级”的变量。如果有些东西CMake没有找到，运行ccmake并手工调整它。&lt;br /&gt;
&lt;br /&gt;
一些你可能希望设置的变量：&lt;br /&gt;
* '''CMAKE_INSTALL_PREFIX''': cmake ../kdelibs -DCMAKE_INSTALL_PREFIX=/opt/kde4 相当于./configure --prefix=/opt/kde4&lt;br /&gt;
* '''CMAKE_BUILD_TYPE''': 决定你如何构建系统。你可以在“debugfull”、“debug”、“profile”、“relwithdebinfo”和“release”中进行选择。默认的是“relwithdebinfo”(-O2 -g)。更多细节查看FindKDE4Internal.cmake。&lt;br /&gt;
* '''RPATH_STYLE''': 这个不再有效了。默认情况下，一切都将在RPATH设置正确的情况下来构建。如果你不希望使用RPATH，将CMAKE_SKIP_RPATH设置为TRUE。&lt;br /&gt;
* '''WITH_FOO''': 这里有一些选项，例如WITH_CUPS或WITH_Jasper。如果你将他们关闭，cmake甚至不会去尝试寻找这个包。如果将它激活，cmake将会尝试寻找这个包。如果这样做失败了，你还可以通过上面介绍的方法手工设置。&lt;br /&gt;
&lt;br /&gt;
=== 环境变量 ===&lt;br /&gt;
如果你在CMake没法找到的非标准位置安装了头文件或库（ 例如Mac OSX下把fink安装到/sw），那么就请设置下面这些环境变量。尽管有相似的命名规则，这些设置在cmake的命令中并不会做为参数来工作。&lt;br /&gt;
* '''CMAKE_INCLUDE_PATH'''，例如export CMAKE_INCLUDE_PATH=/sw/include&lt;br /&gt;
* '''CMAKE_LIBRARY_PATH'''，例如export CMAKE_LIBRARY_PATH=/sw/lib&lt;br /&gt;
&lt;br /&gt;
关于变量的更多信息，请参考&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_Useful_Variables cmake.org wiki page]。&lt;br /&gt;
&lt;br /&gt;
=== 更进一步 ===&lt;br /&gt;
如果cmake以“Generating done”结束，那表示没有错误，但如果以“Configuring done”结束，那表示有错误需要修正。当cmake成功结束，运行你的构建工具（如make、KDevelop、XCode或MSVC）来构建并等到它结束。然后运行“make install”。&lt;br /&gt;
&lt;br /&gt;
如果你得到如下错误提示：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
CMake Error: This project requires some variables to be set,&lt;br /&gt;
and cmake can not find them.&lt;br /&gt;
Please set the following variables:&lt;br /&gt;
X11_XTest_LIB (ADVANCED)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
那表示你可能缺少库（或其他依赖包）。在cmake/modules目录中查找cmake无法找到的变量来确定是缺少哪个库文件。在上面的例子中，就是：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
FIND_LIBRARY(X11_XTest_LIB Xtst ${X11_LIB_SEARCH_PATH})&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这里缺失的库是Xtst。然后你找到这个库（也许是通过安装libXtst-devel）并再次运行cmake。&lt;br /&gt;
&lt;br /&gt;
== 在简单的应用中使用CMake ==&lt;br /&gt;
这是最简单的CMakeLists.txt：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
add_executable(hello main.cpp)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
这将从main.cpp源码文件创建一个叫“hello”（Windows下叫“hello.exe”）的可执行文件。你可以根据自己的需要将C和C++文件混合。在同一个CMakeLists.txt可以有多个可执行文件和库。同一个源码文件可以用于不同的目的，源码可以从其他目标中为每个目的独立的编译。CMake语言最重要的部分可能是变量：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SET( MY_SOURCES main.cpp widget.cpp)&lt;br /&gt;
MESSAGE(STATUS &amp;quot;my sources: ${MY_SOURCES}&amp;quot;)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
使用SET()命令来为变量设置值。如果你列出了一个以上的字符串，变量将是串列表。列表是一列由分号隔开的字符串。如果只设置个一项，那么这项只有一个值。可以通过${VAR}获得变量的值。可以使用FOREACH()来迭代一份列表：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
FOREACH(next_ITEM ${MY_SOURCES})&lt;br /&gt;
   MESSAGE(STATUS &amp;quot;next item: ${next_ITEM}&amp;quot;)&lt;br /&gt;
ENDFOREACH(next_ITEM ${MY_SOURCES})&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
CMake中的命令是大小写无关的。变量名和参数名是大小写相关的。&lt;br /&gt;
&lt;br /&gt;
还可以测试一些不同的东西：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
IF (UNIX)&lt;br /&gt;
   MESSAGE(STATUS &amp;quot;This is UNIX (including OS X and CygWin)&amp;quot;)&lt;br /&gt;
ENDIF (UNIX)&lt;br /&gt;
&lt;br /&gt;
IF (MSVC)&lt;br /&gt;
   SET(MY_SRCS ${MY_SRCS} winextra.cpp)&lt;br /&gt;
ENDIF (MSVC)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
在第二个例子中，你可以看到如何将项目附加到列表中。&lt;br /&gt;
&lt;br /&gt;
在cmake Wiki中有一份使用cmake构建KDE4软件的[http://www.cmake.org/Wiki/HowToBuildKDE4Software 指导]，推荐阅读。&lt;br /&gt;
&lt;br /&gt;
== 在KDE项目中使用CMake ==&lt;br /&gt;
这里是一份基本的构建一个小KDE4项目的CMakeList文件：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
PROJECT( kde4project)&lt;br /&gt;
FIND_PACKAGE(KDE4 REQUIRED)&lt;br /&gt;
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} )&lt;br /&gt;
&lt;br /&gt;
SET(KDE4ProjectSources kde4mainapp.cpp someclass.cpp someotherclass.cpp)&lt;br /&gt;
&lt;br /&gt;
KDE4_AUTOMOC( ${KDE4ProjectSources} )&lt;br /&gt;
&lt;br /&gt;
KDE4_ADD_EXECUTABLE(kde4project ${KDE4ProjectSources} )&lt;br /&gt;
&lt;br /&gt;
TARGET_LINK_LIBRARIES(kde4project ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 扩展CMake ==&lt;br /&gt;
CMake可以通过cmake脚本扩展，CMake带有大量的脚本，在UNIX下，这些脚本默认安装在 /usr/local/share/CMake/Modules/内。KDE库也在/apps/cmake/modules/安装了一些CMake模块。这里的文件将被代替CMake的系统全局模块路径。FindFOO.cmake用来检测软件包，&lt;br /&gt;
[http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 这里]有更多信息。在CMake中也可以写宏文件，对于大多数的软件构建来说，他们足够强大了。这些宏不会做为通用语言来使用。&lt;br /&gt;
&lt;br /&gt;
你还可以在CMake中编写宏。他们非常强大，可以满足你编译的软件中所需要的所有事情，但是他们并不是被用作通用目的的编程语言。&lt;br /&gt;
&lt;br /&gt;
== 将基于autotools的KDE软件转换为CMake ==&lt;br /&gt;
你可以在kdesdk/cmake/找到am2cmake脚本。这是ruby写成的，所以确定你的系统安装了ruby。在你的源码目录最上层运行am2cmak：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
$ cd src/mykooltool/&lt;br /&gt;
$ am2cmake --kde4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
不要忘了开关“--kde4”，不然系统无法生成适合KDE4的文件。转换文件可能会正常工作，但编译的项目将需要一些额外的编辑。&lt;br /&gt;
&lt;br /&gt;
你可能需要：&lt;br /&gt;
* 使用INCLUDE_DIRECTORIES()添加更多include目录。&lt;br /&gt;
* 使用TARGET_LINK_LIBRARIES()添加更多链接库。&lt;br /&gt;
* 使用ADD_DEFINITIONS()添加更多编译开关。&lt;br /&gt;
* 添加一些“configure”检查，参照[http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks 如何进行平台检查]和[http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 如何找到已经安装的软件]。&lt;br /&gt;
* 特别要注意以往的libtool便捷库，CMake并不支持这些库，而是生成一个ConvenienceLibs.cmake文件代替。在这个文件里，你可以为每个便捷库找到一个包含了这个库所有源码的变量。对于链接到这些库的目标，只要在源码中添加这些变量即可。&lt;br /&gt;
* 一个AdditionalInfo.txt文件将被创建。你可以在这里找到项目所有的*.in和*.in.in文件。这些文件完成的任务将被手工转换到CMake.&lt;br /&gt;
&lt;br /&gt;
== 常见问题 ==&lt;br /&gt;
&lt;br /&gt;
=== 如何使我最喜欢的编辑器支持CMake的语法和缩进？ ===&lt;br /&gt;
请阅读CMake Wiki中[http://www.cmake.org/Wiki/CMake_Editors_Support CMake编辑器支持]这部分。这里介绍了如何设置Emac、VI、Kat、KWrite和KDevelop。&lt;br /&gt;
&lt;br /&gt;
=== 我需要在构建过程中产生一些文件，我该如何做？ ===&lt;br /&gt;
使用ADD_CUSTOM_COMMAND()。这里有解释：[http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F 在构建过程中如何生成一个源文件]。&lt;br /&gt;
&lt;br /&gt;
=== 我想在产生文件的构建过程中创建一个稍后使用的可执行文件，我要如何做？ ===&lt;br /&gt;
假定可执行文件叫genembed。那么使用KDE4_ADD_EXECUTABLE(foo RUN_UNINSTALLED ${fooSources})来生成可执行文件。RUN_UNINSTALLED选项非常重要，因为可执行文件必须从构建目录运行，并会链接到builddir中的一些库。为达到这个目的，可执行文件通过相应设置的RPATH和包装的外壳脚本编译，和可执行文件的命名一样只是多了“.sh”后缀。这个外壳脚本设置LD_LIBRARY_PATH并调用实际的可执行文件。象上面介绍的在ADD_CUSTOM_COMMAND()中使用这个包装的外壳脚本。可以通过查询WRAPPER_SCRIPT来获得名称和确切的路径。这里有一个来自kdelibs/kstyles/keramik/完整的例子：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
# build the executable&lt;br /&gt;
KDE4_ADD_EXECUTABLE(genembed RUN_UNINSTALLED ${genembed_SRCS})&lt;br /&gt;
&lt;br /&gt;
# get the name of the generated wrapper script (which sets up LD_LIBRARY_PATH)&lt;br /&gt;
GET_TARGET_PROPERTY(GENEMBED_EXECUTABLE genembed WRAPPER_SCRIPT)&lt;br /&gt;
&lt;br /&gt;
# and the custom command&lt;br /&gt;
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/keramikrc.h&lt;br /&gt;
  COMMAND ${GENEMBED_EXECUTABLE} --file ${CMAKE_CURRENT_BINARY_DIR}/keramikPics.txt &amp;gt; \&lt;br /&gt;
  ${CMAKE_CURRENT_BINARY_DIR}/pixmaps.keramik&lt;br /&gt;
  DEPENDS genembed ${keramikPics}&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
如你所见genembed也做为依赖关系列出。这表示CMake知道它应该在执行这些规则之前创建genembed的可执行文件。&lt;br /&gt;
&lt;br /&gt;
=== 我不想设置-DCMAKE_INSTALL_PREFIX命令行参数。CMake是否支持KDEDIR环境变量？ ===&lt;br /&gt;
不。KDE4反对使用$KDEDIR。&lt;br /&gt;
&lt;br /&gt;
=== 为什么我会得到类似/usr/lib/qt4/include/QtCore/qstring.h:536: undefined reference to `QString::fromLatin1_helper(char const*, int)'的编译错误？ ===&lt;br /&gt;
如果你的qt/lib目录下有个老版本的Qt4，你必须删除这些老版本（4.0.4）文件。&lt;br /&gt;
&lt;br /&gt;
=== 我如何让CMake创建noisy makefiles？我希望准确的看到make过程执行的命令。 ===&lt;br /&gt;
给make传递 VERBOSE 变量，例如：&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
% make VERBOSE=1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
或者&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
% VERBOSE=1 make&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
更多细节请查看CMake wiki： [http://www.cmake.org/Wiki/CMake_FAQ#Is_there_an_option_to_produce_more_.27verbose.27_compiling.3F&lt;br /&gt;
有没有选项可以产生更多的“verbose”编译？]&lt;br /&gt;
&lt;br /&gt;
=== 产生的Makefiles中没有“make distclean”标签。我如何才能清理包括cache文件在内的所有文件？ ===&lt;br /&gt;
只需删除构建目录，或目录里包含的内容。&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming]]&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
[[Category:FAQs]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Development/Tutorials/CMake_(zh_CN)</id>
		<title>Development/Tutorials/CMake (zh CN)</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Development/Tutorials/CMake_(zh_CN)"/>
				<updated>2007-04-01T13:42:15Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: first part for chinese cmake&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:/CMake}}&lt;br /&gt;
&lt;br /&gt;
== 简介 ==&lt;br /&gt;
&lt;br /&gt;
CMake并不是KDE项目的一个子项目，CMake是由[http://www.kitware.com Kitware Inc.]开发的并按类BSD的协议发布的一个自己软件，它作用是为其原生构建系统读出脚本并生成输入文件。&lt;br /&gt;
&lt;br /&gt;
CMake可以生成GNU Makefiles、KDevelop的项目文件、XCode项目文件以及Visual Studio项目文件等多种文件格式，并且不再使用 libtool，大大加快了编译速度，另外它的build文件更易于读写，故2006年3月，KDE正式决定采用CMake代替automake做为KDE4的构建工具。&lt;br /&gt;
&lt;br /&gt;
这些地方学习CMake挺不错的：&lt;br /&gt;
* [http://www.cmake.org/HTML/Documentation.html CMake手册]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake CMake Wiki]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToDoPlatformChecks CMake系统检查]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware 查找可替换的软件包]&lt;br /&gt;
* [http://www.cmake.org/Wiki/HowToBuildKDE4Software CMake Wiki上的KDE4指导]&lt;br /&gt;
* [http://www.cmake.org/Wiki/CMake_FAQ CMake FAQ]&lt;br /&gt;
* [http://mail.kde.org/pipermail/kde-buildsystem/ kde-buildsystem的邮件列表存档]&lt;br /&gt;
&lt;br /&gt;
另外，还可以考虑加入[http://www.cmake.org/mailman/listinfo/cmake CMake邮件列表]。&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	<entry>
		<id>http://techbase.kde.org/Development/Tutorials</id>
		<title>Development/Tutorials</title>
		<link rel="alternate" type="text/html" href="http://techbase.kde.org/Development/Tutorials"/>
				<updated>2007-04-01T13:31:06Z</updated>
		
		<summary type="html">&lt;p&gt;Liangqi: add link for simplified chinese of cmake&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Tutorials are the fastest way of finding out what KDE will do for you, and how to do it. Here is a list of currently available tutorials '''for KDE4'''. Material for KDE3 and KDE2 is available on the bottom of this page.&lt;br /&gt;
&lt;br /&gt;
== Getting started ==&lt;br /&gt;
;[[/Programming Tutorial KDE 4|Introduction To KDE 4 Programming]]&lt;br /&gt;
:''Are you interested in writing applications with KDE 4? This tutorial series is aimed at those completely new to KDE programming.''&lt;br /&gt;
&lt;br /&gt;
;[[/KDE4 Porting Guide|Porting Your Application]]&lt;br /&gt;
:''Help Porting Applications from Qt3/KDE3 to Qt4/KDE4''&lt;br /&gt;
&lt;br /&gt;
;[[/CMake|Introduction to CMake]][[/CMake_(zh_CN)| (Simplified Chinese version)]]&lt;br /&gt;
:''How to use the CMake build system used by KDE4.''&lt;br /&gt;
&lt;br /&gt;
;[[/Using Qt Designer|Using Qt Designer to build user interfaces]]&lt;br /&gt;
:''How to create UI files with designer, and how to integrate them into a KDE program.''&lt;br /&gt;
&lt;br /&gt;
;[[/Command-Line Options|Using Command-line Options]]&lt;br /&gt;
:''Processing and accessing command-line arguments the easy way with KDE's command line arguments classes.''&lt;br /&gt;
&lt;br /&gt;
== Testing And Debugging ==&lt;br /&gt;
&lt;br /&gt;
;[[/Debugging|Debugging your application]]&lt;br /&gt;
:''Tips, tools and techniques to apply when debugging your KDE application''&lt;br /&gt;
&lt;br /&gt;
;[[Development/Tutorials/Unittests|Writing Unittests for Qt4 and KDE4 with QTestLib]] ([http://developer.kde.org/documentation/tutorials/writingunittests/writingunittests.html Original link])&lt;br /&gt;
:''Tutorial by [mailto:bradh@frogmouth.net Brad Hards] that describes how to write unit tests using the QTestLib framework. It is presented as an example based tutorial, and is still under development.''&lt;br /&gt;
&lt;br /&gt;
;[[/Code_Checking|Semi-automatic ways to detect code errors]]&lt;br /&gt;
:''Techniques you can use to detect errors in KDE code''&lt;br /&gt;
&lt;br /&gt;
== Managing Configuration Data With KConfig ==&lt;br /&gt;
;[[/KConfig|Introduction To KConfig]]&lt;br /&gt;
:''An overview of the KConfig classes and how to use them in your application code''&lt;br /&gt;
&lt;br /&gt;
;[[/Using KConfig XT|Using KConfig XT]]&lt;br /&gt;
:''Tutorial on how to efficiently use the KConfig XT framework.''&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
;[[/Localization/Unicode|Introduction To Unicode]]&lt;br /&gt;
:''An introduction to what Unicode is as well as how to handle Unicode data in KDE applications.''&lt;br /&gt;
&lt;br /&gt;
; [[/Localization/i18n|Writing Applications With Localization In Mind]]&lt;br /&gt;
:''This tutorial covers what localization is, why it's important and how to ensure your application is ready to be localized. A must read for all application developers.''&lt;br /&gt;
&lt;br /&gt;
; [[/Localization/i18n Mistakes|Avoiding Common Localization Pitfalls]]&lt;br /&gt;
:''There are several common mistakes that prevent applications from being properly localized. Find out what they are and how to easily avoid them in this tutorial.''&lt;br /&gt;
&lt;br /&gt;
; [[/Localization/Building KDE's l10n Module|Building KDE's Localization Module]]&lt;br /&gt;
:''Building and installing language support from KDE's localization (l10n) module is a good idea for those working on applications in the main KDE repository. Doing so will allow you to test your application in another language and spot problem areas. Learn how to do just that in this tutorial.''&lt;br /&gt;
&lt;br /&gt;
; [[/Localization/i18n Build Systems|Incorporating i18n Into the Build System]]&lt;br /&gt;
:''Once your application is ready to be localized, the next step is to ensure that translation files are built automatically and kept up to date. This tutorial covers the necessary CMakeFiles.txt additions as well the process of distributing the resulting message catalogs with your application.''&lt;br /&gt;
&lt;br /&gt;
; [[/Localization/i18n Challenges|Common i18n Challenges and Solutions]]&lt;br /&gt;
:''This tutorial covers challenges that you may eventually run into such as translating handbooks and other data that exists outside of the source code, merging and handling obsolete .po files, deeling with freezes, coding in languages other than English and creating independent releases of or moving applications between KDE modules.''&lt;br /&gt;
&lt;br /&gt;
== Documentation ==&lt;br /&gt;
&lt;br /&gt;
;[[Development/Tutorials/API_Documentation|API Documentation]]&lt;br /&gt;
:''This tutorial explains how to document your APIs properly.''&lt;br /&gt;
&lt;br /&gt;
== Application Automation and Scripting ==&lt;br /&gt;
&lt;br /&gt;
=== D-Bus ===&lt;br /&gt;
; [[/D-Bus/Introduction|Introduction to D-Bus]]&lt;br /&gt;
:''A straight-forward introduction to the core concepts in D-Bus from an application developer's perspective, this tutorial covers what D-Bus is and how it can be used by applications.''&lt;br /&gt;
; [[/D-Bus/Accessing Interfaces|Accessing D-Bus Interfaces]]&lt;br /&gt;
:''A step-by-step guide to calling D-Bus methods and connecting to D-Bus signals using QtDBus.''&lt;br /&gt;
; [[/D-Bus/Intermediate_D-Bus|Intermediate D-Bus]]&lt;br /&gt;
:''Tips to make use of QtDBus when faced with problematic real-world interfaces.''&lt;br /&gt;
; [[/D-Bus/Creating Interfaces|Creating D-Bus Interfaces]]&lt;br /&gt;
:''Learn how to expose functionality in your application by creating and using custom D-Bus interfaces. Covers generating the XML descriptions, instantiating interfaces at run time and setting up the build system with CMake.''&lt;br /&gt;
; [[/D-Bus/Autostart Services|D-Bus Autostart Services]]&lt;br /&gt;
:''Turn your application into a D-Bus autostart service with this tutorial. This D-Bus feature, also known as &amp;quot;D-Bus service activation&amp;quot;, will ensure that even when your application isn't running that D-Bus calls made to it will work by relying on the D-Bus daemon itself to start your app if and when needed.''&lt;br /&gt;
; [[/Porting_to_D-Bus|Porting from DCOP to D-Bus]]&lt;br /&gt;
: ''Port your applications from DCOP to D-Bus with this handy guide.''&lt;br /&gt;
&lt;br /&gt;
=== Konqueror ===&lt;br /&gt;
; [[/Creating Konqueror Service Menus|Creating Konqueror Service Menus]]&lt;br /&gt;
:''This tutorial shows you how to create mimetype-specific actions in Konqueror's context menu (aka &amp;quot;servicemenus&amp;quot;).''&lt;br /&gt;
&lt;br /&gt;
===Kross===&lt;br /&gt;
; [[Development/Tutorials/Kross-Tutorial|Kross Tutorial]]&lt;br /&gt;
:''This tutorial explains how to integrate the Kross scripting framework into an application.''&lt;br /&gt;
&lt;br /&gt;
=== KOffice ===&lt;br /&gt;
; [[Development/Tutorials/Write a Flake Plugin|Creating KOffice Flake Plugins]]&lt;br /&gt;
:''This tutorial shows you how you can build a plugin for KOffice applications to allow you embed content in ODF documents using Flake.''&lt;br /&gt;
&lt;br /&gt;
; [[Development/Tutorials/KWord Scripting|KWord Scripting]]&lt;br /&gt;
:''This tutorial shows how to script KWord with Python, Ruby or JavaScript using Kross.''&lt;br /&gt;
&lt;br /&gt;
; [[Development/Tutorials/KSpread Scripting|KSpread Scripting]]&lt;br /&gt;
:''This tutorial shows how to script KSpread with Python, Ruby or JavaScript using Kross.''&lt;br /&gt;
&lt;br /&gt;
; [[Development/Tutorials/Krita Scripting|Krita Scripting]]&lt;br /&gt;
:''This tutorial shows how to script Krita with Python, Ruby or JavaScript using Kross.''&lt;br /&gt;
&lt;br /&gt;
== Search and Metadata ==&lt;br /&gt;
&lt;br /&gt;
; [[/Writing file analyzers|Writing file analyzers]]&lt;br /&gt;
:''File analyzers extract data from files to display in the file dialogs and file managers. The data gathered this way is also used to search for files. KDE4 allows the use of multiple analyzers per file type. This tutorial describes how you can write new analyzers.''&lt;br /&gt;
&lt;br /&gt;
== Hardware Awareness (Solid) ==&lt;br /&gt;
&lt;br /&gt;
;[[/Solid_Tutorials|Introduction to Solid]]&lt;br /&gt;
:''An introduction to using the Solid hardware discovery and interaction system in KDE applications.''&lt;br /&gt;
&lt;br /&gt;
;[[/Solid_Network_Tutorial|Accessing Network Information]]&lt;br /&gt;
:''How to use the Solid system to get information about the network''&lt;br /&gt;
&lt;br /&gt;
== Multimedia (Phonon) ==&lt;br /&gt;
&lt;br /&gt;
;[[/Phonon/Introduction|Phonon]]&lt;br /&gt;
:''How to start with the multimedia API''&lt;br /&gt;
&lt;br /&gt;
==Printing==&lt;br /&gt;
&lt;br /&gt;
;[[/Printing Hello World|Hello World]]&lt;br /&gt;
:''Introduction to the KDE printing system''&lt;br /&gt;
&lt;br /&gt;
;TODO Print Dialog&lt;br /&gt;
:''Using the KDE print dialog''&lt;br /&gt;
&lt;br /&gt;
== Get Hot New Stuff ==&lt;br /&gt;
; [[Development/Tutorials/Introduction to Get Hot New Stuff|Introduction to Get Hot New Stuff]]&lt;br /&gt;
:''An introduction to the developer-friendly network update system that allows KDE applications to fetch new application data at runtime in a user friendly manner.''&lt;br /&gt;
&lt;br /&gt;
;[[Development/Tutorials/KNewStuffSecure|KNewStuff Secure]] ([http://developer.kde.org/documentation/tutorials/knewstuffsecure/index.html Original Link])&lt;br /&gt;
:''Tutorial showing how to share resources in a secured way (KDE 3.4 and later).''  By Andr&amp;amp;#225;s Mantia &amp;amp;lt;amantia@kde.org&amp;amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Rapid Application Development ==&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&lt;br /&gt;
;[[Development/Tutorials/Python introduction to signals and slots|101 Introduction to signals and slots]]&lt;br /&gt;
:''A simple introduction to Qt's signal and slot architecture.''&lt;br /&gt;
&lt;br /&gt;
=== Ruby ===&lt;br /&gt;
&lt;br /&gt;
;[http://developer.kde.org/language-bindings/ruby/kde3tutorial/index.html KDE Ruby Korundum tutorial]&lt;br /&gt;
:''A ruby version of Antonio Larrosa Jim&amp;amp;eacute;nez's KDE tutorial by Richard Dale. See the [http://developer.kde.org/language-bindings/ruby/index.html Ruby Developers Corner] for Qt tutorials and other info.''&lt;br /&gt;
&lt;br /&gt;
;[[Development/Tutorials/Qt4_Ruby_Tutorial|Qt4 Ruby Tutorial]]&lt;br /&gt;
:''Trolltech's fabulous introductory tutorial to Qt, translated to Ruby.''&lt;br /&gt;
&lt;br /&gt;
=== Shell ===&lt;br /&gt;
&lt;br /&gt;
;[[Development/Tutorials/Shell_Scripting_with_KDE_Dialogs|Shell Scripting with KDE dialogs]] ([http://developer.kde.org/documentation/tutorials/kdialog/t1.html Original Link]) [[Development/Tutorials/Shell_Scripting_with_KDE_Dialogs_(de)| (German version)]]&lt;br /&gt;
:''Tutorial by [mailto:bradh@frogmouth.net Brad Hards] that describes how to use KDE dialogs in shell scripts with kdialog. It is presented as an example based tutorial.''&lt;br /&gt;
&lt;br /&gt;
== Other tutorials ==&lt;br /&gt;
&lt;br /&gt;
=== KPlotWidget ===&lt;br /&gt;
;[http://developer.kde.org/documentation/tutorials/kdeeduplot/kdeeduplot_tutorial.tar.bz2 Using and extending the KDE EDU Plot widget (docbook archive)]&lt;br /&gt;
:''This tutorial introduces Jason Harris' KPlotWidget that is part of the KDE-Edu package. Contains information about defining your own widget in Qt / KDevelop designer and about subclassing widgets and overriding member functions to extend functionality.''&lt;br /&gt;
&lt;br /&gt;
=== Sonnet ===&lt;br /&gt;
;[[/Sonnet/SonnetTutorial|Adding spell-checking or grammar-checking to KDE applications]]&lt;br /&gt;
:''This tutorial introduces Sonnet and how one may use it to add language correction to your KDE application. Sonnet's auxiliary features shall be described in a separate tutorial.''&lt;br /&gt;
&lt;br /&gt;
== KDE2 and KDE3 Materials ==&lt;br /&gt;
&lt;br /&gt;
;[[Development/Tutorials/KDE3|KDE3 Tutorials]]&lt;br /&gt;
:''These tutorials cover topics related to KDE3.''&lt;br /&gt;
&lt;br /&gt;
;[[Development/Tutorials/KDE2|KDE2 Tutorials]]&lt;br /&gt;
:''These tutorials cover topics related to KDE2.''&lt;br /&gt;
&lt;br /&gt;
[[Category:KDE4]]&lt;/div&gt;</summary>
		<author><name>Liangqi</name></author>	</entry>

	</feed>