Difference between revisions of "Setting Up A Development Environment"

From LinuxMCE
Jump to: navigation, search
m
 
(2 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
   | __TOC__
 
   | __TOC__
 
   |}
 
   |}
[[Category: Tutorials]]
+
[[Category:Development Environment]]
[[Category: Development]]
+
[[Category:Programmer's Guide]]
[[Category: Programmer's Guide]]
+
  
== Introduction ==
+
Please use the 810 development setup guide [http://wiki.linuxmce.org/index.php/Building_LinuxMCE_0810 here]
 
+
'''/!\ WARNING: at the moment the sources are moving, so there are some  bugs related to sources versions. you may not be able to compile'''
+
 
+
See also: [[Building From Source]]
+
 
+
See also: [[Building_LinuxMCE]] (these are the build scripts for the official cd build)
+
 
+
I have seen a lot of questions on how to set up a development environment for LMCE.
+
As a person with limited programming experience in c++, I can tell you that you don't have to be a master-level programmer to get your feet wet
+
and examine the source code, and even make changes that add new features or fix existing bugs. It just takes a little patience, some help from experienced members,
+
and a willingness to learn. There is a lot of information and help available in the forums, the wiki, and the linuxmce channel on IRC freenode servers.
+
 
+
That being said, dev work can also be risky business. You can seriously damage your installation compiling and testing changes, so '''USE THIS INFORMATION AT YOUR OWN RISK!'''
+
If you really want to get started developing, the best advice I can give is to get a separate computer to set up as a development machine, so you don't damage your existing LinuxMCE installation accidentally! That way, if you make a change that LMCE really doesn't like, you won't trash your personally installation. (Too bad I don't follow my own advice, as I've done this before!)
+
 
+
 
+
----
+
''The following tutorial represents my experiences only, and may not necessarily be the best or correct way to do things - though it has worked very well for me.''
+
 
+
As I am a linux user, I am going to describe this process as I set up a development environment on my core from a computer running Ubuntu linux. Other linux variants will be very similar, if not the same. For Windows users, there is equivalent software that you can use, though I can't name any off of the top of my head - you will have to do your own research on that one.
+
 
+
Be sure to set aside a free evening to set up your development environment, as it can take several hours to complete!
+
----
+
 
+
== Preface ==
+
The first thing I found surprising when I went to set up my first development environment is that it must be set up on your core. To my knowledge, you can't just make changes to the source on your desktop computer, compile them on your desktop computer, then upload them to the core. Everything must reside on the core, and you can have access to the source on your normal desktop over SSH (covered later). For those that aren't keen with working with a command line over ssh, this will take some getting used to (as was my case). But, once you get used to it, its not a bad development environment, and it even got me more familiar with the command line, and linux commands, which is something I've been meaning to do anyways.
+
Lets get started...
+
 
+
 
+
== Setting Up the Development Environment ==
+
Once you have a LinuxMCE Core up and running, the first thing we have to do is learn how to connect to it from our Desktop computer. On my Ubuntu desktop, I open a terminal via Applications->Accessories->Terminal.
+
We will now use SSH to connect to out core - enter the following into the terminal:
+
ssh linuxmce@192.168.80.1
+
When prompted for a password, enter "linuxmce".
+
''(You may be prompted for a password several times during the setup of your development environment - this will always be "linuxmce")''
+
 
+
 
+
Congratulations! You are now logged into the core over SSH from a remote computer! Now its time to install some packages needed for development. In the terminal, type:
+
sudo apt-get install subversion build-essential ccache
+
This will install Subversion (SVN), which is needed to keep your local copy of the source code in sync with the latest changes, and well as some development libraries.
+
 
+
 
+
For my development environment, I decided to keep everything in my Home directory. The source can actually go many places, but I prefer using the Home directory. Lets go there now...
+
cd ~/
+
 
+
 
+
To check out the most recent source code, run the following:
+
  svn co http://svn.linuxmce.org/svn/branches/trunk
+
 
+
if you have already compiled the sources, the make wo'nt install some packages required(since they are supposed to have already been installed). thus you need to run in trunk/
+
make clean
+
cp /usr/pluto/lib/* /src/lib/ -R
+
 
+
And finally, lets do a compile. This is necessary to setup more development packages, populate the source code with make files, etc. (Don't worry, this won't alter your current installation!) 
+
cd trunk
+
./configure
+
make
+
+
Now go take a break. This part may take a while!
+
 
+
'''GREAT!''' You now have the most recent version of the source code available to you and you will be able to compile changes!  You can run svn update at any time from within the trunk directory to get the latest changes that have been committed to SVN.
+
 
+
 
+
Now that this is finished, you are now ready to compile changes in the source code, then copy the resulting file to the appropriate place in the core.
+
 
+
 
+
----
+
'''A quick example'''
+
 
+
Since I am familiar with the CM11A source, I will use it as an example...
+
First i cd into the CM11A directory
+
cd ~/lmce/src/CM11A
+
Next I make changes to devicepoll.cpp..
+
Now I want to compile my changes.. But first I have found it good practice to delete any old object files etc. before compiling, so I usually run
+
rm *.o
+
rm CM11A
+
This removes the last resulting CM11A binary if present, as well as the object files that might be present from my last compile.
+
Next I compile the changes..
+
make bin
+
Once it is finished compiling, I have a new CM11A binary that just needs moved to the right place in the core.. In this instance it is /usr/pluto/bin/ (/usr/pluto/lib/ is another hot-spot to check, usually for .so files)
+
First, I remove the original file that I will be replacing..
+
sudo rm /usr/pluto/bin/CM11A
+
then I copy my newly compiled binary over..
+
sudo cp CM11A /usr/pluto/bin/CM11A
+
Now with a "quick reload router" from one of my orbiters, my changes will be in effect!
+
 
+
A quick note - if "make bin" does not work, you may need to run "make so" for some sources that end up being library files, and yet others require just "make". I'm not sure if there is a golden rule to all of this, but I just try each of them until one of them works. Then, for the most part, you can search /usr/pluto/bin and /usr/pluto/lib to see where the resulting compiled file should go.
+
Also, I have noticed that a "Full reload router" is necessary if you replace a library file (*.so)
+
 
+
== Helpful Tools and Hints ==
+
 
+
'''Compiling changes and where to put them on the core'''
+
 
+
As stated above, I am not sure if there is a golden rule to this, but depending on what you are trying to compile, you will have to use one of the following:
+
make
+
make bin
+
make so
+
If you try one and get an error, try another one (i'm sure there is a better approach to this!)
+
For the most part, you should be able to search through /usr/pluto/bin and /usr/pluto/lib to see where the resulting file should go.
+
 
+
 
+
'''Using VNC to remotely view the on-screen orbiter'''
+
 
+
As an Ubuntu user, I will explain it from how I do it from Ubuntu.
+
 
+
First, ssh to the core, and install VNC
+
ssh linuxmce@192.168.80.1
+
Now lets install VNC
+
sudo apt-get install x11vnc
+
Ok, once it is installed, run the VNC Server from the core
+
x11vnc
+
 
+
Now that you have a VNC server running on the core, lets start the client on our Ubuntu desktop:
+
First, open another terminal on your desktop
+
now run the following command (in the new terminal, not the terminal that is SSH'd into the core!)
+
vncviewer 192.168.80.1:0
+
 
+
Now you can take professional developer-grade screenshots of our on-screen orbiters!
+
(There are other tools available to take full recorded screencasts of these VNC sessions, but I've never used one)
+
Also note, that the VNC playback is not at full framerate - this is normal.
+
 
+
 
+
 
+
 
+
'''Navigating the core remotely with GUI'''
+
 
+
Unless you like editing source code in a terminal with vim, you will want to make things easier on yourself, and set things up so you can graphically browse the directory tree on the core, and edit source code files with gedit or a similar editor...
+
In ubuntu, go to Places->Connect To Server
+
A "Connect Tto Server" window will appear. Fill it out as follows:
+
Service Type - SSH
+
Server - 192.168.80.1
+
Port - 22
+
Folder - /
+
User Name - linuxmce
+
Name to use for connection - <anything you want> (I use Access Core Files)
+
 
+
You will now have a network folder on your desktop that you can access files with - without having to use the command line. (the first time you will be prompted for a password, which of course is 'linuxmce'. Double clicking files will now open them in your preferred desktop editor!
+
 
+
 
+
 
+
'''SSH-ing into a Media Director'''
+
 
+
I'm sure there is a better way, but here is what I do:
+
 
+
1)ssh into the core
+
ssh linuxmce@192.168.80.1
+
..enter password 'linuxmce'
+
 
+
2) navigate to /usr/pluto/diskless
+
cd /usr/pluto/diskless
+
 
+
3) get the "moon numbers" of the media directors
+
ls
+
note that each media director has a unique 3-digit number.. you will need this number in the following steps..
+
 
+
4) change over to the root user:
+
sudo su
+
...enter password 'linuxmce'
+
 
+
5) ssh into one of the media directors
+
ssh moonxxx
+
(xxx is the 3-digit number of one of the media directors)
+
 
+
You are now in the Media Director's file system, be careful, as you are root!
+
 
+
 
+
 
+
'''Installing phpMyAdmin to examine database structure etc.'''
+
phpMyAdmin is a graphical (web based) mysql front end that makes looking through the vast LMCE databases effortless. While I would never recommend adding or removing anything directly to the database this way, having a view of the database structure and the ability to easily browse through the tables really helps to understand LMCE and how it works much better. It also makes for a good reference when you are looking for primary keys that are so popular as device data. Now you can look up all of your options.
+
 
+
First, lets ssh into the core
+
ssh linuxmce@192.168.80.1
+
(use password linuxmce)
+
 
+
Now lets switch to the directory where the admin web pages are stored
+
cd /var/www/
+
 
+
...and download the tarball
+
sudo wget http://internap.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.11.7-rc1-english.tar.gz
+
 
+
Once the tarball is finished downloading, its time to extract it
+
sudo tar -xzvf  phpMyAdmin-2.11.7-rc1-english.tar.gz
+
 
+
You will now notice that if you list the directory contents (with ls), that you have a new phpMyAdmin-2.11.7-rc1-english directory. Thats fine, but who wants to type that in their web browser when they want to use phpMyAdmin. Lets rename it to something easier
+
sudo mv phpMyAdmin-2.11.7-rc1-english phpmyadmin
+
 
+
thats it! Now you can check out the database and learn from it. Again, be careful, as you can really, truely screw things up internally if you go adding and deleting entries.
+
To go to phpMyAdmin, in your web browser, just type 192.168.80.1/phpmyadmin
+

Latest revision as of 16:50, 13 October 2012

Please use the 810 development setup guide here