Celestia/Development/Qt4

From Wikibooks, open books for an open world
Jump to: navigation, search

Introduction[edit]

Building Celestia with the Qt4 Graphical User Interface

The next major release of Celestia, which will be either v1.7 or 2.0, is planned to use Nokia's publicly available Qt4 cross-platform user interface. This GUI will replace the platform-specific GUIs used by Celestia v1.6.1 and older versions. Instead of having to maintain several different user interfaces, only one GUI will have to be updated as new features are added to Celestia.

Windows 7 x64[edit]

Command-line building[edit]

Using qmake on the command line to build Celestia-qt4 is much more efficient than using the GUI development process. If you use this procedure, you do not need to install the Qt SDK, which is much larger.

Preparing to build Celestia-qt4[edit]

  • Use your favorite SVN client to download Celestia's source code from SourceForge
  • Download and install Visual Studio Express 2008 for C++
  • Download and install the Qt libraries for Visual Studio 2008
    • http://qt.nokia.com/downloads
    • scroll down the page to find the entry titled "Qt libraries 4.8.0 for Windows (VS 2008, 273 MB)"
    • download and install only that one set of libraries.
  • Verify that your Windows PATH includes both the Visual Studio bin directory and the Qt bin directory
    • Open the menu Computer --> Properties --> Advanced System Settings --> Environment Variables
    • Modify or create the variable PATH
      • It should include at least
      • C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin;C:\Qt\4.8.0\bin

Building Celestia-qt4[edit]

  • Use your SVN client to update your master copy of Celestia's source code to the current version
  • Copy the entire Celestia svn directory tree to another location so you can build it from clean sources (Consider using a RAM disk to enhance performance.)
  • Open a Windows Command window
  • cd to the new directory Celestia\src -- it contains celestia.pro, which will be used by qmake.

Alternate method for opening the command window:

  • Browse to the new directory Celestia
  • Hold down the shift key and Right-Mouse-Button click on the icon for the src folder
  • In the popup menu, select "Open Command Window Here"

In either case,

  • Type the following commands
vcvars32
qmake
nmake release
  • 'vcvars32' configures the Visual Studio build environment
  • 'qmake' reads celestia.pro and generates an appropriate Makefile
  • 'nmake release' invokes the Visual Studio nmake program, which reads the Makefile and compiles and links the "release version" of Celestia-qt4
  • ( 'nmake debug' would create a version useful for debugging.)
  • Wait a few minutes. The build process will generate warning messages about unused variables and loss of precision, but eventually should terminate having successfully built Celestia-qt4.exe
  • A new version of Celestia-qt4.exe will have been created in your new Celestia directory. It should run with no error messages if you click on its icon.
  • Copy the new Celestia-qt4.exe to the directory where you normally run Celestia with addons.

Qt Creator[edit]

Qt Creator is a useful addition to the Qt libraries for Visual Studio 2008 that you must have installed before you install the Qt Creator. It allows to edit the code in a GUI and also to change the User Interface in an easy to use way. More deatils on it can be found on the Nokia Qt Website. http://qt.nokia.com/products/developer-tools

To install Qt Creator v2.4.1 or later you have to download the Qt binary that is corresponding to your OS from http://qt.nokia.com/downloads

Then you have to install it.

On Windows you then have on the first startup of the Program to open the menu entry "Extras" go to "Prefrences" and check under the entry "Qt4" if the correct path to the Qt environment has been taken from the "Path" environment.

If that is not the case, you have to do it manually by adding the path to the qmake binary (i.e. C:\Qt\4.8.0\bin\qmake).

That's it. Now you are ready to start building Celestia Qt.

Building Celestia[edit]

  • Initial build of Celestia using Qt Creator:
    • Start Qt Creator
      • Be patient: it takes quite a while before it opens its window. (90 seconds on a Dell Latitude E6510 laptop.)
    • Open the Celestia project
      • File menu --> Open file or project ...
      • Browse to your Celestia /src/ directory (e.g. C:\MyPrograms\celestia-svn\trunk\celestia\src )
      • Select (double click on) the file celestia.pro
      • Click on OK if the file-selection window didn't close
      • A green progress bar titled "Parsing" should appear in the left column of the IDE. Wait for it to finish.
    • Select if you want to build a Debug or a Release version
      • In the left-most column of the IDE, Select (Left-Mouse-Button click on) the topmost icon below the title "celestia". It looks like a blue terminal.
      • In the "slide out" menu click on the type of build. By default, it'll probably be
Qt from PATH Release
      • If you want to create a Debug version you have to change it to
Qt from PATH Debug
    • Build Celestia
      • Select the menu Build --> Build Project "celestia"
      • Wait patiently. You can select the option "Compile output" to watch the progress of the compilation and build process.
      • Run Celestia from the IDE: select the green triangle.


  • Subsequent rebuilds:
    • After downloading updated SVN code, or making your own changes to the source code, Rebuild Celestia. If you select "Build Project "celestia" it'll just recompile the modified files, which is much quicker.


  • Running Celestia standalone
    • When you run Celestia by clicking on the IDE's green triangle, it has no problems finding the necessary Qt libraries. However, if PATH has not been set, when you start Celestia by clicking on its own icon, Celestia doesn't know where to get the Qt libraries. One workaround is to copy into Celestia's main directory the Qt dll files from the appropriate Qt bin directory.

The libraries used by the Qt SDK are located in

C:\QtSDK\Desktop\Qt\#.#.#\msvc2008\bin

(where #.#.# corresponds to the version of Qt.)

MacOS[edit]

We are in NEED of a apple Dev to help out

Linux[edit]

Getting the sources[edit]

Most major distros have celestia in the repos ,HOWEVER it is almost all ways a very old version

in the "red hat" family it might be celestia1.5 in the el5 repo

so it tends to be a good idea to pull the current SVN code

-- warning --

the svn code might not build - it MIGHT/ DOSE have bugs and it is in a state of flux

with that said i have only had just a few times in the last 5 years that a particular svn/cvs pull did not build

As of May 22 2012 the trunk is 1.7+

1.7.0 has been branched off


svn co https://celestia.svn.sourceforge.net/svnroot/celestia/trunk/celestia

once you pull svn ,copy the celestia/celsetia source folder to a different location ( you DO NOT want to build it in the svn folder )

QT4, compiler and build tools[edit]

tools needed

Grab from your packager manager " QT creator " that should also pull any needed prerequisites


for reference I use red hat type systems , so the development packages in the repos are "-devel"

the development packages in Debian type Operating Systems are " -dev"

as of July 2012 most OS's have moved to Gnome3

Rhel5.8 and RHEL6.3 ( and the rebuilds ) are still using Gnome2


Celestia is phasing out Gnome support currently Gnome2 is still "supported" ( as in not removed from the source YET )

use your packagemanager to install the "KDE4 desktop development tools "

or if using Gnome3 the QT4 development packages for your distro

make sure that the Gcc autotools are installed ( normally part of the "Development Tools" package )

SEE: your OWN distros documentation !!!

-- WARNING--

as of June 2012 if you Gcc 4.7 you will need to do some hacking of celestia to get it to build on a testing version of gcc

Gcc 4.6 is the recommended version

Lua[edit]

You will need LUA. If you are installing LUA using your distribution package sources, you will probably need packages named something like liblua and liblua-devl or the deb liblua-dev .

PNG, JPEG[edit]

You will need PNG and JPEG libraries. If you are installing them using your distribution package sources, you will probably need packages named something like libpng, libpng-dev, libjpeg and libjpeg-dev.

a word on png Celestia is currently using libpng14.

some OS's like fedora 17/18 alpha have png15 ,some hacking on fedora might be required .

OpenGL, GLU[edit]

Similarly you will need OpenGL and GLU with headers.


these are normally installed if you have a Nvivia 3d card

Your distro's .rpm,or.deb in the repo will install this

and so will the MANUAL install using the Nvidia.run file

if you have an AMD/ATI card ? see your distros help forum pages on installing OpenGL

Or your Distros Documentation for the instructions

NAIF SPICE[edit]

If you want SPICE support, you will have to download the CSPICE toolkit for your platform from http://naif.jpl.nasa.gov/naif/toolkit_C.html. You only need the include and lib folders. The qmake project file expect them to be under /usr/local/cspice/include and /usr/local/cspice/lib/.

-- warning--

a lot of Distros DO NOT by default have /usr/local in the DEFAULT system path 

if you install spice to /usr/local you might need to add this location to $PATH


Do to changes the old 1980's unix / , /usr and (of course /usr/local) split are being merged back together like they were way back in the `70's


so installing SPICE to /usr/local might not be the best idea

I would recommend installing it to /opt/cspice (N0064 is the current)

( /opt is also where LibreOffice is installed)

Theora[edit]

Theora support (movie capture) is not in the SVN yet. But a patch is available at http://sourceforge.net/mailarchive/message.php?msg_id=26185215 Note that this patch was against an old SVN revision, so you will have to adapt. You will need theora library and headers. If you are installing them using your distribution package sources, you will probably need packages named something like libtheora and libtheora-dev.

celestia.pro[edit]

Goto the src folder in the celestia source tree. Review the celestia.pro qmake project file for the location of any libraries and include files in particular for:

  • cspice.
  • theora.
  • lua (location normally found by pkgconfig).

Edit the file if the location of a library or include file does not match your installation.

The default install prefix is /usr/local/ If you want to install somewhere else edit celestia.pro to change the prefix.

warning some distros like Fedora DO NOT have /usr/local in the system $PATH , so the computer might NOT be able to run celestia if you install it to /usr/local

If SPICE was not installed to "/usr/local " then edit the .pro file in kate or gedit . near the end is the spice location, edit it for YOUR install location

Build[edit]

To generate the Makefile, under the src folder run:

qmake 

Then to build, run:

make

The executable will be generated one level below in "src/.." You can test it by doing:

cd ..
./celestia

Note that the data directory is first the current directory where you launch the application, if the configuration is not found in that directory, then it the data directory is share/celestia under the install prefix (default /usr/local/share/celestia). If you run celestia in a directory where there is no configuration data (such as src) and before you install the configuration data in share/celestia under the install prefix, you will get a dialog box with an error message and then a segmentation fault.

Build in Terminal[edit]

The Celestia.pro is nice

BUT

I like the terminal

in the BUILD folder ( the copy OF the SVN folder)

You need to make a "configure file ( std with SVN and CVS )

For that you will need the gcc Autotools installed

In the build folder run this code:

autoreconf -v -i

Now it is most likely best to use your systems default "bin" folder /usr/bin it install into

now in the terminal you have GREAT power on settings and changing them on the fly as needed

For reference:

cspice is installed to /opt/cspice

the install location is to be /usr

lua,thera are installed to /usr

run:

./configure --prefix=/usr --with-lua --with-qt --with-cspice-dir=/opt/cspice 
 
make
 
/* see options for make ,for multicore CPU's  try"-j3 " */
--- or run this ---
make -j3 
 
su  
 
/* type in your root password */ 
 
make install

Install[edit]

Run

make install

to install the software. Depending on the install location, you might need to run this command as root (e.g. with sudo).