July 2006 Archives
Mon, 2006-07-31 13:39:11 +0800
Embed - qvfb error in qt-x11-opensource-src-4.1.4 (continued)
At last I realised that it's the bug of qvfb in qt-x11-opensource-src-4.1.4. I copied the file tools/qvfb/qvfbhdr.h to qt-x11-opensource-src-4.1.4/tools/qvfb/ and gamke again. I still got some errors as follows:
... ... qvfbshmem.cpp:27:44 ../../src/gui/embedded/qlock.cpp: No such file or directory qvfbshmem.cpp:105: error: syntax error before '*' token ... ...
I searched qt-x11-preview-opensource-src-4.2.0-tp1 and got the file qlock.cpp in tools/qvfb, I donot know why but I am sure that it's the bug from source code. So I decided to compile the preview version for a try.
Mon, 2006-07-31 13:25:03 +0800
Embed - Qtopia-core installation and qvfb error in Qt-x11-opensource-src-4.1.4
qtopia-core-opensource-src-4.1.4 installation
It's easy to install this stuff, just unrar the .tar.gz file and use the command as follows:
#cd qtopia-core-opensource-src-4.1.4#./configure -prefix /path/to/Qtopia/core -debug-and-release -qvfb -qconfig full -depths 4,8,16,24,32#gmake#gmake install
Although it spent about 8 hours to compile, it still has no errors.
qvfb error in qt-x11-opensource-src-4.1.4
When I want to compile qvfb in qt-x11-opensource-src-4.1.4/tools/qvfb/ I got an error said:
... ... qvfbprotocol.cpp: 93: error: 'struct QVFbKeyData' has no member named 'keycode' ... ...
that means an error happened in the declaration of struct QVFbKeyData without member named keycode, but it was used in the file qvfbprotocol.cpp. The problem is that I searched all the files in qvfb and I still did not find any file defined the struct QVFbKeyData. At last I Googled it and find that the file named qvfbhdr.h may define this struct. However, after searching the qt-x11-opensource-src-4.1.4 directory I got nothing. I did not know what wrong with this version, maybe it's a bug!?
I have no idea but download the preview version of 4.2.0 named qt-x11-preview-opensource-src-4.2.0-tp1.tar.gz and compiling now, I hope this will be ok with file tools/qvfb/qvfbhdr.h.
Fri, 2006-07-28 13:52:28 +0800
500 OOPS: vsftpd: refusing to run with writable anonymous root
I met the error that is "500 OOPS: vsftpd: refusing to run with writable anonymous root" after I chown my ftp directory to the user ftp, then I Googled it and got the solution:
To avoid this error:
500 OOPS: vsftpd: refusing to run with writable anonymous root# chmod u-w /srv/ftp # mkdir /srv/ftp/pub # chown ftp:ftp /srv/ftp/pub
- The first line takes care of the root directory being not writable.
- The second line creates a directory.
- The third line changes the owner to the user and group ftp.
The ftp root directory MUST NOT be owned by ftp for security reasons (it should be root:root).
However, I just chown the ftp directory to another user of the system and solved this problem.
Fri, 2006-07-14 13:49:53 +0800
Windows, Solaris and Linux on a disk
Microsoft Windows (XP), SUN Solaris 10 (x86) and Slackware Linux
I have finally coexisted Windows, Solaris and Linux on my one disk. And the partition table is:
| Windows | Solaris | Linux Swap | Linux | +---------+---------+------------+-------- + | Pri (1) | Pri (2) | Pri (3) | Pri (4) | +---------+---------+------------+---------+
Microsoft Windows (XP)
First I installed Microsoft Windows (XP) on my first primary partition as shown above. It's easy to install Microsoft Windows XP on a raw harddisk, so I will not say anything about this.
SUN Solaris 10
About the installation you can refer to The way to SUN Solaris 10. It's also not very confused if you do make good preparation about SUN Solaris.
After this you can enter into Windows and Solaris with the bootloader of Solaris while Solaris partition is active.
Slackware Linux
At last I installed my favorite GNU/Linux distro --- Slackware Linux on the last primary partition. However, here I met some trouble about the label of my harddisk. Actually I have insert the harddisk to the first IDE interface, but it was recognized as the second IDE, that is, /dev/dsk/c0d1sx in Solaris and /dev/hdb in Linux. The question is that lilo make /dev/hda as default. (Refer to Installing Slackware for the installation of Slackware.) After Googling Windows, Solaris and Linux coexist with lilo I solved the problem as follows.
After installing the packages of Slackware it asked me to install lilo on Root or MBR, I selected MBR and generate an error showing that it's fail to install lilo on MBR. Then reboot the system and booting by the first Slackware CD and type:
bare.i root=/dev/hdb4 noinitrd ro
after the boot: prompt. Then you can boot the sytem using the new installed Slackware kernel and login the new Slackware system with root user. It is the point to change /etc/lilo.conf to:
# LILO configuration file # generated by 'liloconfig' # # Start LILO global section boot = /dev/hdb message = /boot/boot_message.txt prompt timeout = 60 # Override dangerous defaults that rewrite the partition table: change-rules reset # VESA framebuffer console @ 800x600x256 #vga = 771 # Normal VGA console # vga = normal # VESA framebuffer console @ 1024x768x64k # vga=791 # VESA framebuffer console @ 1024x768x32k # vga=790 # VESA framebuffer console @ 1024x768x256 # vga=773 # VESA framebuffer console @ 800x600x64k # vga=788 # VESA framebuffer console @ 800x600x32k # vga=787 # VESA framebuffer console @ 800x600x256 # vga=771 # VESA framebuffer console @ 640x480x64k # vga=785 # VESA framebuffer console @ 640x480x32k # vga=784 # VESA framebuffer console @ 640x480x256 # vga=769 # End LILO global section # Linux bootable partition config begins image = /boot/vmlinuz root = /dev/hdb4 label = Linux read-only # Linux bootable partition config ends # Windows bootable partition config begins other = /dev/hdb1 label = Windows table = /dev/hdb # Windows bootable partition config ends # UNIX bootable partition config begins other = /dev/hdb2 label = Solaris # UNIX bootable partition config ends
Then type the commands as follows:
#lilo -A /dev/hdb#lilo -M /dev/hdb#lilo
If no error happens then reboot the system and enjoy Windows, Solaris and Linux at hand.
Thu, 2006-07-13 13:51:41 +0800
X config and sendmail problem in Solaris (x86)
X config
Solaris also has some similar features and I did not find it until I want to set up the Refresh Frequency of my monitor. I googled it and find the same command as GNU/Linux which is xorgconfig in /usr/X11R6/bin/. That's convenient for me.
sendmail warning
I got the warning of sendmail with
DateTime FlyStar Sendmail[310]: my unqualified hostname (FlyStar) unknown; sleeping for retry.
At last, I found the solution on Trying SUN Solaris for Intel x86 by (still) Google.
Just modify the HOSTS file to use a dummy FQDN (Full Qualified Domain Name) for sendmail as follows:
192.168.10.20 solarisi solarisi.bigsunfan.com loghost
which the first solarisi is the hostname of the system and solarisi.bigsunfan.com is the dummy FQDN we used.
What is FQDN?
A fully qualified domain name consists of a host and domain name, including top-level domain. For example, www.webopedia.com is a fully qualified domain name. www is the host, webopedia is the second-level domain, and.com is the top level domain.
A FQDN always starts with a host name and continues all the way up to the top-level domain name, so www.parc.xerox.com is also a FQDN.
Wed, 2006-07-12 13:20:48 +0800
The way to SUN Solaris 10
Beginning
I was hign on SUN Solaris for a long time, however, I got the chance to use it just two days ago. That's Solaris(TM) 10 Operation System for x86 from Sun Microsystems in China free of charge. Although I was familiar with GNU/Linux, I still got some hills to walk over.
S/Aolaris Primary Boot Subsystem?
After creating a primary (it must be) partition for Solaris OS, I inserted the DVD into my SamSung Combo CD-RW/DVD driver. However, I got a screen with "Solaris Primary Boot Subsystem" first and then "Aolaris Primary Boot Subsystem" on the left corner of the screen. Everything halted there. After Googling the problem, I solved it by changing the option of "USB Controller" from "Enabled" to "Disabled" in BIOS. I still do not know why?
IP Conflicts!
It's really happy to see the thing going on correctly after that, but I think that I was happy earlier. After setting up my IP with "192.168.0.4" in LAN I got the warining said "WARNING: IP: HardWare address ':e0:4c:c4:2e:92' trying to be our address 192.168.000.004". It's obvious that's the IP conflicts with someone in LAN.
/sbin/sh or /bin/bash?
I was very familiar with Bash Shell not sh, so I try to change the default setting by changing the first line of file /etc/passwd:
root:x:0:0:Super-User:/:/sbin/sh
to
root:x:0:0:Super-User:/root:/bin/bash
It's unfortunately that I change the "/sbin/sh" to the wrong /sbin/bash and so I can not login in. At last I found a solution to login in a Solaris system by the installing DVD (exit when ask for installation). Mount the Solaris system on HardDisk by:
mkdir /tmp/FlyStarmount /dev/dsk/c0d1s0 /tmp/FlyStar
Here "c0d1s0" was the root partition of my System, you should ensure what's yours. Then correct the error.
Changing hostname in Solaris
It's so happy to see the interface to log in JDS (Java Desktop System). But I still got a warning about my hostname which I set it to "FlyZhyStar", the warning sounds like "WARNING: sendmail(xxx) xxx hostname". Sorry I forgot the details, but it told me that I indeed have a problem with the hostname of my System. Then I checked all the files that were related with hostname and got the correct one of "FlyStar".
- /etc/hostname.interface
- /etc/hosts ---> /etc/inet/hosts (ro)
- /etc/nodename
- /etc/inet/ipnodes (ro)
the "ro" means that it was read-only at first, you should use chmod +w file to make it writable and then change it. Make sure to change all the above files by substituting the old hostname by your new hostname.
NOTICE: I still did not solve this problem by changing the hostname of the System with the warning:
DateTime FlyZhyStar Sendmail[310]: my unqualified hostname (FlyZhyStar) unknown; sleeping for retry
I soloved this by Googling it in my next journal. Check that if you are still in this trouble.
IP reconfiguration in Solaris
I did not find a good tool to change IP configuration such as IP address, netmasks, gateway and DNS server. So I changed the configuration files related to IP (ipv4). The files related as follows:
| IP address | /etc/hosts ---> /etc/inet/hosts (ro) |
| netmasks | /etc/netmasks ---> /etc/inet/netmasks (ro) |
| gateway | /etc/defaultrouter |
| DNS server | /etc/nsswitch.conf /etc/resolv.conf (new) |
For /etc/nsswitch.conf of DNS server, just add the word "dns" after two lines with "hosts" and "networks" such as:
# # /etc/nsswitch.files: # # An example file that could be copied over to /etc/nsswitch.conf; it # does not use any naming service. # # "hosts:" and "services:" in this file are used only if the # /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports. passwd: files group: files hosts: files dns networks: files dns protocols: files rpc: files ethers: files netmasks: files bootparams: files publickey: files # At present there isn't a 'files' backend for netgroup; the system will # figure it out pretty quickly, and won't use netgroups at all. netgroup: files automount: files aliases: files services: files sendmailvars: files
And the file /etc/resolv.conf was created by me manually and the contents of it was:
search flyzhy.org nameserver 127.0.0.1 nameserver 192.168.0.254
Here FlyStar was the hostname and 192.168.0.254 was the DNS server.
Then reboot to connect the networks.
Continuing ...
It's good for me to see the interface of Solaris, I will continue to talk to her and know more about her. Also I still have some problems such as USB, there wheel button mouse, and so on.
Mon, 2006-07-10 14:26:34 +0800
The "-c" option of "gcc" or "g++"
I find a strange phenomena while compiling source code using gcc or g++ which is that if I add "-c" option before the source code it will not be executable of the compiling result. That is:
#gcc -o HelloWorld -c HelloWorld.c
will generate the "HelloWorld" without executable while
#gcc -o HelloWorld HelloWorld.c
will generate the executable binary file "HelloWorld". And I check it out using man gcc, then get the reason as follows:
... ... the -c option says not to run the linker. Then the output consists of object files output by the assembler. ... ...
That's the reason for that.
Mon, 2006-07-10 11:47:50 +0800
Volunteer of Beijing - 2006 Qingdao International Regatta
It's good to know that I will be a volunteer of Beijing - 2006 Qingdao International Regatta. It will last 14 days from August, 18 to August 31 in this year. That's good for me.
Mon, 2006-07-10 11:03:25 +0800
C++ Day 4 - Expressions and Statements
I met the confusing points in my C++ Day 4 which narattes Expressions and Statements.
What is an expression?
The answer is any statement that returns a value.
Is x = 0 evaluates to TRUE or FALSE?
I confused this question, and the answer is FALSE. That is, the if statement
if (a = VALUE) statement ...
is assigning, not testing for equality which should be if (a == CONSTANT). So, if the VALUE is not zero, the return value will be TRUE, else if the VALUE is zero and the return value will be FALSE. That is decided by the return value of the Expression a = VALUE.
Sun, 2006-07-09 18:30:15 +0800
JDK installation for Linux and "HelloWorld" test
It's easy to install the self-extracting file of J2SE(TM) Development Kit 5.0 Update 7 from J2SE Download. Just do the following operations:
#chmod +x jdk-1_5_0_07-linux-i586.bin#mv jdk-1.5.0_07 /path/to/your/jdk/
Then it's important to set up the environment variable for JDK such as JAVA_HOME, CLASSPATH and PATH, just modify the $HOME/.bashrc file to set up them by adding the following lines:
# $HOME/.bashrc for JDK export JAVA_HOME="/path/to/your/jdk/jdk1.5.0_07" export PATH="$PATH:$JAVA_HOME/jdk-1.5.0_07/bin" export CLASSPATH=".:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar"
At last run . ~/.bashrc to make them effective and write the first Java program "HelloWorld" to test:
/**
* The HelloWorldApp class implements an application that
* simply displays "Hello World!" to the standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
//Display "Hello World!"
System.out.println("Hello World!");
}
}
Then save the file with HelloWorldApp.java as its name (this is strict) and run:
#javac HelloWorldApp.java#java HelloWorldHello World!
Reference the following pages to make it more clear:
Sat, 2006-07-08 21:07:10 +0800
C++ Day 1 - Hello World!
This is the beginning of learning C++ and I choose Teach Yourself C++ in 21 Days (Second Edition) as the text book. I like documents like that such as Sams Teach Yourself Emacs in 24 Hours. It makes you getting started quickly, and that's why I choose this article as the beginning.
Day 1 --- Getting Started
From the introduction about the history of computer programming I got the development of computer languages including procedural, structured and Object-Oriented Programming. And four pillars of OOP (Object-Oriented Programming) are:
- encapsulation
- data hiding
- inheritance
- polymorphism
By compiling the first C++ Program of Hello.cpp which contains the following code in this document:
1: #include <iostream.h>
2:
3: int main()
4: {
5: cout << "Hello World!\n";
6: return 0;
7: }
with the command g++ -o Hello Hello.cpp I got the warning messages as follows:
In file included from /usr/include/c++/3.3.6/backward/iostream.h:31,
from helloworld.cpp:1:
/usr/include/c++/3.3.6/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
From the Q & A part of the author we know:
Q. Can I ignore warning messages from my compiler?
A. Many books hedge on this one, but I'll stake myself to this position: No! Get into the habit, from day one, of treating warning messages as errors. C++ uses the compiler to warn you when you are doing something you may not intend. Heed those warnings, and do what is required to make them go away.
Also I think this is a good idea for programmers and I got the solution for this warning by modifing the source code of Hello.cpp with:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!\n";
return 0;
}
and then compile the program with g++ -o Hello Hello.cpp we got the perfect result of our Hello World program which is the first outstanding of us.
Fri, 2006-07-07 15:18:05 +0800
Installing Qt/Windows
This is a document for installing Qt on Microsoft Windows OS.
Download
We need two files to install Qt on Windows OS which are Dev-Cpp and Qt-MinGW version:
- devcpp-version_setup.exe: http://prdownloads.sourceforge.net/dev-cpp/
- qt-win-opensource-version-mingw.exe: http://www.trolltech.com/developer/downloads/qt/windows
Installation
Installing Dev-Cpp first and then Qt-MinGW with the installation path of Dev-Cpp as its MinGW path.
Configuration
Set up the path of Dev-Cpp\bin and Qt\bin to the environment variable PATH and then run Start -> Programs -> Qt by Trolltech vversion (OpenSource) -> Qt version (Build Debug Libraries).
Test
Run qmake and make or make debug in the Qt\examples\tutorial\t1\ directory to test the "Hello World" example.
References
- QT/Windows OpenSource Installing Guide (in Chinese)
- Installing Qt/Windows (in Chinese)
Tue, 2006-07-04 22:26:37 +0800
AWK tip to match the fields between two files
Here exists a question. There are two files, one contains two columns with id and value, another contains three columns with rank, start value and end value which is the range of this rank. Now use a shell script to match the suitable range in the second file (assume range.txt) to the first file (assume id.txt). e.g:
- id.txt
136351119 2244 174844071 0 188180816 2145 231151815 0 272591688 35862 274301378 46985
- range.txt
l00 0 999 l01 1000 10000 l02 10001 20000 l03 20001 30000 l04 30001 40000 l05 40001 50000 l06 50001 70000 l07 70001 90000 l08 90001 110000 l09 110001 130000 l10 130001 260000 l11 260001 390000 l12 390001 520000 l13 520001 650000 l14 650001 910000 l15 910001 1170000 l16 1170001 1430000 l17 1430001 1690000 l18 1690001 1990000 l19 1990001 2290000 l20 2290001 4580000 l21 4580001 9160000 l22 9160001 18320000 l23 18320001 36640000 l24 36640001 73280000 l25 73280001 146560000 l26 146560001 293120000 l27 293120001 586240000 l28 586240001 1172480000 l29 1172480001 2344960000
The answer is:
awk ' BEGIN { i=1
while((getline < "range.txt")>0)
{ F[i]=$1; S[i]=$2; T[i]=$3; i++ }
line=i
}
{ for(j=1;j<=line;j++)
{ if($2>=S[j]&&$2<T[j]) printf "%s,%s\n",$1,F[j] }
}
' id.txt
