libxml2でhello, world

ここを参考にXmlTextReaderでhello, world。

環境はUbuntu12.04。
libxml2をインストール。

$ sudo apt-get update;sudo apt-get install libxml2-dev

hello.cを作成。
[hello.c]

#include 

static void processNode(xmlTextReaderPtr reader) {
xmlChar *name, *value;

name = xmlTextReaderName(reader);
if (name == NULL)
name = xmlStrdup(BAD_CAST "--");
value = xmlTextReaderValue(reader);

printf("%d %d %s %d",
xmlTextReaderDepth(reader),
xmlTextReaderNodeType(reader),
name,
xmlTextReaderIsEmptyElement(reader));
xmlFree(name);
if (value == NULL)
printf("\n");
else {
printf(" %s\n", value);
xmlFree(value);
}
}
int main() {
char *filename = "hello.xml";
xmlTextReaderPtr reader;
int ret;

reader = xmlNewTextReaderFilename(filename);
if (reader != NULL) {
ret = xmlTextReaderRead(reader);
while (ret == 1) {
processNode(reader);
ret = xmlTextReaderRead(reader);
}
xmlFreeTextReader(reader);
if (ret != 0) {
printf("%s : failed to parse\n", filename);
}
} else {
printf("Unable to open %s\n", filename);
}
return 0;
}

ビルド。

$ gcc hello.c -o hello -I/usr/include/libxml2 -lxml2

hello.xmlを用意。
[hello.xml]

<?xml version="1.0" encoding="UTF-8"?>
hello, world

実行。

$ ./hello

0 1 message 0
1 3 #text 0 hello, world
0 15 message 0

vimをビルドしてみる

基本ここを試すだけ。
環境もUbuntu12.04LTS。

ビルドの準備。

$ sudo apt-get update;sudo apt-get install mercurial libncurses5-dev

ソースを取得してビルド。

$ hg clone https://vim.googlecode.com/hg/ vim
$ cd vim
$ ./configure --with-features=huge --enable-fail-if-missing
$ make

ビルドできた。
sudo make installでインストールだがここではできたファイルを直接起動してみる。

$ src/vim

起動した。使い方は良くわからない。

UbuntuでIrrlicht

ここを参考にUbuntu12.04でIrrlichtでhello, world。
まずここからirrlicht-1.8.zipをダウンロードして展開(今回は~/irrlicht-1.8/に展開)。

ビルドの準備。

$ sudo apt-get update;sudo apt-get install build-essential libglu1-mesa-dev libxxf86vm-dev

ビルド。

$ cd ~/irrlicht-1.8/source/Irrlicht
$ make

特に問題なくビルドまで終了。

とりあえずhello, world。
[~/main.cpp]

#include 
int main()
{
irr::IrrlichtDevice *device = irr::createDevice( irr::video::EDT_SOFTWARE, irr::core::dimension2d(640, 480), 16, false, false, false, 0);
device->setWindowCaption(L"hello, world");
irr::gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
guienv->addStaticText(L"hello, world",irr::core::rect(10,10,260,22), true);
irr::video::IVideoDriver* driver = device->getVideoDriver();
while(device->run())
{
driver->beginScene(true, true, irr::video::SColor(255,100,101,140));
guienv->drawAll();
driver->endScene();
}
device->drop();
return 0;
}

ビルドして実行。

$ cd~
$ g++ main.cpp ./irrlicht-1.8/lib/Linux/libIrrlicht.a -lGL -I./irrlicht-1.8/include/ -o hello
$ ./hello

ウインドウが出て「hello, world」が表示されたのでとりあえずよしとする。

Ubuntuでassimpをビルドして使ってみる

Ubuntu12.04でassimpをビルドして使ってみる。

まずここからassimp--3.0.1270-source-only.zipをダウンロードして展開。(今回は~/assimp--3.0.1270-source-only/へ展開)

ビルドの準備。

$ sudo apt-get update;sudo apt-get install build-essential cmake libboost-dev

assimpのビルド。

$ cd assimp--3.0.1270-source-only
$ mkdir build
$ cd build
$ cmake ../
$ make

特に問題なし。
assimp-cmdというツールがビルドされているのでテスト。
まず、テスト用データをダウンロード。
http://sketchup.google.com/3dwarehouse/details?mid=b22e101d86f50bcb89a16ec098e81015
からdae(Colladaファイル)を拝借。

$ cd ~/assimp--3.0.1270-source-only/build/tools/assimp_cmd/
$ ./assimp info models/model.dae

ファイルの情報が表示された。

Ubuntuでbullet

http://code.google.com/p/bullet/downloads/listからbullet-2.81-rev2613.tgz
をダウンロードして展開。(今回は~/bullet-2.81-rev2613/へ展開)

ここを参考にインストール。

ビルドの準備。

$ sudo apt-get update;sudo apt-get install build-essential cmake freeglut3-dev

ビルド。

$ cd ~
$ mkdir bullet-build
$ cd bullet-build
$ cmake .. -G "Unix Makefiles" -DINSTALL_LIBS=ON
$ make -j4

インストール。

$ sudo make install

このビルドでデモもビルドされているが、テストでビルドしてみる。

$ cd ~
$ g++ -I/usr/local/include/bullet bullet-2.81-rev2613/Demos/HelloWorld/HelloWorld.cpp -lBulletDynamics -lBulletCollision -lLinearMath -o hello
$ ./hello

コンソールに計算結果が表示された。

Ubuntuでgnuplot

Ubuntu12.04上にgnuplotをセットアップ。

端末から、

$ sudo apt-get install gnuplot

でインストール完了。

早速テスト。

$ gnuplot

	G N U P L O T
Version 4.4 patchlevel 3
last modified March 2011
System: Linux 3.2.0-26-generic-pae

Copyright (C) 1986-1993, 1998, 2004, 2007-2010
Thomas Williams, Colin Kelley and many others

gnuplot home: http://www.gnuplot.info
faq, bugs, etc: type "help seeking-assistance"
immediate help: type "help"
plot window: hit 'h'

Terminal type set to 'wxt'

と表示され起動した。

gnuplot> splot x*x+y*y

ウインドウが開きグラフが描画された。

終了は以下で。

gnuplot> quit

まずはここあたりでお勉強。