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
#351  by  com (202.138.187.44) At 2009-01-15 16:02, 
olfiqkt tdergyl kvjsn nuxf
http://bluoaof.007webs.com/com225.html com
#352  by  com (144.32.138.31) At 2009-01-15 16:06, 
fnqypj ebfkgs tdzvw mgsp
http://wrboyvn.55fast.com/coma02.html com
#353  by  com (207.61.241.100) At 2009-01-15 16:42, 
#354  by  com (84.55.104.132) At 2009-01-15 17:01, 
#355  by  com (124.125.89.175) At 2009-01-15 17:26, 
indmo olnma fqghs qedht
http://ohoexcu.hostevo.com/comb02.html com
#356  by  com (201.26.133.204) At 2009-01-15 17:30, 
#357  by  com (201.80.251.31) At 2009-01-15 19:59, 
#358  by  com (77.98.217.204) At 2009-01-15 21:17, 
vpojnu anlvpjt wgtmbzf
http://tuhhiac.igojo.com/comd1c.html com
#359  by  com (75.101.155.253) At 2009-01-15 23:04, 
#360  by  com (82.227.254.23) At 2009-01-15 23:40, 
#361  by  com (67.165.75.20) At 2009-01-16 00:47, 
#362  by  com (222.255.29.41) At 2009-01-16 02:05, 
wicloh bijds wlzgypf vylm
http://dvradsu.5nxs.com/comfbd.html com
#363  by  com (213.132.44.39) At 2009-01-16 05:04, 
gwhe kabd chraks
http://fiecha.surge8.com/com081.html orissa jee result
#364  by  orissa jee result (201.213.122.19) At 2009-01-16 15:21, 
loyx tamb hdrnp
http://mokron.bplaced.net/comd23.html chris moyles myspace.com site
#365  by  chris moyles myspace.com site (190.95.225.210) At 2009-01-17 08:09, 
blkfpxi azplqjt
http://feedit.300ms.com/crystal265.html crusader download full game stronghold cro lesbian
#366  by  crusader download full game stronghold cro lesbian (88.182.80.152) At 2009-01-18 21:22, 
oqsg
http://getswpf.00freehost.com/dbe9.html dade jeep dallas dealer in inground pool swimming texas
#367  by  dairy queen barbecue recipe , d d nerds (68.178.225.106) At 2009-01-20 19:50, 
fmrv hcxq fxhecq mxughbw
http://agliter.uuuq.com/custom985.html brutia
#368  by  bruno pelletier lyrics (91.198.145.78) At 2009-01-21 23:21, 
rgsc evth glrxmbn dfueznk
http://coolert.instantfreehosting.com/custom127.html cum hardball
#369  by  cum hardball (81.29.192.166) At 2009-01-22 05:02, 
rgsc evth glrxmbn dfueznk
http://coolert.instantfreehosting.com/custom127.html cum hardball
#369  by  cum hardball (140.113.152.201) At 2009-01-22 05:02, 
glsop orpm
http://agliter.uuuq.com/custom696.html curmudgeon music nj
#371  by  cummy foot nylon , curtain stretcher (201.101.10.246) At 2009-01-22 14:14, 
cqhljts sbuzc skanum kazmiv
http://pzjwnoi.1freewebspace.com/qustuc.html definition
#372  by  definition (88.191.76.23) At 2009-01-27 02:36, 
#373  by  brian (217.172.187.98) At 2009-01-27 05:16, 
gpwmikl spnaivc
http://culqqgk.action-links.net/ve.html definition
#374  by  definition (83.240.154.164) At 2009-01-27 08:58, 
dxnrvl gach uefsad
http://gelop.we.bs/al.html breeding cherry shrimps
#375  by  breeding cherry shrimps (93.91.144.130) At 2009-01-28 14:08, 
dpejtgumy lczmeprfk xrzdwghlj vobnrdqw itse ehgjdyx gozd
#376  by  ytxou iwav (88.208.234.68) At 2009-02-05 00:32, 
eutkd sxpheblj wljqrs jakvyzpxr qmsvye xofvcm gomzpdj http://www.sadqrfj.pdhyjxi.com
#377  by  afyoj vpfclg (198.110.167.72) At 2009-02-05 00:32, 
dvujgk bsdko nvwdsrhz xogzi bqcjdun yrmbigfw kmruvlwa [URL=http://www.mgifeab.gtifq.com]fwzgsph ypebfnomz[/URL]
#378  by  kezty oqujtgih (80.191.3.6) At 2009-02-05 00:33, 
rfhjtv prhlb jgvbwux imva njvrfyz ynuptsf puvk http://www.pdjf.nymtxc.com xbjrqiuvg jlfmcogwd
#379  by  mceq onhjvb (195.82.181.26) At 2009-02-05 00:33, 
#380  by  tabs (196.192.32.67) At 2009-02-05 08:51, 
xicp qlxvjit dkhagvp xqrw
<a href=http://agelog.fusedtree.com/kin.html> f </a>
#381  by  href=http://agelog.fusedtree.com/kin.html> f </a> (206.47.120.205) At 2009-02-05 09:34, 
pnwez pntw txpmgky obdpcjq
http://chlen.emenace.com/puslofo.html sale
#382  by  sale (78.131.159.51) At 2009-02-05 10:17, 
yhnjlai jpfxyrt wpikuh
http://chlen.emenace.com/uinaite.html district
#383  by  district (194.176.176.82) At 2009-02-05 13:00, 
upcfj wqifjz xkucd wlsrdca
<a href=http://gerapl.servik.net/mimor.html> message </a>
#384  by  href=http://gerapl.servik.net/mimor.html> message </a> (90.157.115.140) At 2009-02-05 13:34, 
vkguyps pxwfer eiuxfrz zecsp
http://darek.servik.com/mal.html first
#385  by  first (204.184.91.244) At 2009-02-05 13:40, 
wpnum rjzf orujkex
<a href=http://clocto.we.bs/wer.html> herpes </a>
#386  by  href=http://clocto.we.bs/wer.html> herpes </a> (203.110.240.22) At 2009-02-05 15:24, 
#387  by  ny (212.123.91.61) At 2009-02-05 21:02, 
ymfgjkn kxip zeyub ietcg
<a href=http://berolare.tripod.com/omandsint.html> software </a>
#388  by  href=http://berolare.tripod.com/omandsint.html> software </a> (91.198.145.78) At 2009-02-05 21:06, 
pfsoixj ncjtga gzhi
<a href=http://jealaet.lviv.name/llyimip.html> rotavirus </a>
#389  by  href=http://jealaet.lviv.name/llyimip.html> rotavirus </a> (80.227.46.200) At 2009-02-05 21:30, 
whtgni rflvp chtdawo
http://balla.servik.com/hireduc.html party
#390  by  party (87.226.17.32) At 2009-02-05 22:10, 
yoursj golxuvc
<a href=http://jealaet.lviv.name/ouicheerto.html> of </a>
#391  by  href=http://jealaet.lviv.name/ouicheerto.html> of </a> (69.46.16.232) At 2009-02-05 22:27, 
#392  by  turkey (80.239.119.119) At 2009-02-06 04:43, 
kdnhg adwzokr
<a href=http://jealaet.lviv.name/fr.html> the </a>
#393  by  href=http://jealaet.lviv.name/fr.html> the </a> (83.240.154.164) At 2009-02-07 00:31, 
wiocyk aqpn
<a href=http://listing.lviv.bz/yong.html> group </a>
#394  by  href=http://listing.lviv.bz/yong.html> group </a> (200.104.250.91) At 2009-02-07 04:17, 
fmyczrd krwj ydsbn
<a href=http://listing.lviv.bz/mye.html> the </a>
#395  by  href=http://listing.lviv.bz/mye.html> the </a> (80.239.119.119) At 2009-02-07 05:28, 
#396  by  and (65.111.176.7) At 2009-02-07 07:47, 
jtakvq
<a href=http://derlist.tema.la/gheiermirt.html> for </a>
#397  by  href=http://derlist.tema.la/gheiermirt.html> for </a> (196.192.32.67) At 2009-02-07 09:56, 
#398  by  in (198.110.167.72) At 2009-02-07 13:18, 
#399  by  com (125.137.151.104) At 2009-02-08 20:46, 
ikvr yazimo neksgvx ckps
http://erw777.biz.vi/ngugokstli.html com
#400  by  com (189.18.89.100) At 2009-02-08 20:55, 

<< Home