Archive for January 7, 2010

Hướng dẫn cơ bản về Code::Blocks IDE


Hướng dẫn cơ bản về Code::Blocks IDE

Code::Blocks là một IDE (Môi trường phát triển tích hợp) dùng để phát triển C/C++ trên Windows và Linux rất thông dụng.  Code::Blocks được viết bằng bộ thư viện wxWidgets, giao diện khá đẹp và thân thiện. Code::Blocks có thể sử dụng nhiều trình biên dịch như GCC, Mingw,Borland C++ 5.5, Watcom C … và tích hợp sẵn các trình debug. Code có màu dễ nhìn rõ ràng, chương trình tự động xếp code 1 cách khoa học và dễ nhìn, chương trình tự động nhắc lệnh, tên hàm, tên biến trong quá trình soạn thảo, giúp cho công việc của người lập trình giảm tải đi khá nhiều.

Sau một thời gian dài không tung ra thử nghiệm phiên bản mới (RC1) mà chỉ update từng phần trên forum của Code::Blocks, nhóm phát triển đã tung ra phiên bản hoàn toàn cuối cùng (Final Release) Code::Blocks 8.02 (ý nhĩa là release tháng 2/2008). Đây là sản phẩm hoàn toàn miễn phí và Mã Nguồn Mở (opensource) theo giấy phép GPL v3.0. Code::Blocks có thể chạy đa nền trên nhiều loại HĐH : Windows, Linux, Mac OS .v.v.

Trang chủ: http://www.codeblocks.org

01 – Với HĐH Windows.
Link download trực tiếp phiên bản cho HĐH Windows
– Only IDE không có bộ dịch : http://nchc.dl.sourceforge.net/sourc…8.02-setup.exe => Không khuyên dùng.
– IDE và bộ dịch MinGW : http://jaist.dl.sourceforge.net/sour…ingw-setup.exe => Khuyên dùng.

02 – Với HĐH Ubuntu.
Các phiên bản Ubuntu từ 8.10 trở lên, Code:Blocks đã có sẵn trong kho phần mềm của Ubuntu.
Các bạn chỉ cần vào đó và cài đặt là OK.

Hoặc sử dụng lệnh này sudo apt-get install codeblocks build-essential

– Đối với máy không có mạng thì có thể dùng wapt-get để tải về cài.
Sau đó, copy những file *.deb này vào một thư mục nào đó (ví dụ ~/Desktop chẳng hạn). Mở Terminal lên sau đó gõ lệnh :

cd /thư/mục/chứa/các/files/deb
sudo dpkg -i *.deb

* Cách sử dụng :
– Cách sử dụng Code::Blocks cũng khá đơn giản
+ Tạo một trang mới : New > Empty file, hoặc ctrl +shift + n.
+ Hiển thị mầu chữ theo ngôn ngữ : Edit > Highlight mode > chọn loại ngôn ngữ
+ Biên dịch và chạy : F9

Chúc các bạn học tốt !

Nhóm WRU-OSS

Advertisements

Comments off

Installation for Ubuntu Linux: Code Block


1) Add the repositories to /etc/apt/sources.list:

Open the file with a graphical editor as root. Paste the following line in a terminal:

gksu gedit /etc/apt/sources.list

Paste this at the end:

# codeblocks
deb http://lgp203.free.fr/ubuntu/ gutsy universe
# wx widgets
deb http://apt.wxwidgets.org/ gutsy-wx main

Note: Depending on what version of Ubuntu you are using, in step 1 you
may need to replace gutsy with feisty.

2) To make sure your package system trusts these sources. Add their keys.

Enter these two lines at the terminal:

wget -q http://lgp203.free.fr/public.key -O- | sudo apt-key add -
wget -q http://apt.wxwidgets.org/key.asc -O- | sudo apt-key add -

And update the packages by entering the following lines on the terminal:

sudo apt-get update
sudo apt-get upgrade

3) Install Code::Blocks

Enter the following line in the terminal:

sudo apt-get install libcodeblocks0 codeblocks libwxsmithlib0 codeblocks-contrib

You are able to step 3 whenever you want you to get the latest nightly build.

You should see Code::Blocks in the Programming Languages listing of your programs.
Enjoy!

Comments off

Start IM through /etc/X11/xinit/xinput.d/all_ALL linked to /etc/X11/xinit/xinput.d/default.


Hi, I have installed 8.04 on a number of machines both real and virtual (VMWare). I am in the UK and use british keyboards.

I keep getting errors after a few days that means I cannot login.

I try to login and get a message

“Your session only lasted 10 seconds…”

~/.xsession-errors says…

“/etc/gdm/Xsession: Beginning session setip…
Setting IM through im-switch for locale=en_GB
Start IM through /etc/X11/xinit/xinput.d/all_ALL linked to /etc/X11/xinit/xinput.d/default.
mkdtemp: private socket dir: Permission denied”

I can only login to a safe terminal session.

Any ideas anyone?

=>

chmod 777 /tmp

sudo chmod 1777 /tmp

Comments off

/dev/sda1: UNEXPECTED INCONSISTENCY;


This is what appears when I boot to Ubuntu 8.04…

Checking drive /dev/sda1: 6% (stage 1/5, 27/286)
/dev/sda1: Inodes that were part of a corrupted orphan linked list found.

/dev/sda1: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY. (i.e., without -a or -p options)
fsck died with exit status 4
Checking drive /dev/sda1: 10% (stage 1/5, 44/286)

* An automatic file system check (fsck) of the root filesystem failed.
A manual fsck must be performed, then the system restarted.
The fsck should be performed in maintenance mode with the root filesystem mounted in read-only mode.
* The root file system is currently mounted in read-only mode.
A maintenance shell will now be started.
After performing system maintenance, press CONTROL-D to terminate the maintenance shell and restart the system.

bash: no job control in this shell
bash: groups: command not found
bash: lesspipe: command not found
bash: Command: command not found
bash: The: command not found
bash: dircolors: command not found
bash: Command: command not found
bash: The: command not found
root@lacroxste: ~#

What should I do to repair this problem….?

#fsck manually


#fsck -y /dev/sda1

===>>> OK

Comments off

Checking and Repairing Unix File system with fsck


fsck is a Unix utility for checking and repairing file system inconsistencies . File system can become inconsistent due to several reasons and the most common is abnormal shutdown due to hardware failure , power failure or switching off the system without proper shutdown. Due to these reasons the superblock in a file system is not updated and has mismatched information relating to system data blocks, free blocks and inodes .

fsck – Modes of operation :

fsck operates in two modes interactive and non interactive :

Interactive – fsck examines the file system and stops at each error it finds in the file system and gives the problem description and ask for user response whether to correct the problem or continue without making any change to the file system.

Non interactive :fsck tries to repair all the problems it finds in a file system without stopping for user response useful in case of a large number of inconsistencies in a file system but has the disadvantage of removing some useful files which are detected to be corrupt .

If file system is found to have problem at the booting time non interactive fsck is run and all errors which are considered safe to correct are corrected. But if still file system has problems the system boots in single user mode asking for user to manually run the fsck to correct the problems in file system

Running fsck :
fsck should always be run in a single user mode which ensures proper repair of file system . If it is run in a busy system where the file system is changing constantly fsck may see the changes as inconsistencies and may corrupt the file system .

If the system can not be brought in a single user mode fsck should be run on the partitions ,other than root & usr , after unmounting them . Root & usr partitions can not be unmounted . If the system fails to come up due to root/usr files system corruption the system can be booted with CD and root/usr partitions can be repaired using fsck.

command syntax

fsck [ -F fstype] [-V] [-yY] [-o options] special

-F fstype type of file system to be repaired ( ufs , vxfs etc)

-V verify the command line syntax but do not run the command

-y or -Y Run the command in non interactive mode – repair all errors encountered without waiting for user response.

-o options Three options can be specified with -o flag

b=n where n is the number of next super block if primary super block is corrupted in a file system .

p option used to make safe repair options during the booting process.

f force the file system check regardless of its clean flag.

special – Block or character device name of the file system to be checked/repaired – for example /dev/rdsk/c0t3d0s4 .Character device should be used for consistencies check & repair

fsck phases
fsck checks the file system in a series of 5 pages and checks a specific functionality of file system in each phase.

** phase 1 – Check Blocks and Sizes
** phase 2 – Check Pathnames
** phase 3 – Check Connectivity
** phase 4 – Check Reference Counts
** phase 5 – Check Cylinder Groups

fsck error messages & Corrective action :

1. Corrupted superblock – fsck fails to run
If the superblock is corrupted the file system still can be repaired using alternate superblock which are formed while making new file system .

the first alternate superblock number is 32 and others superblock numbers can be found using the following command :

newfs -N /dev/rdsk/c0t0d0s6

for example to run fsck using first alternate superblock following command is used

fsck -F ufs -o b=32 /dev/rdsk/c0t0d0s6

2. Link counter adjustment
fsck finds mismatch between directory inode link counts and actual directory links and prompts for adjustment in case of interactive operation. Link count adjustments are considered to be a safe operation in a file system and should be repaired by giving ‘y’ response to the adjust ? prompt during fsck.

3. Free Block count salvage
During fsck the number of free blocks listed in a superblock and actual unallocated free blocks count does not match. fsck inform this mismatch and asks to salvage free block count to synchronize the superblock count. This error can be corrected without any potential problem to the file system or files.

4. Unreferenced file reconnection
While checking connectivity fsck finds some inodes which are allocated but not referenced – not attached to any directory . Answering y to reconnect message by fsck links these files to the lost+found directory with their inode number as their name .

To get more info about the files in lost+found ‘file’ command can be used to see the type of files and subsequently they can be opened in their applications or text editors to find out about their contents. If the file is found to be correct it can be used after copying to some other directory and renaming it.

Comments off