A primer for new C++ developer volunteers on Win XP

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
Paolo
Posts: 502
Joined: 23.09.2002
With us: 22 years 1 month
Location: Pordenone/Italy

A primer for new C++ developer volunteers on Win XP

Post #1by Paolo » 26.10.2003, 12:31

The purpose of this thread is to give a primer to developer volunteers, to be able to compile from scratch a debug version of Celestia code from CVS. The environment is Windows XP and the compiler Visual C++ (perhaps .NET too).
So hopefully new developers should join the crew and implement new features or submit patches and bug corrections to Celestia.

The primer is subdivided in three phases.
1 Get the last code from CVS.
2 Compile from command line.
3 Compile from VC++ IDE a debug version of Celestia.

If you find errors or you encounter problems following the instructions of the three phases, post together your comments. I will edit and update the instructions.

Bye - Paolo

P.S. My English is poor so be patient with mistakes.
Last edited by Paolo on 12.03.2005, 22:29, edited 2 times in total.
Remember: Time always flows, it is the most precious thing that we have.
My Celestia - Celui

Topic author
Paolo
Posts: 502
Joined: 23.09.2002
With us: 22 years 1 month
Location: Pordenone/Italy

Phase 1

Post #2by Paolo » 26.10.2003, 12:32

Phase 1: Get the code

1.1 - WinCVS
First of all it is necessary a CVS client program.

Go to the WinCVS website.

http://www.wincvs.org/

Open the download page

I've downloaded the version 1.3.10 beta 10
Actually is available the 1.3.13 beta 2
Download the x86 version.

Install WinCVS following the instructions.

1.2 - Phyton
WinCVS is programmable, it has an internal macro system used for task automation.
These macros are written in Phyton language.
So after installation WinVCs asks to you to install Phyton.
It is necessary a Phyton interpreter.

To download Phyton go to the official Website.

http://www.python.org/

I've downloaded the version 2.2.2
Actually is available the 2.3.2
Download the Windows installer

Install Phyton following the instructions.

1.3 Configure WinCVS
Now it is necessary to configure WinCVS.

Using a CVS program is not something that should be called easy.
WinCVS is extremely powerful, it has a very large number of functions to help distributed development teams.
To use a CVS program it is necessary to know some basic concepts.
The main commands are:

Code: Select all

- Checkout
- Update
- Diff
- Log
- Graph
- Log
- Annotate
- Status
- Commit
- Branch
- Tag
Etc.


You can learn more about these commands reading the WinCVS help or other web resources.

For our purposes actually we will need only to know how to "Checkout" and "Update".
These commands are used to download in our local CVS tree the files present in the Celestia CVS tree on Sourceforce.

Create a new folder on your Hard Disk.
I suggest to use a folder in the root.
As example my folder is: C:\CVS.
This folder will be the base for our local CVS tree.

1.4 Access to SourceForge
It is necessary to input the account settings to access Surceforge CVS Tree.
Open WinCVS
Activate the preferences dialog: Menu\Admin\Preferences...
In the general tab input:

Code: Select all

Authentication: pserver
Path: /cvsroot/celestia
Host address: cvs.celestia.sourceforge.net
User name: anonymous
CVS root: anonymous@cvs.celestia.sourceforge.net:/cvsroot/celestia


In the WinCvs tab set the HOME path : "C:\CVS".

Now you can try to connect to the Sourceforge repository.

Activate the login dialog: Menu\Admin\Login...

Set the "Force Using -d" checkbox.

Press Ok

WinCVS requests to you the password.
The anonymous account dos not requires a password.
So press ok without typing any password.

In the console panel the following message should appear:

Code: Select all

***** CVS exited normally with code 0 *****



If the code is different than 0 something goes wrong.
Sometimes the Sourceforge servers are overloaded so the request goes in timeout. The returned code is 1.
My experience is that some days you can try many times and you won't be able to connect.
Sometimes after five-six tentative you can connect.
Sometimes the connection expires during the work.
It is normal. Retry another day perhaps you will be more lucky.


1.5 Checkout
The fist time that you connect you must perform a Checkout.
The checkout copies the entire CVS tree on your local repository.

Activate the command line dialog: Menu\Admin\Command Line...

Type:

Code: Select all

CVS checkout celestia

And then press “Ok”

Be careful about upper and lower case.

About 21 MB of files will be downloaded on your HD.
The downloaded file names are listed on the console.
If you have a fast connection within a few minutes all the work is done.
If you have a modem connection 64kb like me probably you will need about 2 hours or more.
When the *.dat and the *.jpg/png files are downloaded (the largest ones) seems that the systems is frozen.
Be patient. star.dat on my PC requires about 20 minutes. During this time nothing happens on the screen except that the small fishes in the lower right corner continues to wave.

Probably it possible to speed up the checkout operation copying in the c:\CVS folder the code that probably you have already downloaded. I’ve not tested this option so I do not encourage it.

If all goes well in the top left panel will appear the tree of the Celestia CVS folders.
You will have all the latest Celestia files: the textures, the objects, the data, the scripts, and all the source code for all the platforms: Windows, Unix and MacOS.
The only things that are not present are the executable files: our final target.

1.6 Update
The next time that you will want to update the files, that the development team changes almost every day, it won't be necessary to checkout, you will update only the changed files.

To update there are two systems.
To update the whole tree activate the command line dialog: Menu\Admin\Command Line...
Type:

Code: Select all

CVS update


And then press “Ok”.

To update a single folder select it in the top left panel with the tree of the Celestia CVS folders and then press the toolbar button with the green arrow that points to the bottom direction.
Then press ok on the dialog that will appear.
If you select the root folder you will obtain the same effect of the command line system.

End of phase 1 Get the code

Submit your corrections additions and suggestions referring to the chapter numbers.
Last edited by Paolo on 17.11.2003, 21:06, edited 2 times in total.
Remember: Time always flows, it is the most precious thing that we have.

My Celestia - Celui

Topic author
Paolo
Posts: 502
Joined: 23.09.2002
With us: 22 years 1 month
Location: Pordenone/Italy

Phase 2

Post #3by Paolo » 26.10.2003, 12:33

Phase 2 Compile form command line

2.1 The working copy

To do your experimentations on the code surely you won't want to corrupt your precious CVS tree.

So you will need one or more working copies of the CVS tree.
You can copy the entire tree in your favorite folder. My favorite one is c:\MyCelestia.
From this point I will refer to your working folder calling it c:\MyCelestia.

2.2 Sync tool
To update this folder I'm using a nice program that is called Windows Commander.
Do you remember mythical Norton Commander for DOS? The same but for windows.
This program is very useful because has a feature that allows to compare the content of two folders and can recourse in subfolders.
I have an old version. Actually is shareware and called Total commander. The website where you can find it is:

http://www.ghisler.com/

Using this program is not obligatory. You can use another program with the same feature or you can do the work by hand using the explorer and sorting the files id descending order by date.
But why I suggest to use this program? Because you will be able update your working copy of the Celestia CVS tree with a pair of mouse clicks. Tremendously handy.

2.3 Additional libraries

You will need to download some libraries used for the jpg and png image format and lua scripting management.

Fortunately these file are packed in a brand new zip that Chris has already prepared for us.
You can find this file at:
http://ennui.celestiaproject.net/celestia/files/

The file is called:

Code: Select all

winlibs-new.zip 944 kb


Unpack the file in a temp folder.

The Zip contains 2 folders:

Code: Select all

 inc
 lib


Move these folders in:

Code: Select all

c:\MyCelestia


2.4 Compile from command line

Ok If everything went well and you have the Visual C++ already installed and configured on your system, now you are able to compile from command line.

Edit the file named:

Code: Select all

c:\MyCelestia\makerelease.bat

Redirect the output of the command line compiler to a text file.
I've called this file compile.txt
The makerelease.bat must contain:

Code: Select all

cd src
nmake /f winbuild.mak CFG=Release %1 > ../compile.txt
cd ..
copy src\celestia\Release\celestia.exe .

Hopefully everything will run correctly and you will get the celestia.exe file.
If something will go wrong you will find the errors in the compile.txt file.

2.5 Run your Celestia.exe

Last but not least to be able to run the program it is necessary to copy in the same folder of the exe file the three dll that contain external calls:

Code: Select all

Libpng1.dll
Libpng1d.dll
Zlib.dll


You can find these dll in the official Celestia executable distribution.

Ok It's all for now.
In the phase 3 We will see how to configure the Visual C++ to compile from the IDE the debug version of Celestia.

Submit your corrections additions and suggestions referring to the paragraph numbers.[/b]
Last edited by Paolo on 26.10.2003, 12:44, edited 1 time in total.
Remember: Time always flows, it is the most precious thing that we have.

My Celestia - Celui

Topic author
Paolo
Posts: 502
Joined: 23.09.2002
With us: 22 years 1 month
Location: Pordenone/Italy

Phase 3

Post #4by Paolo » 26.10.2003, 12:33

Phase 3 Configuring the IDE

3.1 Project file
In the CVS tree there are the dsw and dsp files used by the IDE (Integrated Development Environment) of Visual C++.

Since Celestia is a complex program, has many source files.
Those files are organized in folders. These folders are located in the src folder of our working copy of our local CVS repository.
Each sub folder in the src folder is prepared to be a collector of a library.
Libraries are used by C/C++ compliers to store metacode. The metacode is used by the linker to build the final executable.
Organizing the source code file in libraries is useful because when some file are updated the compiler rebuilds only the libraries that contain the changed files. This speed up very much the operations.

The Dsp file are used to build libraries. The dsw file collects the dsp file and is used to build the executable.

In the dsw file one dsp is marked as "active project" and contains the file with the "main" procedure.

In each subfolder there is a dsp file and a mak file. The mak file is in plain text format and is equivalent of the dsp file but is used by the command line compiler (see description of makerelease.bat in phase 2).

Why all this long introduction?

Because Chris uses mak file. So these are always up to date and instead dsp are not.

So sometimes to be able to build from the IDE it is necessary to add in the dsp the missing file that are present in the mak file.

3.2 Using the IDE

To start the IDE simply double click on the file celestia.dsw in the src folder.

Visual C++ Shows on the top left panel the tree of the libraries(dsp) that are used in the project.

One of them is in bold format and is the active project.

At the bottom of this panel there are three tabs. The “Class view” tab is the default one. Since you won’t compile successfully at least one time the leafs of the tree in this tab does not contain noting because the bsc file is not available. The bsc file is used by the IDE to create all the reference mechanisms that are used to browse the code.

The second tab contains the resources tree. The leafs of this tree represent all the resources of the Windows executable (menus, dialogs, icons, bitmaps etc.).

The third tab contain the fileview tree. Is useful to open rapidly the various files and to add files to the dsp. So if you need to add file present in the mak but missing in the dsp you can right click on the dsp name, choose “Add files to folder” from the context menu.

3.3 Compiler configuration

It is possible to compile the executable in to ways. Release and Debug. The release version by default is highly optimized in order to obtain the fastest and most compact assembler. The debug version by default produces not optimized assembler that contains additional control instructions and labels that are useful for interactive debugging and profiling.

We are interested in debugging so first of all it is necessary to set this mode with the dialog reachable via:
Menu\Build\Set active configuration...
In the listbox select
Celestia – Win 32 Debug
And then press ok.

It is necessary to configure the compiler, so select the dialog
Menu\project\settings...

In this very complex dialog the user can set all the options that are available to configure the compiler/linker. Very experienced C/C++ programmers knows those options very well and like Chris prefer to work with the command line compiler.

Select the Debug tab and the general category. Set the working directory to:
C:\MyCelestia.

This have to be done because the executable is placed elsewhere (C:\mycelestia\src\celestia\Debug\Celestia.exe) and to run correctly the IDE must simulate that is located in the folder with all the necessary data (ssc, cfg, dat, jpg, 3ds etc).

Select the C/C++ tab. This is the most complex one.
Select the category “general”.
The warning level is set to 3 by default. Using this level it is not possible to compile. There is a problem with the STL library that until now I was not able to solve. So if you set a warning level different to 0 you will get an endless list of warnings.
A “#pragma disable(4786) compiler directive should solve the problem but since now I was not able to figure out how to use it.

After having set the warning level to 0 you can close the dialog.

This should be enough. Not very complex to do.

3.4 Build

Start the build with the command:
Menu\Build\Rebuild all

The building process is started. On the bottom the list of the precessed file scroll up.
Hopefully after a few minutes the executable will be prepared correctly.

To run it you can press “F5” key.
To trace the execution you can press “F10” and “F11” keys.

That is all. You can set the breakpoints to focus on some parts of the code, watch the variable content etc.

3.5 Remarks
Remember that if the dsp file content is not aligned with the corresponding mak file the final Celestia executable obtained with the IDE will be different from the one obtained with the command line compiler.
Another thing to remember is that the debug version of the executable performs worst that the release version. In some tasks is very much slower.

Thank you for the attention.

As usual submit your corrections additions and suggestions referring to the paragraph numbers.


Bye Paolo
Last edited by Paolo on 17.11.2003, 20:54, edited 1 time in total.
Remember: Time always flows, it is the most precious thing that we have.

My Celestia - Celui

don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 4 months
Location: Colorado, USA (7000 ft)

Post #5by don » 17.11.2003, 09:44

EXCELLENT step-by-step instructions Paolo!

Thank you very much! :D :D :D

-Don G.

don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 4 months
Location: Colorado, USA (7000 ft)

Post #6by don » 21.11.2003, 20:38

Question:

In Windows (I use XP), how does one apply a Linux generated .patch file to the local CVS repository?

Thank you!

-Don G.

GalenTX
Posts: 2
Joined: 30.01.2004
With us: 20 years 9 months

patch files on Windows

Post #7by GalenTX » 21.02.2004, 03:53

In Windows (I use XP), how does one apply a Linux generated .patch file to the local CVS repository?

The gnuwin32 project has compiled native Windows executables for many GNU/Unix/linux programs. Patch is one of them: http://gnuwin32.sourceforge.net/packages/patch.htm. You just need the binary setup file.

After installation, make sure the installation directory is on your path so you can easily run patch from a command prompt.

-Galen

don
Posts: 1709
Joined: 12.07.2003
With us: 21 years 4 months
Location: Colorado, USA (7000 ft)

Post #8by don » 21.02.2004, 20:11

Thank you for the link to the gnuwin32 project GalenTX!

gottliebpet
Posts: 2
Joined: 07.04.2004
With us: 20 years 7 months
Location: Los Angeles

compiling on xp

Post #9by gottliebpet » 07.04.2004, 19:49

I posted this message yesterday on the main board, and have received no replies, so I thought it might get your attention quicker if I posted as a reply on this sub-board.
I have tried both the IDE and the command line. The IDE compiles everything and links, up to a last message that it can't open d:\lib.obj. No such file appears to have been generated by the process. This happens whether I do the compile incrementally, from the 5 sub-directories and then finish with the celestia sub-directory, or if I do the compile all at once using the Celestia.dsw in the top level directory.

From the command line, using nmake winbuild.mak it accepts the libs that have been built from the IDE, but when trying to link Celestia it gives a warning message "defaultlib LIBC conflictrs with other libs; use /NODEFAULTLIB:library. Unfortunately, I can find no way to successfully use this directive in the makefile. Furthermore, if I repeat the nmake it tells me that celestial.exe is up to date, but no such executable has been built on the d: drive. I have a Celestia executable on my C: drive that I had previously downloaded as such, and that does not change.

I am not yet using CVS, so things should be simple.

kaycea
Posts: 11
Joined: 13.07.2004
With us: 20 years 4 months

cannot download source files

Post #10by kaycea » 13.07.2004, 18:22

I have followed the directions in Paolo's posts but after two weeks, still get the same exit message:

Code: Select all

cvs -d :pserver:anonymous@cvs.sourceforge.net:/cvsroot/celestia login
Logging in to :pserver:anonymous@cvs.sourceforge.net:2401:/cvsroot/celestia
cvs [login aborted]: connect to cvs.sourceforge.net:2401 failed: No connection could be made because the target machine actively refused it.

***** CVS exited normally with code 1 *****


My account settings have been modified, based on Recent Updates ( 2004-05-03 05:41:25 - Project CVS Service )
http://sourceforge.net/docman/display_doc.php?docid=2352&group_id=1

My account settings are as follows:

Code: Select all

Authentication: pserver
Path: /cvsroot/celestia
Host address: cvs.sourceforge.net
User name: anonymous
CVS root: anonymous@cvs.sourceforge.net:/cvsroot/celestia


Any suggestions on what should be changed or alternative ways to obtain source files from Win XP, please let me know.

Thanks!

Avatar
John Van Vliet
Posts: 2944
Joined: 28.08.2002
With us: 22 years 2 months

re

Post #11by John Van Vliet » 16.08.2004, 05:41

well it appares that some of cvs is still down , from a misshap in upgrading
there hardware


2004-08-12 12:42:49 - Project CVS Service ) On 2004-08-12 at about 10:00 Pacific the pserver based CVS server that hosts projects that have a first letter of c,d,g,a,w,x and u had a hardware malfunction that is currently being worked on..................................
2004-08-13 07:16:12 - Project CVS Service ) As of 2004-08-13 the CVS issue documented yesterday has not been fully resolved. As such, we had to disable pserver based CVS for those letters again ...............

Apollonian
Posts: 52
Joined: 19.10.2004
With us: 20 years 1 month

Post #12by Apollonian » 10.11.2004, 14:30

Does anyone have any rough idea of the inheritance hierarchy in the Celestia Source?

What are the primary 'core' classes and what are the most important utilities for new developers?

I am at once awed and confused at the quality and shear size of the number and content of the many Celestia class definitions. You guys did a really great job, but I'm afraid I'm having some trouble making sense of it without getting sidetracked on any number of fascinating new inheritance tangents.

georgiouk
Posts: 47
Joined: 02.05.2005
With us: 19 years 6 months
Location: Greece

cant find the Libpng1d.dll

Post #13by georgiouk » 30.05.2005, 22:01

I tried to compile the celestia code, but i cant find in the celestia distribution the Libpng1d.dll file.There are 2 files only Libpng1.dll and zlib.dll.The other file is missing.When i try to build the project with MS visual c++ i get 20 errors and a bunch of warnings.Where can i get Libpng1d.dll ?

Topic author
Paolo
Posts: 502
Joined: 23.09.2002
With us: 22 years 1 month
Location: Pordenone/Italy

Post #14by Paolo » 31.05.2005, 06:52

I forgot this issue. If you compile the debug version of Celestia you have to use debug versions of the dll.
Try renaming a copy of Libpng1.dll in Libpng1d.dll.
Remember: Time always flows, it is the most precious thing that we have.

My Celestia - Celui

georgiouk
Posts: 47
Joined: 02.05.2005
With us: 19 years 6 months
Location: Greece

Post #15by georgiouk » 07.06.2005, 07:00

Now i get all these errors that to tell you the truth i have no idea what to do next :(

cel_engine.lib(shadermanager.obj) : error LNK2001: unresolved external symbol "s
truct _iobuf * __cdecl std::_Fiopen(char const *,int,int)" (?_Fiopen@std@@YAPAU_
iobuf@@PBDHH@Z)
cel_engine.lib(fragmentprog.obj) : error LNK2001: unresolved external symbol "st
ruct _iobuf * __cdecl std::_Fiopen(char const *,int,int)" (?_Fiopen@std@@YAPAU_i
obuf@@PBDHH@Z)
celestiacore.obj : error LNK2019: unresolved external symbol "struct _iobuf * __
cdecl std::_Fiopen(char const *,int,int)" (?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z) r
eferenced in function "public: class std::basic_filebuf<char,struct std::char_tr
aits<char> > * __thiscall std::basic_filebuf<char,struct std::char_traits<char>
>::open(char const *,int,int)" (?open@?$basic_filebuf@DU?$char_traits@D@std@@@st
d@@QAEPAV12@PBDHH@Z)
configfile.obj : error LNK2001: unresolved external symbol "struct _iobuf * __cd
ecl std::_Fiopen(char const *,int,int)" (?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z)
winmain.obj : error LNK2001: unresolved external symbol "struct _iobuf * __cdecl
std::_Fiopen(char const *,int,int)" (?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z)
cel_txf.lib(texturefont.obj) : error LNK2001: unresolved external symbol "struct
_iobuf * __cdecl std::_Fiopen(char const *,int,int)" (?_Fiopen@std@@YAPAU_iobuf
@@PBDHH@Z)
.\Release\celestia.exe : fatal error LNK1120: 8 unresolved externals
NMAKE : fatal error U1077: 'link.exe' : return code '0x460'
Stop.
NMAKE : fatal error U1077: 'C:\Visual_C\bin\nmake.exe' : return code '0x2'
Stop.

Thanks for your time!

Topic author
Paolo
Posts: 502
Joined: 23.09.2002
With us: 22 years 1 month
Location: Pordenone/Italy

Post #16by Paolo » 07.06.2005, 07:24

Georgiouk

Which compiler version and OS are you using?
Can you give more info about your development environment.
Remember: Time always flows, it is the most precious thing that we have.

My Celestia - Celui

georgiouk
Posts: 47
Joined: 02.05.2005
With us: 19 years 6 months
Location: Greece

Post #17by georgiouk » 15.06.2005, 18:34

Hello.
I used TortoiseCVS and my O.S is
Window XP
Pentium(R) 4 CPU 1.6 GHz

Ireally this info covers you enough to find oyt what is going wrong.

Thanks for your time.

MB
Posts: 128
Joined: 19.07.2002
With us: 22 years 4 months
Location: Paris France

Post #18by MB » 16.06.2005, 07:57

Paolo,

For various reasons, I completely lost the access to the cvs tree, that I used during years to update the celestia code. I recently reactivate my interest for celestia and would again try to compile under Windows XP environement.
I used the write-up you kindly provided to us, and succeeds (I guess!) to install Wincvs. However, the new version WinCvs 2.0.0.2 (Build 2) seems to have some change about the way that the "cvs root" is introduced that made somewhat obsolete the orresponding part of your help message . I should confess that I did not really understand what they write about the way to introduce pathways , root, etc ...........In one word, I did not succed to download the celestia code through the "check out" command.
Here is what I get:

cvs -d "anonymous@cvs.celestia.sourceforge.net :/cvsroot/celestia " checkout
cvs checkout: warning: unrecognized response `'ssh' n'est pas reconnu en tant que commande interne
' from cvs server
cvs checkout: warning: unrecognized response `ou externe, un programme ex?€?cutable ou un fichier de commandes.
' from cvs server
cvs [checkout aborted]: end of file from server (consult above messages if any)

***** CVS exited normally with code 1 *****

I would appreciate any help about this matter.
Thanks
MB

maxim
Posts: 1036
Joined: 13.11.2003
With us: 21 years
Location: N?rnberg, Germany

Post #19by maxim » 16.06.2005, 15:45

I'd suggest using TortoiseCVS. It's much more intuitive.

maxim

Topic author
Paolo
Posts: 502
Joined: 23.09.2002
With us: 22 years 1 month
Location: Pordenone/Italy

Post #20by Paolo » 19.06.2005, 16:23

Hi MB.
its a long time that i don't use WinCVS. The latest version that I've installed is 1.3.17.
At present time I'm using Tortoise CVS too.
Remember: Time always flows, it is the most precious thing that we have.

My Celestia - Celui


Return to “Development”