Thứ Năm, 30 tháng 8, 2007

Makefiles by example

Makefiles

by example


Compiling your source code files can be tedious, specially when you want to include several source files and have to type the compiling command everytime you want to do it.
Well, I have news for you... Your days of command line compiling are (mostly) over, because YOU will learn how to write Makefiles.
Makefiles are special format files that together with the make utility will help you to automagically build and manage your projects.

For this session you will need these files:

I recommend creating a new directory and placing all the files in there.

note: I use g++ for compiling. You are free to change it to a compiler of your choice

The make utility

If you run
make
this program will look for a file named makefile in your directory, and then execute it.
If you have several makefiles, then you can execute them with the command:
make -f MyMakefile
There are several other switches to the make utility. For more info, man make.

Build Process

  1. Compiler takes the source files and outputs object files
  2. Linker takes the object files and creates an executable

Compiling by hand

The trivial way to compile the files and obtain an executable, is by running the command:
g++ main.cpp hello.cpp factorial.cpp -o hello

The basic Makefile

The basic makefile is composed of:

target: dependencies
[tab] system command
This syntax applied to our example would look like:
all:
g++ main.cpp hello.cpp factorial.cpp -o hello
[Download here]

To run this makefile on your files, type:

make -f Makefile-1
On this first example we see that our target is called all. This is the default target for makefiles. The make utility will execute this target if no other one is specified.
We also see that there are no dependencies for target all, so make safely executes the system commands specified.
Finally, make compiles the program according to the command line we gave it.

Using dependencies

Sometimes is useful to use different targets. This is because if you modify a single file in your project, you don't have to recompile everything, only what you modified.
Here is an example:
all: hello

hello: main.o factorial.o hello.o
g++ main.o factorial.o hello.o -o hello

main.o: main.cpp
g++ -c main.cpp

factorial.o: factorial.cpp
g++ -c factorial.cpp

hello.o: hello.cpp
g++ -c hello.cpp

clean:
rm -rf *o hello

[Download here]

Now we see that the target all has only dependencies, but no system commands. In order for make to execute correctly, it has to meet all the dependencies of the called target (in this case all).
Each of the dependencies are searched through all the targets available and executed if found.
In this example we see a target called clean. It is useful to have such target if you want to have a fast way to get rid of all the object files and executables.

Using variables and comments

You can also use variables when writing Makefiles. It comes in handy in situations where you want to change the compiler, or the compiler options.
# I am a comment, and I want to say that the variable CC will be
# the compiler to use.
CC=g++
# Hey!, I am comment number 2. I want to say that CFLAGS will be the
# options I'll pass to the compiler.
CFLAGS=-c -Wall

all: hello

hello: main.o factorial.o hello.o
$(CC) main.o factorial.o hello.o -o hello

main.o: main.cpp
$(CC) $(CFLAGS) main.cpp

factorial.o: factorial.cpp
$(CC) $(CFLAGS) factorial.cpp

hello.o: hello.cpp
$(CC) $(CFLAGS) hello.cpp

clean:
rm -rf *o hello
[Download here]

As you can see, variables can be very useful sometimes. To use them, just assign a value to a variable before you start to write your targets. After that, you can just use them with the dereference operator $(VAR).

Where to go from here

With this brief introduction to Makefiles, you can create some very sophisticated mechanism for compiling your projects. However, this is just a tip of the iceberg. I don't expect anyone to fully understand the example presented below without having consulted some Make documentation (which I had to do myself) or read pages 347 to 354 of your Unix book.

CC=g++
CFLAGS=-c -Wall
LDFLAGS=
SOURCES=main.cpp hello.cpp factorial.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=hello

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) -o $@

.cpp.o:
$(CC) $(CFLAGS) $< -o $@


[Download here]

If you understand this last example, you could adapt it to your own personal projects changing only 2 lines, no matter how many additional files you have !!!.


Hector Urtubia

Thứ Năm, 16 tháng 8, 2007

Visual Basic 6 Package and Deployment Wizard for setup file

Visual Basic 6 Package and Deployment Wizard for setup file
My Dear, Salman1karim
As you have finished your first project in vb6, MS Access 2003 and crystal reports 11 and you want to create setup file. You need Pdcmdln.EXE file to create setup program of VB6 for your project.
First of all compile your VB6 Project & Make project EXE file then run the project EXE independently from the Icon. If your project is working perfectly Ok then make a setup file as given below.
1. Collect all the files of your project in a folder
2. Then open Program File where you will get Microsoft Visual Studio
3. Open Microsoft Visual Studio then you will get VB98
4. Now openVB98 you will get Wizards then open Wizards folder then you will get PDWizard
5.Now open PDWizard then you will get Icon of Pdcmdln Application Program
6. Create a shortcut of Pdcmdln and send to desktop
7 Run Pdcmdln.EXE program by double click on desktop Icon of program Pdcmdln
8 you will get Package and deployment Wizard
9. Now Browse your project EXE file the click on Package it will create the setup file of your project
10. If you have already install MSDN then click on help for more details.

Hope Now you will make your setup file with complete installer of your project

Adeeb Raza

Command-line CD-ROM burning in Linux

Command-line CD-ROM burning in Linux

by Charlton Rose

You don't need fancy programs to burn CDs in Linux. You can do it all from the command line. Here are some quick and dirty patterns to get you started.

Mounting ISO images in Linux

CD-ROMs are often distributed (or pirated) digitally in the form of ISO images. Like a .zip or .tar file, an ISO image encapsulates a collection of files. The main difference is that an ISO image contains specific information about how those files are laid out on a CD-ROM. After you have acquired an ISO image, you can access its files immediately, even before you burn it onto a CD-ROM. These notes explain how.

You probably need to be root to do all of this.

To mount the image, simply issue the following command:

mount -t iso9660 -o loop image.iso /mnt/isoimage

where image.iso is the filename of the ISO image and /mnt/isoimage is the directory under which you want the ISO's files to appear (create it if necessary).

After doing this, you will be able to navigate through the ISO's files, starting from /mnt/isoimage, just as you would any other files in your file system, but with one exception: all of the files and directories mounted from the ISO will be read-only.

When you are finished looking at the files, unmount the ISO with

umount /mnt/isoimage

Creating an ISO image using mkisofs

If you need to generate your own ISO, mkisofs is a great tool for doing it. You don't need fancy tools or GUI front ends to use it, either (though you may wish to employ your favorite graphical file manager). Just follow these simple steps:

  1. Create a temporary directory from which the ISO's files will be read.

  2. Insert files into that directory and arrange them in the manner you would like them to appear in the ISO.

  3. From a directory outside of the tempoary ISO directory, run the following command:

    mkisofs -f -R -r -l -J -Vvolid -Aappid -Ppubid -odest.iso src

    where

    volid
    is the volume ID to be written into the master block;
    appid
    describes the application contained within the ISO;
    pubid
    names the publisher of the ISO (CD-ROM), usually including adequate contact information, such as a phone number or email address;
    dest.iso
    is the destination filename of the newly created ISO image;
    src
    is the temporary ISO directory containing the files and file structure you wish to have included in the ISO image.
  4. These parameters are good defaults. You can customize them, however. For more information, see man mkisofs.

Writing an ISO to a CD-ROM using cdrecord

Assuming that all you want to do is create a CD based on the ISO 9660 file system standard, you can quickly burn the CD using the following command:

cdrecord -v -pad speed=1 dev=0,0,0 src.iso

src.iso is the source filename of the ISO you are burning to the CD-ROM.

You may need to adjust the dev parameter if you are not burning with an IDE drive or you did not follow the instructions given in Configuring an IDE/ATAPI CD-ROM burner in RedHat Linux 6.1.

If you want, you can take the ISO image from stdin by replacing the filename with a hyphen ("-"). This works well with mkisofs if you replace the output image filename to that command with a hyphen also. Then you can chain the two commands together using a standard Unix pipe. Burning CD-ROMs in this manner reduces the total amount of temporary storage you will need, which may be useful if you are low on disk space.

Burning Audio CDs using cdrecord

Burning audio CDs using cdrecord is a piece of cake, too. Just follow these steps:

  1. Create your audio tracks and store them as uncompressed, 16-bit stereo .wav files.

  2. Name the audio files in a manner that will cause them to be listed in the desired track order when listed alphabetically, such as 01.wav, 02.wav, 03.wav, etc.

  3. Change into the directory containing the wave files and make sure there are not any wave files you do not want included in the CD.

  4. With a blank CD in your burner, issue the following command:

    cdrecord -v -pad speed=1 dev=0,0,0 -dao -audio -swab *.wav

    Again, you may need to adjust your dev parameter as mentioned earlier.

Copyright © 2000 Sharkysoft. All rights reserved.

[ Sharkysoft home | more Linux tips ]

Mounting the CD-ROM (Linux)

Mounting the CD-ROM (Linux)

Prerequisites

Root authority is required to perform this task.

Procedure

To mount the CD-ROM on Linux:

  1. Log in as a user with root authority.
  2. Insert the CD-ROM in the drive and enter the following command:
        mount -t iso9660 -o ro /dev/cdrom /cdrom    

    where /cdrom represents the mount point of the CD-ROM.

  3. Log out.

Your CD-ROM file system is now mounted. To view the contents of the CD-ROM, place the disk in the drive and enter the cd /cdrom command where cdrom is the CD-ROM mount point directory.

How to install Tomcat 5.5.9 on Ubuntu

Installing Tomcat on Ubuntu

Versions:
SDK: 1.5
JRE: 1.5
Tomcat: 5.5.9

Step 1 – Install JRE and SDK

Download and install the Java Software Development Kit (SDK) and J2SE Runtime Environment (JRE). These packages are available through Synaptic (the extra repositories have to be added).

Or in terminal type:

Code:

sudo apt-get install sun-j2re1.5
sudo apt-get install sun-j2sdk1.5

N.B. SDK is 146MB and JRE is 84.7MB.
You can verify that both items were installed corectly, by checking that you get a response when typing in terminal:

Code:

java -version
javac -help
Step 2 – Get tomcat

Download tomcat 5.5 from http://jakarta.apache.org/site/downloads/

In this example I am using jakarta-tomcat-5.5.9.tar.gz

Uncompress the file:

Code:

sudo tar -zxvf jakarta-tomcat-5.5.9.tar.gz
N.B. To make things simpler I also renamed the package to just 'tomcat'. If you do not do this, make sure you adjust these tutorial instructions to the name of your package whenever you see 'tomcat' written.

Step 3 – Add tomcat

Place the uncompressed package in:

/usr/local/

Step 4 – Set JAVA_HOME and CLASSPATH

You need to point out where you installed Java SDK. You will have to edit the file '.bashrc'. Backup this file first!

In terminal type:

Code:

sudo gedit ~/.bashrc
Add the following lines to the file:

Code:

export JAVA_HOME=/usr/local/java/j2sdk1.5/
exprt CLASSPATH=/usr/local/tomcat/common/lib/jsp-api.jar:/usr/local/tomcat/common/lib/servlet-api.jar
N.B. remember to change the word tomcat to the name of the package you placed in /usr/local.

Save and close. You will have to log out and back in again before these changes take effect.


The next steps are optional. They are for setting tomcat up to be used as a development environment. Skip to the last step ( Step 8 ) if you just want to start tomcat how it is.


Step 5 – Change default port number


Tomcats default port number is 8080. To change it to 1024 or another number do the following.

In terminal type:

Code:

sudo gedit /usr/local/tomcat/conf/server.xml
Find the lines:

Connector port = "8080" ...
maxThreads = "150" minSpareThreads = "25" ....


Adjust the port number to 1024 (or any other port number you want to use), save and close.

The last step
Open Web Browser and type http://localhost:1024/

Good luck

Thứ Tư, 15 tháng 8, 2007

YPOPs! and Mozilla Thunderbird

YPOPs! and Mozilla Thunderbird

A good article on configuring Thunderbird to work with YPOPs! is documented at OpenSourceArticles.com
Alternative instructions:
  • Click Tools-> Account Settings
  • Click Add Account button.
  • Choose Email account. Click Next
  • Type name and email address in the boxes. Click Next
  • Choose POP and type 'localhost' as the incoming server.
  • Depending on your preferences check or uncheck Use Global Inbox
  • Click Next. If your username is not already there by default, add it.
  • Click Next. Add the way you want your Account Name to look in Thunderbird.
  • Click Finish.
  • Now scroll down to the bottom of the Account Settings pane and click on Outgoing server (SMTP).
  • Click on Advanced. Click on Add.
  • Type 127.0.0.1 as the outgoing mail server. Port default is 25.
  • Check Use name and password. This is Thunderbird’s way of enabling authentication.
  • Type your Yahoo user name as username@yahoo.com.
  • Click No to Use secure connection and then OK twice.
  • Click OK to the Server Settings window.
  • Now get back into Account Settings
  • Go back to the Server Settings of you Yahoo Account in the Account Settings pane.
  • Do not check Use secure connection (SSL) or Use secure authentication.
  • Click on Advanced.
  • Choose where you want your emails to go in the POP tab.
  • Click on the SMTP tab and click on the drop down menu and select 127.0.0.1:25
  • Continue modifying any of your preferences in the account and then click on OK.

  • The first time you try to access the account, Mozilla will ask for a password and if you want Mozilla to remember the password.