รูปภาพของ karyonix
karyonix
Rating 1
Posts: 10
Joined: 11-02-2008
ดูเหมือนจะไม่มีใครเชื่อที่ผมโพส ขออธิบายเพิ่มเติมแล้วกัน
ถ้าคุณติดตั้ง package build-essential สิ่งที่จะถูกติดตั้งเข้าไปจริงๆ ก็คือ packages เหล่านี้ :

dpkg-dev g++ g++-4.1 gcc libc6-dev libstdc++6-4.1-dev linux-libc-dev patch
เมื่อติดตั้งแล้วคุณก็จะสามารถ compile โปรแกรมภาษา C, C++ ได้แล้ว

แผ่นที่ผมทดสอบแล้วว่า นำมาใช้ติดตั้ง packages เหล่านี้ได้ครบชุด คือ Linux TLE 9.0 CD และ ubuntu 7.10 alternative CD (ไม่ใช่ live CD ที่ผมโพสข้างบนน่ะผิดนะขอโทษที) ทดสอบแล้วทั้งสองแผ่นว่าใช้ได้แน่ๆ

ส่วนแผ่น ubuntu 7.10 desktop live CD น่ะ อาจจะใช้ไม่ได้ ตอนบูตด้วย live CD มันมี gcc ติดตั้งมาด้วยเลย แต่ไม่มี libc-dev จึงไม่พอที่จะใช้ compile โปรแกรมจริงๆ ได้

สรุป สิ่งที่คุณควรทำคือ เอาแผ่น LinuxTLE 9.0 ใส่เข้าไป (มีแผ่นแล้วใช่ไหม) และสั่งสองคำสั่งนี้ ใน terminal โดยไม่ต้องต่อ internet ก็ได้

  • sudo apt-cdrom add
  • sudo apt-get install build-essential

ตัวอย่าง

tote@tote-desktop:~$ sudo apt-cdrom add
Using CD-ROM mount point /cdrom/
Unmounting CD-ROM
Waiting for disc...
Please insert a Disc in the drive and press enter
Mounting CD-ROM...
Identifying.. [f38417f7ed4311386f5496706aea66ed-2]
Scanning disc for index files..
Found 2 package indexes, 0 source indexes, 0 translation indexes and 1 signatures
This disc is called:
'Ubuntu 7.10 _Gutsy Gibbon_ - Release i386 (20071016.1)'
Copying package lists...gpgv: Signature made Tue 16 Oct 2007 06:24:30 AM ICT using DSA key ID FBB75451
gpgv: Good signature from "Ubuntu CD Image Automatic Signing Key <cdimage@ubuntu.com>"
Reading Package Indexes... Done
Writing new source list
Source list entries for this disc are:
deb cdrom:[Ubuntu 7.10 _Gutsy Gibbon_ - Release i386 (20071016.1)]/ gutsy main restricted
Unmounting CD-ROM...
Repeat this process for the rest of the CDs in your set.
tote@tote-desktop:~$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  dpkg-dev g++ g++-4.1 gcc libc6-dev libstdc++6-4.1-dev linux-libc-dev patch
Suggested packages:
  debian-keyring g++-multilib g++-4.1-multilib gcc-4.1-doc gcc-multilib
  manpages-dev autoconf automake1.9 libtool flex bison gcc-doc glibc-doc
  libstdc++6-4.1-doc diff-doc
The following NEW packages will be installed:
  build-essential dpkg-dev g++ g++-4.1 gcc libc6-dev libstdc++6-4.1-dev
  linux-libc-dev patch
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 0B/7939kB of archives.
After unpacking 32.0MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Selecting previously deselected package linux-libc-dev.
(Reading database ... 91707 files and directories currently installed.)
Unpacking linux-libc-dev (from .../linux-libc-dev_2.6.22-14.46_i386.deb) ...
Selecting previously deselected package libc6-dev.
Unpacking libc6-dev (from .../libc6-dev_2.6.1-1ubuntu9_i386.deb) ...
Selecting previously deselected package gcc.
Unpacking gcc (from .../gcc_4.1.2-9ubuntu2_i386.deb) ...
Selecting previously deselected package libstdc++6-4.1-dev.
Unpacking libstdc++6-4.1-dev (from .../libstdc++6-4.1-dev_4.1.2-16ubuntu2_i386.deb) ...
Selecting previously deselected package g++-4.1.
Unpacking g++-4.1 (from .../g++-4.1_4.1.2-16ubuntu2_i386.deb) ...
Selecting previously deselected package g++.
Unpacking g++ (from .../g++_4.1.2-9ubuntu2_i386.deb) ...
Selecting previously deselected package patch.
Unpacking patch (from .../p/patch/patch_2.5.9-4_i386.deb) ...
Selecting previously deselected package dpkg-dev.
Unpacking dpkg-dev (from .../dpkg-dev_1.14.5ubuntu16_all.deb) ...
Selecting previously deselected package build-essential.
Unpacking build-essential (from .../build-essential_11.3ubuntu1_i386.deb) ...
Setting up linux-libc-dev (2.6.22-14.46) ...
Setting up libc6-dev (2.6.1-1ubuntu9) ...
Setting up gcc (4:4.1.2-9ubuntu2) ...

Setting up patch (2.5.9-4) ...
Setting up dpkg-dev (1.14.5ubuntu16) ...
Setting up libstdc++6-4.1-dev (4.1.2-16ubuntu2) ...
Setting up g++-4.1 (4.1.2-16ubuntu2) ...
Setting up g++ (4:4.1.2-9ubuntu2) ...

Setting up build-essential (11.3ubuntu1) ...
tote@tote-desktop:~$ mkdir devel
tote@tote-desktop:~$ cd devel
tote@tote-desktop:~/devel$ cat > hello.c
#include <stdio.h>
int main ()
{
  printf ("hello user.\n");
  return 0;
}

tote@tote-desktop:~/devel$ gcc -o hello hello.c
tote@tote-desktop:~/devel$ ./hello
hello user.
tote@tote-desktop:~/devel$

ตอบ

Captcha
พิมพ์ตัวอักษรที่ท่านเห็นในรูปด้านบนในช่องด้านบนนี้ หมายเหตุ: การสมัครเป็นสมาชิกท่านจะได้รับความสะดวกในการเขียนเนื้อหา
Copy the characters (respecting upper/lower case) from the image.