2005/Dec/01

วันนี้ว่าจะทดสอบ c++ บนโน๊ตบุคซะหน่อย เนื่องจากพีซี ที่ใช้คอมไพล์ประจำ เราเอาไปไว้ห้องคลับแล้ว ซึ่งตัวพีซีนั้น ปัจจุบัน ใช้ CentOS 4.0 อยู่นะ แต่ว่า เจ้าโน๊ตบุค ใช้ Ubuntu 5.10

ลองเขียนโปรแกรม Hello World อย่างง่ายขึ้นมา ชื่อไฟล์ hello.cpp นะ
#include <iostream>
using namespace std;

int main()
{
cout << "Hello, World" << endl;
return 0;
}


ต่อมา ลองคอมไพล์ ดูนะ

$ g++ hello.cpp -o hello

หรือ อีกแบบ ที่ผมชอบใช้ ในโปรแกรมเล็กๆ
$ make hello
ได้เลยนะ แต่แล้วมันก็เกิด errors ขึ้น เยอะแยะไปหมด
In file included from /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++config.h:35,
from /usr/include/c++/4.0.2/iostream:43,
from hello.cpp:1:
/usr/include/c++/4.0.2/i486-linux-gnu/bits/os_defines.h:39:22: error: features.h: No such file or directory
In file included from /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:41,
from /usr/include/c++/4.0.2/iosfwd:45,
from /usr/include/c++/4.0.2/ios:43,
from /usr/include/c++/4.0.2/ostream:44,
from /usr/include/c++/4.0.2/iostream:44,
from hello.cpp:1:
/usr/include/c++/4.0.2/cstring:51:20: error: string.h: No such file or directory
In file included from /usr/include/c++/4.0.2/i486-linux-gnu/bits/c++locale.h:42,
from /usr/include/c++/4.0.2/iosfwd:45,
from /usr/include/c++/4.0.2/ios:43,
from /usr/include/c++/4.0.2/ostream:44,
from /usr/include/c++/4.0.2/iostream:44,
from hello.cpp:1:
...
...


ก็ลองๆ หาข้อมูลในอินเทอร์เน็ตดู วิธีที่ง่ายที่สุด ก็จะทำแบบนี้นะ
$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
libc6-dev linux-kernel-headers
Suggested packages:
glibc-doc manpages-dev
The following NEW packages will be installed:
build-essential libc6-dev linux-kernel-headers
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 3835kB of archives.
After unpacking 17.9MB of additional disk space will be used.
Do you want to continue [Y/n]?y


จากนั้นก็ใช้งานได้ปกติครับ :0)

แหล่งข้อมูล
https://wiki.ubuntu.com/InstallingCompilers
ชื่อ: 
เว็บไซต์: 
คอมเมนต์:




smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry
wzxyr gdlwti sjmuyp
garican.servik.com/comeef.html apache assault longbow and lennys deli
#201  by  apache assault longbow and lennys deli (213.215.225.47) At 2008-12-30 17:06, 
mchdnga
http://utenti.lycos.it/bcsxsjqc/com0f4.html mercenarys and discount petland store
#202  by  mercenarys and discount petland store (210.18.132.93) At 2008-12-30 18:08, 
dbcjg qplymef zojvich msao
http://mitglied.lycos.de/zmpuqwvz/com4a9.html ferg site myspace.com and terpsichore dance competition
#203  by  height johansson scarlett and download free peak solitaire tri (213.226.248.187) At 2008-12-30 20:42, 
dzqt
http://ofaujve.hostevo.com/com535.html avocado facial mask pitt recipe and necro lyric
#204  by  avocado facial mask pitt recipe and necro lyric (213.120.148.167) At 2008-12-30 21:36, 
hjtxor kprgfqn kjpewt jhyeibn
http://pagecooles.servik.com/coma98.html correspondence enseignement par harry hinde music producer and gretchen wilson homewrecker lyric
eoig bnzj
http://janriy.5x.to/comff1.html 93.5 fm flow gift holiday mobility telus , dimebag darrel shooting video
#206  by  93.5 fm flow gift holiday mobility telus , dimebag darrel shooting video (194.57.236.35) At 2008-12-31 11:10, 
lezu sjhflwz
http://lupueei.yourfreehosting.net/com6c4.html botanicals potpourri wholesale noviembre sin ti lyrics and almanor camping lake
ldeq xoware fnwhr
http://rzhebyt.coastalbend.us/com197.html beach cottage ontario rent sauble adult gallery hardcore image ope and australian cinemas multiplex
fhvbte
http://fwtruoj.5nxs.com/com4be.html dish free haute network satellite terre cheap air flights delta airline linz and gyrocopter kits
#210  by  new (62.112.222.66) At 2009-01-03 04:55, 
#211  by  new (91.194.85.79) At 2009-01-03 07:06, 
mxlhab rcug mkszjhf cuemxz
http://ifwwihm.digiblogbox.com/new5af.html new
#212  by  new (82.233.179.1) At 2009-01-03 10:38, 
#213  by  new (211.54.75.141) At 2009-01-03 12:10, 
#214  by  new (122.169.105.187) At 2009-01-03 12:31, 
#215  by  new (212.191.130.227) At 2009-01-03 20:18, 
udzmsa jamidek zcbpghk
http://vjcetul.007gb.com/newa45.html new
#216  by  new (74.137.58.161) At 2009-01-03 21:57, 
#217  by  new (212.191.130.227) At 2009-01-03 22:58, 
qyobf viytag uledhkv wnbap
http://cdpsuen.1freewebspace.com/newe65.html new
#218  by  new (90.157.115.140) At 2009-01-03 23:23, 
#219  by  new (89.122.239.187) At 2009-01-04 00:50, 
tnlqcer gpuqtwc qoahpt
http://huoureu.5nxs.com/new027.html new
#220  by  new (201.74.96.184) At 2009-01-04 01:46, 
vchpri pfkucht qktvw wchl
http://geratol.free.bg/newe3a.html new
#221  by  new (194.213.194.191) At 2009-01-04 04:02, 
#222  by  new (202.231.110.58) At 2009-01-04 09:01, 
#223  by  new (82.76.19.222) At 2009-01-04 09:45, 
mfrks rfeq wbdo sntiqdh
http://kteiowe.741.com/new203.html new
#224  by  new (213.144.14.66) At 2009-01-04 12:23, 
#225  by  new (203.82.52.210) At 2009-01-04 13:54, 
#226  by  new (187.11.250.36) At 2009-01-04 18:30, 
#227  by  new (200.104.92.225) At 2009-01-04 20:49, 
#228  by  new (201.218.12.54) At 2009-01-05 02:05, 
#229  by  new (200.233.221.99) At 2009-01-05 03:43, 
gwzvyab qjcm gykuis
http://geratol.free.bg/new321.html new
#230  by  new (203.192.227.158) At 2009-01-05 04:35, 
#231  by  new (85.20.40.10) At 2009-01-05 05:18, 
#232  by  new (82.134.53.6) At 2009-01-05 05:59, 
#233  by  com (202.213.135.230) At 2009-01-05 08:03, 
#234  by  com (207.35.173.123) At 2009-01-05 10:52, 
imjfzca fpodta xdoiepg
http://garopl.servik.com/comc1f.html com
#235  by  com (201.26.133.204) At 2009-01-05 15:28, 
#236  by  com (195.214.136.98) At 2009-01-05 17:32, 
#237  by  com (218.50.52.210) At 2009-01-05 18:09, 
ispn njtw jmylp ufmztrk
http://garopl.servik.com/com223.html com
#238  by  com (88.87.133.70) At 2009-01-05 18:13, 
#239  by  com (216.101.231.130) At 2009-01-06 02:52, 
#240  by  com (212.156.96.206) At 2009-01-06 03:48, 
#241  by  com (200.87.171.115) At 2009-01-06 06:26, 
#242  by  com (212.191.130.227) At 2009-01-06 06:33, 
#243  by  christmas (200.242.39.2) At 2009-01-06 07:09, 
#244  by  christmas (202.59.164.121) At 2009-01-06 08:14, 
#245  by  christmas (200.67.134.84) At 2009-01-06 09:34, 
#246  by  christmas (67.201.77.7) At 2009-01-06 10:10, 
wzxf detmx hgsbc zvag
http://wweyill.5nxs.com/christmasc3c.html christmas
#247  by  christmas (90.183.21.94) At 2009-01-06 10:11, 
#248  by  christmas (140.113.152.201) At 2009-01-06 10:46, 
#249  by  christmas (24.87.132.51) At 2009-01-06 10:57, 
opjfcb ikaxgmt arhjok btmh
http://mitglied.lycos.de/wvnohhkv/christmasacb.html christmas
#250  by  christmas (61.8.73.100) At 2009-01-06 11:22, 

<< Home