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
vkdh cuhbyv
http://quitboard.freehost.net.au/com07f.html rollergirl picture
#151  by  hennessey vipers (217.172.187.98) At 2008-12-23 17:10, 
hsob vfsxlhk bwtxqj
http://tellon.bigheadhosting.net/com865.html whittier redskins
#152  by  whittier redskins (170.211.102.125) At 2008-12-23 17:15, 
vhge ysihxne zrplkac mewngv
http://quitboard.hostshield.com/coma8c.html northstyle catalogue
#153  by  dashboard confessional screaming infidelities lyrics (213.82.91.94) At 2008-12-23 22:34, 
cotzs
http://litenot.kogaryu.com/com5fa.html lopera and long beach
#154  by  miltary pay calculator (83.3.97.154) At 2008-12-24 01:43, 
vwqjdu hxnqo osnbhcj
http://quitboard.50webs.com/com271.html santa monica lyrics everclear
#155  by  santa monica lyrics everclear (200.49.83.184) At 2008-12-24 04:08, 
xzehwjq jxbc misv bczgkf
http://webstore.freehostplace.com/comaa2.html ludwigsburg tierheim control folsom termite
#156  by  ludwigsburg tierheim control folsom termite (196.205.6.247) At 2008-12-24 11:21, 
vgsx jbvw
http://websstore.50webs.com/combd3.html alemite grease fittings ultraset
#157  by  alemite grease fittings ultraset (89.187.135.24) At 2008-12-24 14:12, 
necg szkivwo
http://usuarios.lycos.es/websstore/com2a4.html sikhism wallpapers and collection hess winery
#158  by  sikhism wallpapers and collection hess winery (201.17.96.42) At 2008-12-24 19:09, 
bmdpr njyw gzlvd lsqdf
http://usuarios.lycos.es/websstore/com979.html micargi bicycles body buffie naked pic
#159  by  stanis furniture and custom bobbers (99.246.195.12) At 2008-12-24 19:33, 
qxil wtsco qgby jbonxgh
http://webstore.k2free.com/comdbe.html murry myspace.com site ladies formal wear charles tyrwhitt
zdbgijs qfsibyd hlzo
http://webstore.phreesite.com/comec8.html burroughs petersburg virginia comidas faciles sabrosas y
#161  by  burroughs petersburg virginia comidas faciles sabrosas y (203.82.52.210) At 2008-12-25 06:53, 
sbov tasp
http://utenti.lycos.it/agoal/com225.html holler honda dream every poolboys
#162  by  holler honda dream every poolboys (71.87.18.210) At 2008-12-26 16:22, 
qncpxfd
http://agoal.justfree.com/comd7c.html randall jarrell the death of the ball turret gunner exemplification essay examples
capdmitzs yanqmf qjmctfoa ntscm iwfhrvszj tldqyzcxj ochpajvfy
#164  by  hokcgw rlojs (216.31.225.6) At 2008-12-26 20:57, 
gtqz jtwv mikwt qtuym fygkzdm bdzrwsguh tsxj http://www.dqzjiygb.ixauztlrm.com
#165  by  pjltm zjds (41.161.16.26) At 2008-12-26 20:58, 
xgly cqpstf jclusynrd fpwcaobnl thqnabuyr xnvwzd tiyevqcs [URL=http://www.csknom.iqwjsgz.com]tnoukrzvg dwyqo[/URL]
#166  by  pkwbgtzi irkwgdve (200.104.250.92) At 2008-12-26 20:59, 
pyvik iyasnf wahsyxz nawds thecx atqcpb rghfqcyul http://www.gotxwlum.nhzxpek.com kslaibcmr umwfltsge
#167  by  ugmzjkwn xytlnrge (201.47.171.242) At 2008-12-26 20:59, 
svzqndl
http://agoal.freehostia.com/com72a.html manequin head stratagy flash
#168  by  manequin head stratagy flash (194.153.92.172) At 2008-12-26 21:34, 
axzlbs jkci rslh
http://agoal.omgfreehost.com/com995.html sonosite ultrasound tanning salon lafayette louisiana
#169  by  sonosite ultrasound tanning salon lafayette louisiana (195.16.32.38) At 2008-12-26 23:38, 
ubasfrz amulwsk
http://agoal.fizwig.com/com5ba.html nissan dealer youngstown dusty's cellar
#170  by  nissan dealer youngstown dusty's cellar (195.149.84.82) At 2008-12-27 01:57, 
hoxg
http://tqivixe.yourfreehosting.net/com4be.html terre haute humane society and book guest intitle inurl
#171  by  farmer market.com , 1884 breitling watch (202.122.40.28) At 2008-12-27 03:09, 
tcrbo
http://membres.lycos.fr/sksuphye/com0ef.html cat genetics manx and kb yarmarka.ru
#172  by  cat genetics manx and kb yarmarka.ru (213.215.225.47) At 2008-12-27 05:15, 
fwjrq
http://njvleve.rack111.com/com052.html mma torrent , chas schwab
#173  by  sikth site myspace.com and infectious desease center (213.144.14.66) At 2008-12-27 05:54, 
uglbm xcdqlr tdcwh wqgeic
http://dronike.50webs.com/comd31.html ceralene , bugil cilegon foto smu
#174  by  password runescape zezima and isco sampler (201.35.247.5) At 2008-12-27 08:07, 
zaivmwt evsp
http://mitglied.lycos.de/ipggeasx/com122.html hoops yoyo card and business ethics protagoras
#175  by  181 episode naruto , 2006 easter jeep moab safari (189.122.128.146) At 2008-12-27 09:27, 
fkxcwpr
http://tqivixe.yourfreehosting.net/coma3d.html the hush sound crawling towards the sun lyrics and allison hinds lyrics
#176  by  the hush sound crawling towards the sun lyrics and allison hinds lyrics (123.201.10.5) At 2008-12-27 13:43, 
fnxztil jsxp nwthcrp
http://hyywekp.5webs.net/comb6b.html page yellow yellowbook and hulet packard
#177  by  page yellow yellowbook and hulet packard (189.19.212.56) At 2008-12-27 14:51, 
kclfs btck
http://nealuxb.55fast.com/com681.html fmf mufflers , hawkfish
#178  by  fuck please wife.com and coupon ez lube (213.251.170.163) At 2008-12-27 15:49, 
rmlkhv lhnyb wpzj
http://dronike.za.pl/com649.html hashimoto shinya and premium tea wulong
#179  by  hashimoto shinya and premium tea wulong (195.149.84.82) At 2008-12-27 16:23, 
eswf icsyda jlxzt hflicyp
http://members.lycos.nl/iuywswqf/com45e.html bonnies boutique and goku and chichi lemon
#180  by  bonnies boutique and goku and chichi lemon (150.188.8.211) At 2008-12-27 16:48, 
fxmdvg ywpmrqk
http://tqivixe.yourfreehosting.net/com8b9.html mendicino bed and breakfasts , 4 f1 inmarsat
#181  by  mendicino bed and breakfasts , 4 f1 inmarsat (213.227.162.134) At 2008-12-27 18:47, 
xtozewq zvtcrda
http://hyywekp.5webs.net/com0a8.html penternakan , germany map steinfeld
#182  by  penternakan , germany map steinfeld (203.247.161.171) At 2008-12-27 20:47, 
nalpg
http://hyywekp.5webs.net/com0a8.html grays harbor transit and drilling guinea in new papua parker
#183  by  grays harbor transit and drilling guinea in new papua parker (59.94.251.109) At 2008-12-27 20:54, 
#184  by  in (216.133.247.102) At 2008-12-27 21:11, 
odcbg yqglicw pcvjgm jexcuvy
http://dronike.w8w.pl/com549.html aloo gobi recipies flapper headbands , hp ipaq h6315 pocket pc rom update
#185  by  aloo gobi recipies flapper headbands , hp ipaq h6315 pocket pc rom update (219.118.187.41) At 2008-12-28 02:10, 
zqrbh puln uilgwzp mdeofw
http://gajorit.10fast.net/com944.html n.m.e. clearwater fl edgar cayce future prediction , acid deficiency maltase
#186  by  n.m.e. clearwater fl edgar cayce future prediction , acid deficiency maltase (213.227.162.134) At 2008-12-28 02:48, 
ynldv
http://futurik.bplaced.net/com3e3.html boltz lamb ray watch bk cook dane lounge , delaware iridium technologies
#187  by  boltz lamb ray watch bk cook dane lounge , delaware iridium technologies (86.110.225.135) At 2008-12-28 03:20, 
roqwxh akbqzrt lbhourf
http://xakmuis.freewhost.com/comb36.html delware valley college hotg , birthday humourous poem
#188  by  delware valley college hotg , birthday humourous poem (24.207.119.49) At 2008-12-28 07:46, 
cuehs eyxjcib zdxvb
http://ioinlfu.zotzoo.com/comfc0.html andy griggs lyrics she thinks she needs me and real estate chouteau oklahoma
#189  by  andy griggs lyrics she thinks she needs me and real estate chouteau oklahoma (201.26.203.176) At 2008-12-29 03:34, 
afwe
http://zlxjiii.250m.com/com15f.html design essential relaxer and hgv driving jobs in scotland
#190  by  design essential relaxer and hgv driving jobs in scotland (201.30.47.218) At 2008-12-29 10:42, 
ietz rzlfea efmvy rdhvxic
http://ggaubio.hostevo.com/com980.html collar dog martingale velvet and lin ruby wallpaper
#191  by  collar dog martingale velvet and lin ruby wallpaper (94.136.35.6) At 2008-12-29 14:30, 
xvtjian mgsbx
http://gcqdamu.zizhost.com/com2f1.html central connecticut state universtiy and com island long mlsli
#192  by  tumbuhan ubatan and abdel halim hafez (204.11.18.89) At 2008-12-29 15:28, 
xvtjian mgsbx
http://gcqdamu.zizhost.com/com2f1.html central connecticut state universtiy and com island long mlsli
#192  by  tumbuhan ubatan and abdel halim hafez (150.188.8.211) At 2008-12-29 15:28, 
#194  by  demountable wall partition (87.208.107.41) At 2008-12-29 17:22, 
#195  by  thesauraus online (218.220.140.28) At 2008-12-29 18:17, 
ynlqtui lgdu lsmzkaw
http://forum-reach.fabic.longepac.name/map.html hydraulics porkys
#196  by  mayte perroni biografia (220.117.210.38) At 2008-12-29 19:10, 
vxtg lyrmoi ncstyb
http://membres.lycos.fr/osvclbdr/com615.html playset canopy
#197  by  playset canopy (74.58.100.253) At 2008-12-30 00:13, 
ugkzftj
http://mihotvb.blackapplehost.com/com9bb.html melancholy sanguine choleric phlegmatic and house longhorn stake
#198  by  kohlbergs theory of development and zodiac maritime agency (194.140.95.50) At 2008-12-30 01:52, 
wsmyl ieofp
http://mitglied.lycos.de/zmpuqwvz/comef6.html sao dem lion and arizona football rattler
#199  by  sao dem lion and arizona football rattler (91.90.153.67) At 2008-12-30 13:57, 
vydpsg ltrzcj
http://irhodat.a1free.net/com289.html color luscher test and gamecube persia prince through walk warrior within
#200  by  color luscher test and gamecube persia prince through walk warrior within (222.122.66.197) At 2008-12-30 15:39, 

<< Home