Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Installing Qt toolkit on Linux

Trolltech

Trolltech is a Norwegian software company. It was founded in 1994. Since then, the company has grown rapidly. Trolltech has got two product lines. The famous Qt toolkit and the Qtopia. Qtopia is an application framework for embedded linux devices. Today Trolltech has about 200 employees and more than 4400 customers in 60 countries. Their headquaters is in Oslo. Trolltech is a new kind of a company. Together with MySQL AB, they are the most renowned companies that use the open source business model. Trolltech's motto is Create more, Code less.

Qt toolkit

Qt is a cross-platform application development framework. The most famous applications using Qt are KDE, Opera, Google Earth and Skype. Qt was first publicly released on May 1995. It is dual licenced. That means, it can be used for creating open source applications as well as proprietary ones. Qt toolkit is a very powerful toolkit. Only the Java Swing toolkit can match it's capabilities. The great advantage of the Qt is that it is a way faster than Swing. The look and feel of the Qt is also superior to Swing. On the other hand, the Swing toolkit is completely free of charge. For commercial development Qt is not free. Qt is well established in the open source community. Thousands of open source developes use Qt all over the world.
In June 2005, Trolltech has released the latest major release. The long awaited 4th version. The new version has a lot of new features, changes and improvements.
Trolltech introduced five new technologies.
  • Tulip - a set of template container classes
  • Interview - a model/view architecture for viewing items
  • Arthur - the painting framework
  • Scribe - the Unicode text renderer
  • Mainwindow - a modern action-based mainwindow, toolbar, menu, and docking architecture
The most exciting technology is definitely the Arthur painting framework.

Download

For non-commercial development Qt is free of charge. We can easily download the toolkit. We go to their download page. As we are talking about linux installation here, we choose the Qt/X11 Open Source Edition. The file name is qt-x11-opensource-src-4.2.3.tar.gz. The size of the file is 35.9MB. The file is archived and zipped. To unzip the file, we type the following command.
tar -zxf qt-x11-opensource-src-4.2.3.tar.gz
The command will unzip all the files to a directory qt-x11-opensource-src-4.2.3. The size of the directory is now 114.5 MB. Now it is time to carefully read the README and the INSTALL file. There we will find detailed installation instructions. The installations is easy and straightforward.

Install

We install the library the classic way. On Unix systems, installation of a software is divided into three steps.
  • Configuration
  • Building
  • Installation
First we run the configure script. The script will configure the library for our machine type. By default, the qt will be installed in /usr/local/Trolltech/Qt-4.2.3 directory. This can be changed by the -prefix parameter of the configure script. And it is the only option, that I used. I decided to install the library into the /usr/local/qt4 directory. Note that the installation word has two meanings here. It is the whole process consisting of all three steps. And it also means 'moving files to specific directories', which is the last, third step.
./configure -prefix /usr/local/qt4
This is the Qt/X11 Open Source Edition.

You are licensed to use this software under the terms of either
the Q Public License (QPL) or the GNU General Public License (GPL).

Type 'Q' to view the Q Public License.
Type 'G' to view the GNU General Public License.
Type 'yes' to accept this license offer.
Type 'no' to decline this license offer.

Do you accept the terms of either license? yes
The script will ask for licence acceptance. After we type yes, the script continues.
Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /usr/local/qt4

To reconfigure, run 'make confclean' and 'configure'.
After a short period of time, the script will nicely inform about the outcome.
The building of the qt toolkit takes several hours. It depends on the power of your processor. During the building my system went suddenly down. The temperature of the processor reached the critical value. This was due to my inefficient cooling probably. I always look at events optimistically. I figured out how to check temperature on the command line
cat /proc/acpi/thermal_zone/THRM/temperature
I also realized, that when you restart the building, it will continue where it has finished.
After the process finished, I saw no message like 'building finished successfully'. This is common, but in my opinion not correct.
The last step is installing, or moving files to the directories.
sudo make install
This command finishes the installation process. The library is now installed in /usr/local/qt4 directory. The size of the directory is 361.5 MB. As we can see, Qt is a huge library.
The last thing that we do, is adding the qt4 path to the PATH system variable. bash users, which are majority of linux users, need to edit the .profile file.
PATH=/usr/local/qt4/bin:$PATH
export PATH
The changes will be active after another login.

Testing a small example

Finally we will write a small code example.
#include <QApplication>
#include <QWidget>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QWidget window;

window.resize(250, 150);
window.setWindowTitle("Simple example");
window.show();

return app.exec();
}
To build this example, we will use a very handy tool called qmake.
qmake -project
qmake
make
If the qt4 installation directory is not a part of the PATH variable, we can provide the full path to the qmake tool.
/usr/local/qt4/qmake -project
/usr/local/qt4/qmake
make
Simple Qt4 example
Simple Qt4 example
Installation finished OK.
Continue Reading

set directory owner, group, and permissions on *nix machine

Execute the following commands via the command line:

sudo chgrp -R _www /Users/user_dir/target_dir
sudo chmod -R ug=rwx /Users/user_dir/target_dir
sudo find /Users/user_dir/target_dir -type d -exec chmod 2770 {} \;
sudo find /Users/user_dir/target_dir -type f -exec chmod ug=rwx {} \;
The first command sets the group to _www recursively.
The second command sets the owner and group permissions to rwx recursively.
The third command makes it so all new directories get created with the correct permissions (i.e. 2770).
The fourth command makes it so all new files get created with the correct permissions (i.e. rwx).

This post is simply a guide. Your values will differ depending on your desired outcome. In your case you may want to set only the group permissions or only the owner permissions (as opposed to both as illustrated in this post). The actual permission values you end up setting may differ too.
Continue Reading

Change a directory's group on *nix

chgrp usergroup somedir
If you want to change the directory's contents too, simply append the -R option to the chgrp command as shown below:
chgrp -R usergroup somedir
Note that somedir could also be a file (it doesn't have to be a directory). Also, if you want to change a directory's owner simply switch chgrp to chown. The options between the two commands are the same.
Continue Reading

.gitignore file isn't working as expected

# Run the following command (this removes everything from the index):
git rm -r --cached .

# Then, run:
git add .

# Finally, commit your changes:
git commit -m ".gitignore is now working"
Note, this answer's source came directly from http://stackoverflow.com/questions/1139762/gitignore-file-not-ignoring.
Continue Reading

Why is MAMP PRO so slow

Not sure. But I can tell you how to fix it.

Run the following series of commands:
# Where yoursite.local is the name of your site
sudo echo '::1 yoursite.local' > /tmp/newfile
sudo cat /etc/hosts >> /tmp/newfile
sudo mv /tmp/newfile /etc/hosts
Problem solved! Check it out for yourself at yoursite.local right now.

Cheers!
Continue Reading

Purpose of each directory in standard linux install

Run the following command:
man hier
and you'll have something like this that prints to your screen:
HIER(7)                                                                                                                Linux Programmer's Manual                                                                                                                HIER(7)

NAME
hier - Description of the file system hierarchy

DESCRIPTION
A typical Linux system has, among others, the following directories:

/ This is the root directory. This is where the whole tree starts.

/bin This directory contains executable programs which are needed in single user mode and to bring the system up or repair it.

/boot Contains static files for the boot loader. This directory only holds the files which are needed during the boot process. The map installer and configuration files should go to /sbin and /etc.

/dev Special or device files, which refer to physical devices. See mknod(1).

/etc Contains configuration files which are local to the machine. Some larger software packages, like X11, can have their own subdirectories below /etc. Site-wide configuration files may be placed here or in /usr/etc. Nevertheless, programs should
always look for these files in /etc and you may have links for these files to /usr/etc.

/etc/opt
Host-specific configuration files for add-on applications installed in /opt.

/etc/sgml
This directory contains the configuration files for SGML and XML (optional).

/etc/skel
When a new user account is created, files from this directory are usually copied into the user's home directory.

/etc/X11
Configuration files for the X11 window system (optional).

/home On machines with home directories for users, these are usually beneath this directory, directly or not. The structure of this directory depends on local administration decisions.

/lib This directory should hold those shared libraries that are necessary to boot the system and to run the commands in the root file system.

/media This directory contains mount points for removable media such as CD and DVD disks or USB sticks.

/mnt This directory is a mount point for a temporarily mounted file system. In some distributions, /mnt contains subdirectories intended to be used as mount points for several temporary file systems.

/opt This directory should contain add-on packages that contain static files.

/proc This is a mount point for the proc file system, which provides information about running processes and the kernel. This pseudo-file system is described in more detail in proc(5).

/root This directory is usually the home directory for the root user (optional).

/sbin Like /bin, this directory holds commands needed to boot the system, but which are usually not executed by normal users.

/srv This directory contains site-specific data that is served by this system.

/tmp This directory contains temporary files which may be deleted with no notice, such as by a regular job or at system boot up.

/usr This directory is usually mounted from a separate partition. It should hold only sharable, read-only data, so that it can be mounted by various machines running Linux.

/usr/X11R6
The X-Window system, version 11 release 6 (optional).

/usr/X11R6/bin
Binaries which belong to the X-Window system; often, there is a symbolic link from the more traditional /usr/bin/X11 to here.

/usr/X11R6/lib
Data files associated with the X-Window system.

/usr/X11R6/lib/X11
These contain miscellaneous files needed to run X; Often, there is a symbolic link from /usr/lib/X11 to this directory.

/usr/X11R6/include/X11
Contains include files needed for compiling programs using the X11 window system. Often, there is a symbolic link from /usr/include/X11 to this directory.

/usr/bin
This is the primary directory for executable programs. Most programs executed by normal users which are not needed for booting or for repairing the system and which are not installed locally should be placed in this directory.
Continue Reading

Install a trusted SSL cert on a linux

It starts with understand the basic pieces of the puzzle.

In SSL there's a concept of a "key pair". A "key pair" is composed of a "private key" and a matching "certificate signing request".

So, to get started, you need to create a private key. Yup, it's all you and it's as simple as running a single command. The private key is created via:

openssl genrsa -out www.yourdomain-example.com.key 2048
Then, after you've created your private key, you can proceed to creating your certificate signing request. Your "CSR" is created via:
openssl req -new -key www.yourdomain-example.com.key -out www.yourdomain-example.com.csr
This is the point in the process where you load your SSL cert with info about your company. You can read the following article if you have questions about what to enter for each prompt: https://knowledge.geotrust.com/support/knowledge-base/index?page=content&id=AR876

A public/private key pair has now been created. The private key (www.yourdomain-example.com.key) is stored locally on the server machine and is used for decryption. The public portion, in the form of a Certificate Signing Request (www.yourdomain-example.com.csr), will be used for certificate enrollment. System admins need to submit their www.yourdomain-example.com.csr files to a "trusted" signing authority such as VeriSign or GeoTrust. The trusted source will then respond with a related "public key". Information encrypted with a public key can only be decrypted with the corresponding private key, and vice-versa.

Okay cool, that makes sense and all but I've heard that intermediate certificates are involved too… What gives? Well, first things first, we should establish the purpose of an intermediate certificate. The purpose of an intermediate certificate is to provide maximum browser and server coverage to ensure visitors won't receive "invalid SSL" warnings when they visit your site. The "trusted sources" intermediate certificate bundle "chains" your SSL certificate to their trusted root certificates, letting your certificate secure connections with older browsers that might have only an old root certificate installed. So yes, you should be getting an intermediate certificate from your chosen certificate signing authority.

Installation of the cert depends on your web server software. Checkout the following GoDaddy support article that does a great job of describing how to install the cert depending on the web sever software you're working with here: http://support.godaddy.com/help/article/5346/installing-an-ssl-server-instructions?locale=en
Continue Reading

Uncompress a tarball

To uncompress a tarball, execute the following command(s) depending on the extension:
tar zxf file.tar.gz
tar zxf file.tgz
tar jxf file.tar.bz2
tar jxf file.tbz2
The following doc snippets explain the tar options being used:
#Extract: tar -xf <archive-filename>
#-z, -j, -J, --lzma Compress archive with gzip/bzip2/xz/lzma
Lastly, if you were to run "tar zxf file.tar.gz" you would end up with a new directory named "file" in your current directory.
Continue Reading

Install a command line tool after uncompressing

First, you need to cd into the directory created as a result of uncompressing via tar. Something along the lines of:
cd path-to-software/
Once in the directory, run the following command:
./configure
"./configure" will configure the software to ensure your system has the necessary functionality and libraries to successfully compile the package.

If you're doing this on a Mac and you get a missing "c compiler" type error then you probably just need to install Xcode's command line tools package. To do so, simply open Xcode, go to preferences then downloads. There is an "Install" link to add the command line tools. Once this has been completed, make sure to re-open your terminal window.

Then run:
make
"make" will compile all the source files into executable binaries.

The purpose of the make utility is to determine automatically which pieces of a large program need to be recompiled, and issue the commands to recompile them.

Then run:
sudo make install
From the documentation, "make install" will copy the executable file into a directory that users typically search for commands; copy any auxiliary files that the executable uses into the directories where it will look for them (e.g. /usr/local/bin/).

Lastly, most software packages have a README or INSTALL file you should probably take a look at. You can do so by running the following command:
cat README
Continue Reading

List of all running processes of linux

First, start off by listing the processes that are running on your machine (i.e. their names). You can do so via the following command:
ps -e
After running the above command you'll see a list of running process and their names. Find the one you're interested in (or the one you think you're interested in) and then use its name in the following command:
ps -U www-data -u www-data u
In this case we used the name 'www-data'. You should see the instances of that process listed and the percentage of memory/cpu each is using.

Lastly, you may be wondering what the 'ps' command does (other than what you've observed here). If you run the following command, you can read all about it:
man ps
Lastly (again), the 'top' command is really awesome. It does the same stuff as the commands above but in real-time:
top
Continue Reading